Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/commands/key-link/get-signing-keys-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ export default class GetSigningKeysList extends FireblocksBaseCommand {
'page-cursor': Flags.string({
description: 'Cursor to the next page',
}),
'page-size': Flags.string({
description: 'Amount of results to return in the next page',
default: '10',
'page-size': Flags.integer({
description: 'Amount of results to return in the next page (1-50)',
default: 10,
min: 1,
max: 50,
}),
'sort-by': Flags.string({
description: 'Field(s) to use for sorting',
Expand Down
8 changes: 5 additions & 3 deletions src/commands/key-link/get-validation-keys-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ export default class GetValidationKeysList extends FireblocksBaseCommand {
'page-cursor': Flags.string({
description: 'Cursor to the next page',
}),
'page-size': Flags.string({
description: 'Amount of results to return in the next page',
default: '10',
'page-size': Flags.integer({
description: 'Amount of results to return in the next page (1-50)',
default: 10,
min: 1,
max: 50,
}),
'sort-by': Flags.string({
description: 'Field(s) to use for sorting',
Expand Down
31 changes: 31 additions & 0 deletions test/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,37 @@ describe('e2e: full command execution flow', () => {
})
})

describe('Key Link page-size validation', () => {
it('forwards the maximum supported page size', async () => {
mockFireblocksFetch.mockResolvedValueOnce(createMockApiResponse(200, {data: []}))

const {default: GetValidationKeysList} = require(
'../src/commands/key-link/get-validation-keys-list.js'
)

try {
await GetValidationKeysList.run(['--page-size', '50', '--no-confirm'])
} catch (error: any) {
if (error?.oclif?.exit !== 0) throw error
}

expect(mockFireblocksFetch).toHaveBeenCalledTimes(1)
const [, , , options] = mockFireblocksFetch.mock.calls[0]
expect(options?.queryParams?.pageSize).toBe('50')
})

it('rejects page sizes above the API limit before making a request', async () => {
const {default: GetValidationKeysList} = require(
'../src/commands/key-link/get-validation-keys-list.js'
)

await expect(
GetValidationKeysList.run(['--page-size', '51', '--no-confirm']),
).rejects.toThrow(/less than or equal to 50/i)
expect(mockFireblocksFetch).not.toHaveBeenCalled()
})
})

describe('--output flag', () => {
it('outputs JSON by default', async () => {
const mockBody = {id: 'vault-1', name: 'My Vault', assets: []}
Expand Down