forked from jagregory/cognito-local
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): adminDeleteUser handles email usernames
The delete call to StormDB was parsing dots in email addresses as JSONPath separators and failing to delete the user. Fixes jagregory#99
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,57 @@ describe( | |
.promise() | ||
).rejects.toEqual(new UserNotFoundError("User does not exist")); | ||
}); | ||
|
||
it("deletes a user with an email address as a username", async () => { | ||
const client = Cognito(); | ||
|
||
// create the user | ||
const createUserResult = await client | ||
.adminCreateUser({ | ||
UserAttributes: [ | ||
{ Name: "email", Value: "[email protected]" }, | ||
{ Name: "phone_number", Value: "0400000000" }, | ||
], | ||
Username: "[email protected]", | ||
UserPoolId: "test", | ||
}) | ||
.promise(); | ||
|
||
// verify they exist | ||
const beforeUserResult = await client | ||
.adminGetUser({ | ||
Username: "[email protected]", | ||
UserPoolId: "test", | ||
}) | ||
.promise(); | ||
|
||
expect(beforeUserResult).toEqual({ | ||
Enabled: true, | ||
UserAttributes: createUserResult.User?.Attributes, | ||
UserCreateDate: createUserResult.User?.UserCreateDate, | ||
UserLastModifiedDate: createUserResult.User?.UserLastModifiedDate, | ||
Username: createUserResult.User?.Username, | ||
UserStatus: createUserResult.User?.UserStatus, | ||
}); | ||
|
||
// delete the user | ||
await client | ||
.adminDeleteUser({ | ||
Username: "[email protected]", | ||
UserPoolId: "test", | ||
}) | ||
.promise(); | ||
|
||
// verify they don't exist anymore | ||
await expect( | ||
client | ||
.adminGetUser({ | ||
Username: "[email protected]", | ||
UserPoolId: "test", | ||
}) | ||
.promise() | ||
).rejects.toEqual(new UserNotFoundError("User does not exist")); | ||
}); | ||
}, | ||
{ | ||
clock, | ||
|
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