Skip to content

Commit 6bcf269

Browse files
add debounce sanity check test
Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 471739c commit 6bcf269

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/core/src/test/credentials/sso/ssoAccessTokenProvider.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ describe('SsoAccessTokenProvider', function () {
156156
assert.strictEqual(cachedToken, undefined)
157157
})
158158

159+
it('concurrent calls resolve successfully', async function () {
160+
// This test verifies debounced getToken() does not break things.
161+
// But this test is not perfect since we are unable to spy _getToken() for some reason.
162+
const validToken = createToken(hourInMs)
163+
await cache.token.save(startUrl, { region, startUrl, token: validToken })
164+
165+
const result = await Promise.all([sut.getToken(), sut.getToken(), sut.getToken()])
166+
for (const r of result) {
167+
assert.deepStrictEqual(r, validToken)
168+
}
169+
})
170+
159171
describe('Exceptions', function () {
160172
it('drops expired tokens if failure was a client-fault', async function () {
161173
const exception = new UnauthorizedClientException({ message: '', $metadata: {} })

0 commit comments

Comments
 (0)