Skip to content

Commit 7ee9b90

Browse files
rix0rrrHBobertz
authored andcommitted
fix(cli): doesn't support plugins that return initially empty credentials (#32552)
Plugins that return V2 credentials objects, return credentials that are self-refreshing. Those credentials can start out empty, which is perfectly valid. We shouldn't reject them if they are. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 4eac959 commit 7ee9b90

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/aws-cdk/lib/api/aws-auth/credential-plugins.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function isV3Provider(x: PluginProviderResult): x is SDKv3CompatibleCredentialPr
165165
}
166166

167167
function isV2Credentials(x: PluginProviderResult): x is SDKv2CompatibleCredentials {
168-
return !!(x && typeof x === 'object' && x.accessKeyId && (x as SDKv2CompatibleCredentials).getPromise);
168+
return !!(x && typeof x === 'object' && (x as SDKv2CompatibleCredentials).getPromise);
169169
}
170170

171171
function isV3Credentials(x: PluginProviderResult): x is SDKv3CompatibleCredentials {

packages/aws-cdk/test/api/plugin/credential-plugin.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ test('plugin can return V2 compatible credential-provider', async () => {
104104
expect(getPromise).toHaveBeenCalled();
105105
});
106106

107+
test('plugin can return V2 compatible credential-provider with initially empty keys', async () => {
108+
// GIVEN
109+
mockCredentialFunction(() => Promise.resolve({
110+
accessKeyId: '',
111+
secretAccessKey: '',
112+
expired: false,
113+
getPromise() {
114+
this.accessKeyId = 'keyid';
115+
return Promise.resolve({});
116+
},
117+
}));
118+
119+
// WHEN
120+
const creds = await fetchNow();
121+
122+
await expect(creds).toEqual(expect.objectContaining({
123+
accessKeyId: 'keyid',
124+
}));
125+
});
126+
107127
test('plugin must not return something that is not a credential', async () => {
108128
// GIVEN
109129
mockCredentialFunction(() => Promise.resolve({

0 commit comments

Comments
 (0)