File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed
test/credentials/provider Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -101,9 +101,15 @@ export abstract class SsoAccessTokenProvider {
101101 * Sometimes we get many calls at once and this
102102 * can trigger redundant disk reads, or token refreshes.
103103 * We debounce to avoid this.
104+ *
105+ * NOTE: The property {@link getTokenDebounced()} does not work with being stubbed for tests, so
106+ * this redundant function was created to work around that.
104107 */
105- public getToken = debounce ( this . _getToken . bind ( this ) , 100 )
106- public async _getToken ( ) : Promise < SsoToken | undefined > {
108+ public async getToken ( ) : Promise < SsoToken | undefined > {
109+ return this . getTokenDebounced ( )
110+ }
111+ private getTokenDebounced = debounce ( this . _getToken . bind ( this ) , 100 )
112+ private async _getToken ( ) : Promise < SsoToken | undefined > {
107113 const data = await this . cache . token . load ( this . tokenCacheKey )
108114 SsoAccessTokenProvider . logIfChanged (
109115 indent (
Original file line number Diff line number Diff line change 44 */
55
66import assert from 'assert'
7- import * as FakeTimers from '@sinonjs/fake-timers'
87import * as sinon from 'sinon'
98import { SharedCredentialsProvider } from '../../../auth/providers/sharedCredentialsProvider'
109import { stripUndefined } from '../../../shared/utilities/collectionUtils'
1110import * as process from '@aws-sdk/credential-provider-process'
1211import { ParsedIniData } from '@smithy/shared-ini-file-loader'
13- import { installFakeClock } from '../../testUtil'
1412import { SsoClient } from '../../../auth/sso/clients'
1513import { stub } from '../../utilities/stubber'
1614import { SsoAccessTokenProvider } from '../../../auth/sso/ssoAccessTokenProvider'
@@ -19,20 +17,13 @@ import { createTestSections } from '../testUtil'
1917const missingPropertiesFragment = 'missing properties'
2018
2119describe ( 'SharedCredentialsProvider' , async function ( ) {
22- let clock : FakeTimers . InstalledClock
2320 let sandbox : sinon . SinonSandbox
2421
2522 before ( function ( ) {
2623 sandbox = sinon . createSandbox ( )
27- clock = installFakeClock ( )
28- } )
29-
30- after ( function ( ) {
31- clock . uninstall ( )
3224 } )
3325
3426 afterEach ( function ( ) {
35- clock . reset ( )
3627 sandbox . restore ( )
3728 } )
3829
You can’t perform that action at this time.
0 commit comments