Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ export async function startLanguageServer(
},
credentials: {
providesBearerToken: true,
// Add IAM credentials support
providesIamCredentials: true,
supportsAssumeRole: true,
},
},
/**
Expand Down Expand Up @@ -211,9 +214,10 @@ export async function startLanguageServer(

/** All must be setup before {@link AuthUtil.restore} otherwise they may not trigger when expected */
AuthUtil.instance.regionProfileManager.onDidChangeRegionProfile(async () => {
const activeProfile = AuthUtil.instance.regionProfileManager.activeRegionProfile
void pushConfigUpdate(client, {
type: 'profile',
profileArn: AuthUtil.instance.regionProfileManager.activeRegionProfile?.arn,
profileArn: activeProfile?.arn,
})
})

Expand Down
43 changes: 42 additions & 1 deletion packages/amazonq/test/unit/codewhisperer/util/authUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,50 @@ describe('AuthUtil', async function () {

assert.ok(mockIamLogin.login.calledOnce)
assert.ok(
mockIamLogin.login.calledWith({
mockIamLogin.login.calledWithMatch({
accessKey: 'accessKey',
secretKey: 'secretKey',
sessionToken: 'sessionToken',
})
)
assert.strictEqual(response, mockResponse)
})

it('creates IAM session with role ARN', async function () {
const mockResponse = {
id: 'test-credential-id',
credentials: {
accessKeyId: 'encrypted-access-key',
secretAccessKey: 'encrypted-secret-key',
sessionToken: 'encrypted-session-token',
roleArn: 'arn:aws:iam::123456789012:role/TestRole',
},
updateCredentialsParams: {
data: 'credential-data',
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a type exist that we could do: } as ReturnTypeOfLogin so that the actual fields are type checked?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will add this.


const mockIamLoginArn = {
login: sinon.stub().resolves(mockResponse),
loginType: 'iam',
}

sinon.stub(auth2, 'IamLogin').returns(mockIamLoginArn as any)

const response = await auth.loginIam(
'accessKey',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: In the future I'd make these values a bit more unique, like MyAccessKey to reduce confusion since there is also the key which is called accessKey

'secretKey',
'sessionToken',
'arn:aws:iam::123456789012:role/TestRole'
)

assert.ok(mockIamLoginArn.login.calledOnce)
assert.ok(
mockIamLoginArn.login.calledWith({
accessKey: 'accessKey',
secretKey: 'secretKey',
sessionToken: 'sessionToken',
roleArn: 'arn:aws:iam::123456789012:role/TestRole',
})
)
assert.strictEqual(response, mockResponse)
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@
"@aws-sdk/types": "^3.13.1",
"@aws/chat-client": "^0.1.4",
"@aws/chat-client-ui-types": "^0.1.53",
"@aws/language-server-runtimes": "^0.2.111",
"@aws/language-server-runtimes-types": "^0.1.47",
"@aws/language-server-runtimes": "^0.2.120",
"@aws/language-server-runtimes-types": "^0.1.52",
"@cspotcode/source-map-support": "^0.8.1",
"@sinonjs/fake-timers": "^10.0.2",
"@types/adm-zip": "^0.4.34",
Expand Down
Loading
Loading