Skip to content

Commit

Permalink
chore(release): v2.173.2 (#32557)
Browse files Browse the repository at this point in the history
See CHANGELOG
  • Loading branch information
mergify[bot] authored Dec 17, 2024
2 parents 4eac959 + 522334f commit f8e6207
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.v2.alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.173.2-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.1-alpha.0...v2.173.2-alpha.0) (2024-12-17)

## [2.173.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.173.0-alpha.0...v2.173.1-alpha.0) (2024-12-14)

## [2.173.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.172.0-alpha.0...v2.173.0-alpha.0) (2024-12-11)
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.173.2](https://github.com/aws/aws-cdk/compare/v2.173.1...v2.173.2) (2024-12-17)


### Bug Fixes

* **cli:** allow credential plugins to return `null` for `expiration` ([#32554](https://github.com/aws/aws-cdk/issues/32554)) ([e59b1db](https://github.com/aws/aws-cdk/commit/e59b1db4d8da5fc11d0e3beeb136593440100325))
* **cli:** doesn't support plugins that return initially empty credentials ([#32552](https://github.com/aws/aws-cdk/issues/32552)) ([7ee9b90](https://github.com/aws/aws-cdk/commit/7ee9b909695aca317a11aad16ca983dcc6d6f85a))

## [2.173.1](https://github.com/aws/aws-cdk/compare/v2.173.0...v2.173.1) (2024-12-14)


Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/aws-auth/credential-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function isV3Provider(x: PluginProviderResult): x is SDKv3CompatibleCredentialPr
}

function isV2Credentials(x: PluginProviderResult): x is SDKv2CompatibleCredentials {
return !!(x && typeof x === 'object' && x.accessKeyId && (x as SDKv2CompatibleCredentials).getPromise);
return !!(x && typeof x === 'object' && (x as SDKv2CompatibleCredentials).getPromise);
}

function isV3Credentials(x: PluginProviderResult): x is SDKv3CompatibleCredentials {
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/aws-auth/provider-caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ export function makeCachingProvider(provider: AwsCredentialIdentityProvider): Aw

export function credentialsAboutToExpire(token: AwsCredentialIdentity) {
const expiryMarginSecs = 5;
return token.expiration !== undefined && token.expiration.getTime() - Date.now() < expiryMarginSecs * 1000;
return !!token.expiration && token.expiration.getTime() - Date.now() < expiryMarginSecs * 1000;
}
30 changes: 30 additions & 0 deletions packages/aws-cdk/test/api/plugin/credential-plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CredentialPlugins } from '../../../lib/api/aws-auth/credential-plugins';
import { credentialsAboutToExpire } from '../../../lib/api/aws-auth/provider-caching';
import { CredentialProviderSource, Mode, SDKv3CompatibleCredentials } from '../../../lib/api/plugin/credential-provider-source';
import { PluginHost, markTesting } from '../../../lib/api/plugin/plugin';

Expand Down Expand Up @@ -104,6 +105,26 @@ test('plugin can return V2 compatible credential-provider', async () => {
expect(getPromise).toHaveBeenCalled();
});

test('plugin can return V2 compatible credential-provider with initially empty keys', async () => {
// GIVEN
mockCredentialFunction(() => Promise.resolve({
accessKeyId: '',
secretAccessKey: '',
expired: false,
getPromise() {
this.accessKeyId = 'keyid';
return Promise.resolve({});
},
}));

// WHEN
const creds = await fetchNow();

await expect(creds).toEqual(expect.objectContaining({
accessKeyId: 'keyid',
}));
});

test('plugin must not return something that is not a credential', async () => {
// GIVEN
mockCredentialFunction(() => Promise.resolve({
Expand All @@ -114,6 +135,15 @@ test('plugin must not return something that is not a credential', async () => {
await expect(fetchNow()).rejects.toThrow(/Plugin returned a value that/);
});

test('token expiration is allowed to be null', () => {
expect(credentialsAboutToExpire({
accessKeyId: 'key',
secretAccessKey: 'secret',
// This is not allowed according to the `.d.ts` contract, but it can happen in reality
expiration: null as any,
})).toEqual(false);
});

function mockCredentialFunction(p: CredentialProviderSource['getProvider']) {
mockCredentialPlugin({
name: 'test',
Expand Down
4 changes: 2 additions & 2 deletions version.v2.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.173.1",
"alphaVersion": "2.173.1-alpha.0"
"version": "2.173.2",
"alphaVersion": "2.173.2-alpha.0"
}

0 comments on commit f8e6207

Please sign in to comment.