fix(api): count Cognito pool users directly
The runtime leaves EstimatedNumberOfUsers at 0, so the pool metadata now carries a userCount from ListUsers (capped at 1000), which the delete confirmation reads.
This commit is contained in:
@@ -121,12 +121,25 @@ describe('AwsUserPoolsAdapter', () => {
|
||||
signInWith: 'email',
|
||||
passwordPolicy: '8+ characters with uppercase, lowercase, number, symbol',
|
||||
estimatedNumberOfUsers: 1,
|
||||
userCount: 0,
|
||||
mfaConfiguration: 'OFF',
|
||||
deletionProtection: 'INACTIVE',
|
||||
appClients: [{clientId: 'a8e5c7d38d3b4a1a97c9d822de', clientName: 'orders-users-client'}],
|
||||
})
|
||||
})
|
||||
|
||||
test('counts users itself, since the runtime leaves EstimatedNumberOfUsers at 0', async () => {
|
||||
const {client} = stubCognito((command) => {
|
||||
if (command instanceof DescribeUserPoolCommand) return {UserPool: {...pool, EstimatedNumberOfUsers: 0}}
|
||||
if (command instanceof ListUsersCommand) return command.input.PaginationToken ? {Users: [alice]} : {Users: [alice, alice], PaginationToken: 'page-2'}
|
||||
return {}
|
||||
})
|
||||
const resource = await new AwsUserPoolsAdapter(client).get(POOL_ID)
|
||||
|
||||
expect(resource?.metadata.userCount).toBe(3)
|
||||
expect(resource?.metadata.estimatedNumberOfUsers).toBe(0)
|
||||
})
|
||||
|
||||
test('summarises a relaxed password policy without character rules', async () => {
|
||||
const {client} = stubCognito((command) => {
|
||||
if (command instanceof DescribeUserPoolCommand) return {UserPool: {...pool, Policies: {PasswordPolicy: {MinimumLength: 8, RequireUppercase: false, RequireLowercase: false, RequireNumbers: false, RequireSymbols: false}}}}
|
||||
|
||||
Reference in New Issue
Block a user