diff --git a/packages/widgets/access-key-management-widget/e2e/access-key-management-widget.spec.ts b/packages/widgets/access-key-management-widget/e2e/access-key-management-widget.spec.ts index f9e18b081..c8778cfb8 100644 --- a/packages/widgets/access-key-management-widget/e2e/access-key-management-widget.spec.ts +++ b/packages/widgets/access-key-management-widget/e2e/access-key-management-widget.spec.ts @@ -146,7 +146,7 @@ test.describe('widget', () => { const createAccessKeyNameInput = page.getByText('Name'); await createAccessKeyNameInput.last().fill('some access key name'); - await page.locator(`id=toggleButton`).last().click(); + await page.locator(`id=toggleButton`).nth(-2).click(); await expect( page.locator(`text=${mockRoles.roles[0].name}`).last(), ).toBeVisible(); @@ -157,7 +157,7 @@ test.describe('widget', () => { page.locator(`text=${mockRoles.roles[2].name}`).last(), ).toBeVisible(); - await page.locator(`id=toggleButton`).last().click(); + await page.locator(`id=toggleButton`).nth(-2).click(); // click modal create button const createAccessKeyButton = page diff --git a/packages/widgets/access-key-management-widget/src/lib/widget/api/sdk/createAccessKeySdk.ts b/packages/widgets/access-key-management-widget/src/lib/widget/api/sdk/createAccessKeySdk.ts index ec21d6bbd..d7ccd1fd0 100644 --- a/packages/widgets/access-key-management-widget/src/lib/widget/api/sdk/createAccessKeySdk.ts +++ b/packages/widgets/access-key-management-widget/src/lib/widget/api/sdk/createAccessKeySdk.ts @@ -73,6 +73,7 @@ export const createAccessKeySdk = ({ expiration, roleNames, userId, + permittedIps, }) => { const expirationTime = new Date(); expirationTime.setDate(expirationTime.getDate() + +expiration); @@ -80,7 +81,7 @@ export const createAccessKeySdk = ({ expiration[0] === '0' ? 0 : Math.floor(expirationTime.getTime() / 1000); if (mock) { return accessKey.create( - { name, expiration, roleNames, userId }, + { name, expiration, roleNames, userId, permittedIps }, expireTime, ); } @@ -92,6 +93,7 @@ export const createAccessKeySdk = ({ expireTime, roleNames, userId, + permittedIps, }, { queryParams: { tenant }, diff --git a/packages/widgets/access-key-management-widget/src/lib/widget/api/sdk/mocks.ts b/packages/widgets/access-key-management-widget/src/lib/widget/api/sdk/mocks.ts index 8d55115a8..7fd9fe110 100644 --- a/packages/widgets/access-key-management-widget/src/lib/widget/api/sdk/mocks.ts +++ b/packages/widgets/access-key-management-widget/src/lib/widget/api/sdk/mocks.ts @@ -20,6 +20,7 @@ const search: (config: SearchAccessKeyConfig) => Promise = async ({ expireTime: new Date().getTime() / 1000 + 60 * 60 * 24 * 30, createdTime: new Date().getTime() / 1000, roleNames: [`Role ${i}`], + permittedIps: ['127.1.2.3'], status: 'active', clientId: `Client ID ${i}`, boundUserId: `User ${i}`, @@ -45,7 +46,7 @@ const create: ( config: CreateAccessKeyConfig, expireTime: number, ) => Promise<{ cleartext: string; key: AccessKey }> = async ( - { name, roleNames, userId }, + { name, roleNames, userId, permittedIps }, expireTime, ) => { const i = Math.random().toString(10).substring(15); @@ -60,6 +61,7 @@ const create: ( expireTime, createdTime: new Date().getTime() / 1000, roleNames, + permittedIps, status: 'active', clientId: `Client ID ${i}`, boundUserId: userId || `User ${i}`, diff --git a/packages/widgets/access-key-management-widget/src/lib/widget/api/types.ts b/packages/widgets/access-key-management-widget/src/lib/widget/api/types.ts index 9d1cfd210..fc597bb1e 100644 --- a/packages/widgets/access-key-management-widget/src/lib/widget/api/types.ts +++ b/packages/widgets/access-key-management-widget/src/lib/widget/api/types.ts @@ -8,6 +8,7 @@ export type AccessKey = { id: string; name: string; roleNames: string[]; + permittedIps: string[]; status: string; createdTime: number; expireTime: number; @@ -33,6 +34,7 @@ export type CreateAccessKeyConfig = { expiration: string; roleNames: string[]; userId: string; + permittedIps: string[]; }; export type ActivateAccessKeyConfig = { diff --git a/packages/widgets/access-key-management-widget/test/access-key-management-widget.test.ts b/packages/widgets/access-key-management-widget/test/access-key-management-widget.test.ts index 7a3eb5b38..69226d892 100644 --- a/packages/widgets/access-key-management-widget/test/access-key-management-widget.test.ts +++ b/packages/widgets/access-key-management-widget/test/access-key-management-widget.test.ts @@ -224,6 +224,7 @@ describe('access-key-management-widget', () => { name: mockNewAccessKey.name, userId: mockNewAccessKey.userId, roleNames: mockNewAccessKey.roleNames, + permittedIps: mockNewAccessKey.permittedIps, expireTime: 0, }, { diff --git a/packages/widgets/access-key-management-widget/test/mocks/createAccessKeyModalMock.ts b/packages/widgets/access-key-management-widget/test/mocks/createAccessKeyModalMock.ts index 16e802329..c9e3f82c5 100644 --- a/packages/widgets/access-key-management-widget/test/mocks/createAccessKeyModalMock.ts +++ b/packages/widgets/access-key-management-widget/test/mocks/createAccessKeyModalMock.ts @@ -9,6 +9,7 @@ export default ` Never + Cancel Create diff --git a/packages/widgets/access-key-management-widget/test/mocks/mockAccessKeys.ts b/packages/widgets/access-key-management-widget/test/mocks/mockAccessKeys.ts index abb29fe20..7dad52c3c 100644 --- a/packages/widgets/access-key-management-widget/test/mocks/mockAccessKeys.ts +++ b/packages/widgets/access-key-management-widget/test/mocks/mockAccessKeys.ts @@ -11,6 +11,7 @@ export const mockAccessKeys: Record = { clientId: 'Client id 1', createdBy: 'created by 1', roleNames: [], + permittedIps: [], createdTime: new Date().getTime(), expireTime: new Date().getTime(), status: 'active', @@ -23,6 +24,7 @@ export const mockAccessKeys: Record = { clientId: 'Client id 2', createdBy: 'created by 2', roleNames: [], + permittedIps: [], createdTime: new Date().getTime(), expireTime: new Date().getTime(), status: 'active', @@ -35,6 +37,7 @@ export const mockAccessKeys: Record = { clientId: 'Client id 3', createdBy: 'created by 3', roleNames: [], + permittedIps: [], createdTime: new Date().getTime(), expireTime: new Date().getTime(), status: 'active', @@ -52,6 +55,7 @@ export const mockAccessKeysWithNonEditable: Record = { clientId: 'Client id 1', createdBy: 'created by 1', roleNames: [], + permittedIps: [], createdTime: new Date().getTime(), expireTime: new Date().getTime(), status: 'active', @@ -64,6 +68,7 @@ export const mockAccessKeysWithNonEditable: Record = { clientId: 'Client id 2', createdBy: 'created by 2', roleNames: [], + permittedIps: [], createdTime: new Date().getTime(), expireTime: new Date().getTime(), status: 'active', @@ -76,6 +81,7 @@ export const mockAccessKeysWithNonEditable: Record = { clientId: 'Client id 3', createdBy: 'created by 3', roleNames: [], + permittedIps: [], createdTime: new Date().getTime(), expireTime: new Date().getTime(), status: 'active', @@ -90,6 +96,7 @@ export const mockNewAccessKey: CreateAccessKeyConfig = { expiration: '0', userId: 'some user id', roleNames: ['aa', 'bb'], + permittedIps: ['127.1.2.3'], }; export const mockRoles = { diff --git a/packages/widgets/access-key-management-widget/test/mocks/rootMock.ts b/packages/widgets/access-key-management-widget/test/mocks/rootMock.ts index 5c81dc9a2..88b6ee18c 100644 --- a/packages/widgets/access-key-management-widget/test/mocks/rootMock.ts +++ b/packages/widgets/access-key-management-widget/test/mocks/rootMock.ts @@ -19,6 +19,7 @@ export default ` +