Skip to content

Commit 9dff77c

Browse files
committed
add really explicit logging statements
1 parent fbb215d commit 9dff77c

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

packages/core/src/auth/providers/sharedCredentialsProviderFactory.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export class SharedCredentialsProviderFactory extends BaseCredentialsProviderFac
3535
}
3636

3737
private async needsRefresh(): Promise<boolean> {
38-
console.log('needs refreshCalled')
3938
const credentialsLastModMillis = await this.getLastModifiedMillis(getCredentialsFilename())
4039
const configLastModMillis = await this.getLastModifiedMillis(getConfigFilename())
4140

packages/core/src/test/credentials/auth.test.ts

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -515,37 +515,64 @@ describe('Auth', function () {
515515
accessKey: 'x',
516516
secretKey: 'x',
517517
}
518-
518+
console.log('generating file for the first time')
519519
await UserCredentialsUtils.generateCredentialsFile(initialCreds)
520520

521+
const initialStats = await fs.stat(getCredentialsFilename())
522+
const intialContent = await fs.readFileText(getCredentialsFilename())
523+
521524
const conn = await auth.getConnection({ id: 'profile:default' })
522525
assert.ok(conn?.type === 'iam', 'Expected an IAM connection')
523526
assert.deepStrictEqual(await conn.getCredentials(), {
524527
accessKeyId: initialCreds.accessKey,
525528
secretAccessKey: initialCreds.secretKey,
526529
sessionToken: undefined,
527530
})
528-
const statBefore = await fs.stat(getCredentialsFilename())
529-
531+
const contentBeforeDeleting = await fs.readFileText(getCredentialsFilename())
532+
const statBeforeDeleting = await fs.stat(getCredentialsFilename())
533+
console.log('Deleting the file')
530534
await fs.delete(getCredentialsFilename())
531-
console.log('file deleted')
532535

533536
const newCreds = { ...initialCreds, accessKey: 'y', secretKey: 'y' }
537+
console.log('regenerating the same file')
534538
await UserCredentialsUtils.generateCredentialsFile(newCreds)
535-
console.log('file written')
536-
const statAfter = await fs.stat(getCredentialsFilename())
539+
540+
const statsAfterRegen = await fs.stat(getCredentialsFilename())
541+
const contentAfterRegen = await fs.readFileText(getCredentialsFilename())
537542
const credsAreUpdated = (creds: Credentials) => {
538543
return creds.accessKeyId === newCreds.accessKey && creds.secretAccessKey === newCreds.secretKey
539544
}
540-
console.log('before: %O, after: %O', statBefore, statAfter)
541-
assert.notStrictEqual(statBefore, statAfter, 'Expected credentials file to be updated')
545+
console.log(
546+
'initial: %O, beforeDelete: %O, afterRegen: %O',
547+
initialStats,
548+
statBeforeDeleting,
549+
statsAfterRegen
550+
)
551+
552+
console.log('Before wait until')
553+
const start = Date.now()
542554
const credsUpdated = await waitUntil(async () => credsAreUpdated(await conn.getCredentials()), {
543-
timeout: 1000,
555+
timeout: 10000,
544556
interval: 100,
545557
truthy: true,
546558
})
547-
const statLater = await fs.stat(getCredentialsFilename())
548-
console.log('before: %O, after: %O, later: %O', statBefore, statAfter, statLater)
559+
console.log('After wait until: %O seconds later', (Date.now() - start) / 1000)
560+
const statAfterWait = await fs.stat(getCredentialsFilename())
561+
const contentAfterWait = await fs.readFileText(getCredentialsFilename())
562+
console.log(
563+
'stats: initial: %O, beforeDelete: %O, afterRegen: %O, afterWait: %O',
564+
initialStats,
565+
statBeforeDeleting,
566+
statsAfterRegen,
567+
statAfterWait
568+
)
569+
console.log(
570+
'content: initial: %O, beforeDelete: %O, afterRegen: %O, afterWait: %O',
571+
intialContent,
572+
contentBeforeDeleting,
573+
contentAfterRegen,
574+
contentAfterWait
575+
)
549576
assert.ok(credsUpdated, 'Expected credentials to be updated')
550577
})
551578
}

0 commit comments

Comments
 (0)