-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next/main' into chore/sync-console-preview-10-5-4
- Loading branch information
Showing
8 changed files
with
143 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,57 @@ describe('Loading tokens', () => { | |
expect(result?.deviceMetadata?.randomPassword).toBe('random-password'); | ||
expect(result?.deviceMetadata?.deviceKey).toBe('device-key'); | ||
}); | ||
|
||
test('load device tokens from store', async () => { | ||
const tokenStore = new DefaultTokenStore(); | ||
const memoryStorage = new MemoryStorage(); | ||
const userPoolClientId = 'userPoolClientId'; | ||
const userSub1 = '[email protected]'; | ||
const userSub1Encoded = 'user1%40email.com'; | ||
const userSub2 = '[email protected]'; | ||
|
||
memoryStorage.setItem( | ||
`CognitoIdentityServiceProvider.${userPoolClientId}.${userSub1Encoded}.deviceKey`, | ||
'user1-device-key' | ||
); | ||
memoryStorage.setItem( | ||
`CognitoIdentityServiceProvider.${userPoolClientId}.${userSub1Encoded}.deviceGroupKey`, | ||
'user1-device-group-key' | ||
); | ||
memoryStorage.setItem( | ||
`CognitoIdentityServiceProvider.${userPoolClientId}.${userSub1Encoded}.randomPasswordKey`, | ||
'user1-random-password' | ||
); | ||
memoryStorage.setItem( | ||
`CognitoIdentityServiceProvider.${userPoolClientId}.${userSub2}.deviceKey`, | ||
'user2-device-key' | ||
); | ||
memoryStorage.setItem( | ||
`CognitoIdentityServiceProvider.${userPoolClientId}.${userSub2}.deviceGroupKey`, | ||
'user2-device-group-key' | ||
); | ||
memoryStorage.setItem( | ||
`CognitoIdentityServiceProvider.${userPoolClientId}.${userSub2}.randomPasswordKey`, | ||
'user2-random-password' | ||
); | ||
|
||
tokenStore.setKeyValueStorage(memoryStorage); | ||
tokenStore.setAuthConfig({ | ||
Cognito: { | ||
userPoolId: 'us-east-1:1111111', | ||
userPoolClientId, | ||
}, | ||
}); | ||
const user1DeviceMetadata = await tokenStore.getDeviceMetadata(userSub1); | ||
expect(user1DeviceMetadata?.randomPassword).toBe('user1-random-password'); | ||
expect(user1DeviceMetadata?.deviceGroupKey).toBe('user1-device-group-key'); | ||
expect(user1DeviceMetadata?.deviceKey).toBe('user1-device-key'); | ||
|
||
const user2DeviceMetadata = await tokenStore.getDeviceMetadata(userSub2); | ||
expect(user2DeviceMetadata?.randomPassword).toBe('user2-random-password'); | ||
expect(user2DeviceMetadata?.deviceGroupKey).toBe('user2-device-group-key'); | ||
expect(user2DeviceMetadata?.deviceKey).toBe('user2-device-key'); | ||
}); | ||
}); | ||
|
||
describe('saving tokens', () => { | ||
|
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
Oops, something went wrong.