Skip to content

Commit e7d9798

Browse files
yuxianrzliramon1
authored andcommitted
fix authUtil tests and description for getMfaSerial
1 parent 7c8d60f commit e7d9798

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

packages/amazonq/test/unit/codewhisperer/util/authUtil.test.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,19 @@ describe('AuthUtil', async function () {
414414
describe('loginIam', function () {
415415
it('creates IAM session and logs in', async function () {
416416
const mockResponse = {
417-
id: 'test-credential-id',
418-
credentials: {
419-
accessKeyId: 'encrypted-access-key',
420-
secretAccessKey: 'encrypted-secret-key',
421-
sessionToken: 'encrypted-session-token',
417+
credential: {
418+
id: 'test-credential-id',
419+
kinds: [],
420+
credentials: {
421+
accessKeyId: 'encrypted-access-key',
422+
secretAccessKey: 'encrypted-secret-key',
423+
sessionToken: 'encrypted-session-token',
424+
},
422425
},
423426
updateCredentialsParams: {
424427
data: 'credential-data',
425428
},
426-
}
429+
} satisfies GetIamCredentialResult
427430

428431
const mockIamLogin = {
429432
login: sinon.stub().resolves(mockResponse),
@@ -433,25 +436,25 @@ describe('AuthUtil', async function () {
433436
sinon.stub(auth2, 'IamLogin').returns(mockIamLogin as any)
434437

435438
const response = await auth.loginIam({
436-
accessKey: 'accessKey',
437-
secretKey: 'secretKey',
438-
sessionToken: 'sessionToken',
439+
accessKey: 'testAccessKey',
440+
secretKey: 'testSecretKey',
441+
sessionToken: 'testSessionToken',
439442
})
440443

441444
assert.ok(mockIamLogin.login.calledOnce)
442445
assert.ok(
443446
mockIamLogin.login.calledWith({
444-
accessKey: 'accessKey',
445-
secretKey: 'secretKey',
446-
sessionToken: 'sessionToken',
447+
accessKey: 'testAccessKey',
448+
secretKey: 'testSecretKey',
449+
sessionToken: 'testSessionToken',
447450
roleArn: undefined,
448451
})
449452
)
450453
assert.strictEqual(response, mockResponse)
451454
})
452455

453456
it('creates IAM session with role ARN', async function () {
454-
const mockResponse: GetIamCredentialResult = {
457+
const mockResponse = {
455458
credential: {
456459
id: 'test-credential-id',
457460
kinds: [],
@@ -464,7 +467,7 @@ describe('AuthUtil', async function () {
464467
updateCredentialsParams: {
465468
data: 'credential-data',
466469
},
467-
}
470+
} satisfies GetIamCredentialResult
468471

469472
const mockIamLogin = {
470473
login: sinon.stub().resolves(mockResponse),
@@ -474,10 +477,10 @@ describe('AuthUtil', async function () {
474477
sinon.stub(auth2, 'IamLogin').returns(mockIamLogin as any)
475478

476479
const opts: auth2.IamProfileOptions = {
477-
accessKey: 'myAccessKey',
478-
secretKey: 'mySecretKey',
479-
sessionToken: 'mySessionToken',
480-
roleArn: 'arn:aws:iam::123456789012:role/MyTestRole',
480+
accessKey: 'testAccessKey',
481+
secretKey: 'testSecretKey',
482+
sessionToken: 'testSessionToken',
483+
roleArn: 'arn:aws:iam::123456789012:role/TestRole',
481484
}
482485

483486
const response = await auth.loginIam(opts)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ const errorMessageUserCancelled = localize('AWS.error.mfa.userCancelled', 'User
105105
/**
106106
* @description Prompts user for MFA serial number
107107
*
108-
* @param defaultSerial Default value for the serial number input
109-
* @param profileName Name of Credentials profile we are asking an MFA Token for
108+
* @param defaultSerial Default MFA serial number to pre-fill
109+
* @param profileName Name of Credentials profile we are asking an MFA serial for
110110
*/
111111
export async function getMfaSerialFromUser(defaultSerial: string, profileName: string): Promise<string> {
112112
const inputBox = createInputBox({

0 commit comments

Comments
 (0)