-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement DeleteUserPoolCommand and DeleteUserPoolClientCommand
- Loading branch information
Showing
7 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import { | ||
AdminCreateUserCommand, | ||
CreateUserPoolClientCommand, | ||
CreateUserPoolCommand, | ||
DeleteUserPoolClientCommand, | ||
DeleteUserPoolCommand, | ||
ListUserPoolClientsCommand, | ||
ListUserPoolsCommand, | ||
} from '@aws-sdk/client-cognito-identity-provider'; | ||
import { cognitoClient } from 'service/cognito'; | ||
import { expect, test } from 'vitest'; | ||
|
@@ -14,3 +19,54 @@ test(CreateUserPoolCommand.name, async () => { | |
expect(pool.UserPool?.Name === 'testPool').toBeTruthy(); | ||
expect(client.UserPoolClient?.ClientName === 'testClient').toBeTruthy(); | ||
}); | ||
|
||
// eslint-disable-next-line complexity | ||
test(DeleteUserPoolCommand.name, async () => { | ||
const pool = await cognitoClient.send(new CreateUserPoolCommand({ PoolName: 'testPool' })); | ||
|
||
await cognitoClient.send( | ||
new CreateUserPoolClientCommand({ ClientName: 'testClient', UserPoolId: pool.UserPool?.Id }), | ||
); | ||
await cognitoClient.send( | ||
new AdminCreateUserCommand({ | ||
UserPoolId: pool.UserPool?.Id, | ||
Username: 'test', | ||
UserAttributes: [{ Name: 'email', Value: '[email protected]' }], | ||
}), | ||
); | ||
|
||
const res1 = await cognitoClient.send(new ListUserPoolsCommand({ MaxResults: 100 })); | ||
|
||
await cognitoClient.send(new DeleteUserPoolCommand({ UserPoolId: pool.UserPool?.Id })); | ||
|
||
const res2 = await cognitoClient.send(new ListUserPoolsCommand({ MaxResults: 100 })); | ||
|
||
expect(res1.UserPools?.length).toBe(2); | ||
expect(res2.UserPools?.length).toBe(1); | ||
}); | ||
|
||
// eslint-disable-next-line complexity | ||
test(DeleteUserPoolClientCommand.name, async () => { | ||
const pool = await cognitoClient.send(new CreateUserPoolCommand({ PoolName: 'testPool' })); | ||
const client = await cognitoClient.send( | ||
new CreateUserPoolClientCommand({ ClientName: 'testClient', UserPoolId: pool.UserPool?.Id }), | ||
); | ||
|
||
const res1 = await cognitoClient.send( | ||
new ListUserPoolClientsCommand({ UserPoolId: pool.UserPool?.Id, MaxResults: 100 }), | ||
); | ||
|
||
await cognitoClient.send( | ||
new DeleteUserPoolClientCommand({ | ||
ClientId: client.UserPoolClient?.ClientId, | ||
UserPoolId: pool.UserPool?.Id, | ||
}), | ||
); | ||
|
||
const res2 = await cognitoClient.send( | ||
new ListUserPoolClientsCommand({ UserPoolId: pool.UserPool?.Id, MaxResults: 100 }), | ||
); | ||
|
||
expect(res1.UserPoolClients?.length).toBe(1); | ||
expect(res2.UserPoolClients?.length).toBe(0); | ||
}); |