Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Dec 24, 2024
1 parent 6d2c547 commit b919b96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
29 changes: 15 additions & 14 deletions packages/@aws-cdk/cli-plugin-contract/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,22 @@ export interface SDKv2CompatibleCredentials {
* AWS access key ID.
*/
accessKeyId: string;

/**
* Whether the credentials have been expired and require a refresh.
* Used in conjunction with expireTime.
*/
expired: boolean;
/**
* Time when credentials should be considered expired.
* Used in conjunction with expired.
*/
expireTime: Date;
* Time when credentials should be considered expired.
* Used in conjunction with expired.
*/
expireTime?: Date | null;

/**
* AWS secret access key.
*/
* AWS secret access key.
*/
secretAccessKey: string;

/**
* AWS session token.
*/
sessionToken: string;
* AWS session token.
*/
sessionToken?: string;

/**
* Gets the existing credentials, refreshing them if necessary, and returns
Expand Down Expand Up @@ -205,15 +203,18 @@ export interface SDKv3CompatibleCredentials {
* AWS access key ID
*/
readonly accessKeyId: string;

/**
* AWS secret access key
*/
readonly secretAccessKey: string;

/**
* A security or session token to use with these credentials. Usually
* present for temporary credentials.
*/
readonly sessionToken?: string;

/**
* A `Date` when the identity or credential will no longer be accepted.
*/
Expand Down
12 changes: 6 additions & 6 deletions packages/aws-cdk/test/api/credential-plugins.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PluginProviderResult } from '@aws-cdk/cli-plugin-contract';
import type { PluginProviderResult, SDKv2CompatibleCredentials } from '@aws-cdk/cli-plugin-contract';
import { CredentialPlugins } from '../../lib/api/aws-auth/credential-plugins';
import { PluginHost } from '../../lib/api/plugin';
import { Mode } from '../../lib/api/plugin/mode';
Expand All @@ -9,7 +9,7 @@ test('returns credential from plugin', async () => {
accessKeyId: 'aaa',
secretAccessKey: 'bbb',
getPromise: () => Promise.resolve(),
};
} satisfies SDKv2CompatibleCredentials;
const host = PluginHost.instance;

host.registerCredentialProviderSource({
Expand All @@ -34,8 +34,8 @@ test('returns credential from plugin', async () => {
const pluginCredentials = await plugins.fetchCredentialsFor('aaa', Mode.ForReading);

// THEN
expect(pluginCredentials).toEqual({
credentials: creds,
pluginName: 'Fake',
});
await expect(pluginCredentials?.credentials()).resolves.toEqual(expect.objectContaining({
accessKeyId: 'aaa',
secretAccessKey: 'bbb',
}));
});

0 comments on commit b919b96

Please sign in to comment.