-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): asset uploads fail if Object Lock is enabled on access buck…
…et (#31937) Object Lock requires passing an object checksum. By default, SDKv2 only calculates MD5 checksums. We used to turn off checksums altogether and rely on SigV4 checksums to produce a workable setup for both FIPS and non-FIPS users, but in case of Object Lock this doesn't work: we must definitely have an S3 content checksum, and the the SigV4 checksum alone is not good enough. Since SDKv2 only supports MD5 checksums, we now only disable checksums for FIPS environments. The unfortunate result is that Object Lock will not work in a FIPS environment, but there's no way around that for now. When we migrate to SDKv3, which can be configured to checksum using SHA256, Object Lock + FIPS will work again. Relates to #31926 (This PR also adds tests for the PluginHost because otherwise the build fails due to coverage requirements) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
8 changed files
with
171 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { ContextProviderPlugin } from '../../../lib/api/plugin/context-provider-plugin'; | ||
import { CredentialProviderSource } from '../../../lib/api/plugin/credential-provider-source'; | ||
import { PluginHost, markTesting } from '../../../lib/api/plugin/plugin'; | ||
|
||
markTesting(); | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
}); | ||
|
||
const THE_PLUGIN = 'the-plugin'; | ||
|
||
test('load a plugin using the PluginHost', () => { | ||
const host = new PluginHost(); | ||
|
||
jest.mock(THE_PLUGIN, () => { | ||
return { | ||
version: '1', | ||
init() { | ||
}, | ||
}; | ||
}, { virtual: true }); | ||
|
||
host.load(THE_PLUGIN); | ||
}); | ||
|
||
test('fail to load a plugin using the PluginHost', () => { | ||
const host = new PluginHost(); | ||
|
||
// This is not a plugin | ||
jest.mock(THE_PLUGIN, () => { | ||
return {}; | ||
}, { virtual: true }); | ||
|
||
expect(() => host.load(THE_PLUGIN)).toThrow(/Unable to load plug-in/); | ||
}); | ||
|
||
test('plugin that registers a Credential Provider', () => { | ||
const host = new PluginHost(); | ||
|
||
jest.mock(THE_PLUGIN, () => { | ||
return { | ||
version: '1', | ||
init(h: PluginHost) { | ||
h.registerCredentialProviderSource({ | ||
canProvideCredentials() { return Promise.resolve(false); }, | ||
name: 'test', | ||
isAvailable() { return Promise.resolve(false); }, | ||
getProvider() { return Promise.reject('Dont call me'); }, | ||
} satisfies CredentialProviderSource); | ||
|
||
}, | ||
}; | ||
}, { virtual: true }); | ||
|
||
host.load(THE_PLUGIN); | ||
|
||
expect(host.credentialProviderSources).toHaveLength(1); | ||
}); | ||
|
||
test('plugin that registers a Context Provider', () => { | ||
const host = new PluginHost(); | ||
|
||
jest.mock(THE_PLUGIN, () => { | ||
return { | ||
version: '1', | ||
init(h: PluginHost) { | ||
h.registerContextProviderAlpha('name', { | ||
getValue(_args: Record<string, any>) { | ||
return Promise.resolve('asdf'); | ||
}, | ||
} satisfies ContextProviderPlugin); | ||
}, | ||
}; | ||
}, { virtual: true }); | ||
|
||
host.load(THE_PLUGIN); | ||
|
||
expect(Object.keys(host.contextProviderPlugins)).toHaveLength(1); | ||
}); | ||
|
||
test('plugin that registers an invalid Context Provider throws', () => { | ||
const host = new PluginHost(); | ||
|
||
jest.mock(THE_PLUGIN, () => { | ||
return { | ||
version: '1', | ||
init(h: PluginHost) { | ||
h.registerContextProviderAlpha('name', {} as any); | ||
}, | ||
}; | ||
}, { virtual: true }); | ||
|
||
expect(() => host.load(THE_PLUGIN)).toThrow(/does not look like a ContextProviderPlugin/); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,10 +79,10 @@ | |
jsonschema "^1.4.1" | ||
semver "^7.6.3" | ||
|
||
"@aws-cdk/cx-api@^2.163.1": | ||
version "2.163.1" | ||
resolved "https://registry.npmjs.org/@aws-cdk/cx-api/-/cx-api-2.163.1.tgz#ef55da9f471c963d877b23d3201ca4560d656b2e" | ||
integrity sha512-0bVL/pX0UcliCdXVcgtLVL3W5EHAp4RgW7JN3prz1dIOmLZzZ30DW0qWSc0D0EVE3rVG6RVgfIiuFBFK6WFZ+w== | ||
"@aws-cdk/cx-api@^2.164.1": | ||
version "2.164.1" | ||
resolved "https://registry.npmjs.org/@aws-cdk/cx-api/-/cx-api-2.164.1.tgz#dce8eaede6b9ec95c4a69f7acbe486b499c32516" | ||
integrity sha512-VwYDcI8b5KYS2VptkIAm75yK1SwLAClFnlyH0Ea5dI3YJrIYtvxW930nhppxmwPihbMJa4Z0sxic7EBTt4ZaBQ== | ||
dependencies: | ||
semver "^7.6.3" | ||
|
||
|
@@ -6646,13 +6646,13 @@ [email protected], case@^1.6.3: | |
resolved "https://registry.npmjs.org/case/-/case-1.6.3.tgz#0a4386e3e9825351ca2e6216c60467ff5f1ea1c9" | ||
integrity sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ== | ||
|
||
cdk-assets@^2.155.17: | ||
version "2.155.17" | ||
resolved "https://registry.npmjs.org/cdk-assets/-/cdk-assets-2.155.17.tgz#d6c285d0279aec8226b45577a151e6dd32a12fa5" | ||
integrity sha512-+hJlYYlsPHhPCeMC/V3pMyrjz5K8p9SQdC50qMg6a8/w/3w0WY1ZixyKGtpJfFB11C3Ubb04l2miieaAH00CIA== | ||
cdk-assets@^2.155.20: | ||
version "2.155.20" | ||
resolved "https://registry.npmjs.org/cdk-assets/-/cdk-assets-2.155.20.tgz#a7a380f820001d2087d0dce802eac4c71a688100" | ||
integrity sha512-NXU7RCJsPecQbRVkQ6iPyOV3jDEojENaxWs9956pYddY5Pq0onSibXItivavQC74i0YZdyWDdlH6RcLPzFQhPQ== | ||
dependencies: | ||
"@aws-cdk/cloud-assembly-schema" "^38.0.1" | ||
"@aws-cdk/cx-api" "^2.163.1" | ||
"@aws-cdk/cx-api" "^2.164.1" | ||
archiver "^5.3.2" | ||
aws-sdk "^2.1691.0" | ||
glob "^7.2.3" | ||
|