-
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.
chore: update cli integ tests to use sdk v3 (#31226)
### Checklist - [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
39492e9
commit 2a27711
Showing
8 changed files
with
1,965 additions
and
522 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
277 changes: 191 additions & 86 deletions
277
packages/@aws-cdk-testing/cli-integ/lib/staging/codeartifact.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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
131 changes: 78 additions & 53 deletions
131
packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli-lib.integtest.ts
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 |
---|---|---|
@@ -1,65 +1,90 @@ | ||
import { DescribeStackResourcesCommand, DescribeStacksCommand } from '@aws-sdk/client-cloudformation'; | ||
import { integTest, withCliLibFixture } from '../../lib'; | ||
|
||
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime | ||
|
||
integTest('cli-lib synth', withCliLibFixture(async (fixture) => { | ||
await fixture.cdk(['synth', fixture.fullStackName('simple-1')]); | ||
expect(fixture.template('simple-1')).toEqual(expect.objectContaining({ | ||
// Checking for a small subset is enough as proof that synth worked | ||
Resources: expect.objectContaining({ | ||
queue276F7297: expect.objectContaining({ | ||
Type: 'AWS::SQS::Queue', | ||
Properties: { | ||
VisibilityTimeout: 300, | ||
}, | ||
Metadata: { | ||
'aws:cdk:path': `${fixture.stackNamePrefix}-simple-1/queue/Resource`, | ||
}, | ||
integTest( | ||
'cli-lib synth', | ||
withCliLibFixture(async (fixture) => { | ||
await fixture.cdk(['synth', fixture.fullStackName('simple-1')]); | ||
expect(fixture.template('simple-1')).toEqual( | ||
expect.objectContaining({ | ||
// Checking for a small subset is enough as proof that synth worked | ||
Resources: expect.objectContaining({ | ||
queue276F7297: expect.objectContaining({ | ||
Type: 'AWS::SQS::Queue', | ||
Properties: { | ||
VisibilityTimeout: 300, | ||
}, | ||
Metadata: { | ||
'aws:cdk:path': `${fixture.stackNamePrefix}-simple-1/queue/Resource`, | ||
}, | ||
}), | ||
}), | ||
}), | ||
}), | ||
})); | ||
})); | ||
); | ||
}), | ||
); | ||
|
||
integTest('cli-lib list', withCliLibFixture(async (fixture) => { | ||
const listing = await fixture.cdk(['list'], { captureStderr: false }); | ||
expect(listing).toContain(fixture.fullStackName('simple-1')); | ||
})); | ||
integTest( | ||
'cli-lib list', | ||
withCliLibFixture(async (fixture) => { | ||
const listing = await fixture.cdk(['list'], { captureStderr: false }); | ||
expect(listing).toContain(fixture.fullStackName('simple-1')); | ||
}), | ||
); | ||
|
||
integTest('cli-lib deploy', withCliLibFixture(async (fixture) => { | ||
const stackName = fixture.fullStackName('simple-1'); | ||
integTest( | ||
'cli-lib deploy', | ||
withCliLibFixture(async (fixture) => { | ||
const stackName = fixture.fullStackName('simple-1'); | ||
|
||
try { | ||
// deploy the stack | ||
await fixture.cdk(['deploy', stackName], { | ||
neverRequireApproval: true, | ||
}); | ||
try { | ||
// deploy the stack | ||
await fixture.cdk(['deploy', stackName], { | ||
neverRequireApproval: true, | ||
}); | ||
|
||
// verify the number of resources in the stack | ||
const expectedStack = await fixture.aws.cloudFormation('describeStackResources', { | ||
StackName: stackName, | ||
}); | ||
expect(expectedStack.StackResources?.length).toEqual(3); | ||
} finally { | ||
// delete the stack | ||
await fixture.cdk(['destroy', stackName], { | ||
captureStderr: false, | ||
}); | ||
} | ||
})); | ||
// verify the number of resources in the stack | ||
const expectedStack = await fixture.aws.cloudFormation.send( | ||
new DescribeStackResourcesCommand({ | ||
StackName: stackName, | ||
}), | ||
); | ||
expect(expectedStack.StackResources?.length).toEqual(3); | ||
} finally { | ||
// delete the stack | ||
await fixture.cdk(['destroy', stackName], { | ||
captureStderr: false, | ||
}); | ||
} | ||
}), | ||
); | ||
|
||
integTest('security related changes without a CLI are expected to fail when approval is required', withCliLibFixture(async (fixture) => { | ||
const stdErr = await fixture.cdk(['deploy', fixture.fullStackName('simple-1')], { | ||
onlyStderr: true, | ||
captureStderr: true, | ||
allowErrExit: true, | ||
neverRequireApproval: false, | ||
}); | ||
integTest( | ||
'security related changes without a CLI are expected to fail when approval is required', | ||
withCliLibFixture(async (fixture) => { | ||
const stdErr = await fixture.cdk(['deploy', fixture.fullStackName('simple-1')], { | ||
onlyStderr: true, | ||
captureStderr: true, | ||
allowErrExit: true, | ||
neverRequireApproval: false, | ||
}); | ||
|
||
expect(stdErr).toContain('This deployment will make potentially sensitive changes according to your current security approval level'); | ||
expect(stdErr).toContain('Deployment failed: Error: \"--require-approval\" is enabled and stack includes security-sensitive updates'); | ||
expect(stdErr).toContain( | ||
'This deployment will make potentially sensitive changes according to your current security approval level', | ||
); | ||
expect(stdErr).toContain( | ||
'Deployment failed: Error: "--require-approval" is enabled and stack includes security-sensitive updates', | ||
); | ||
|
||
// Ensure stack was not deployed | ||
await expect(fixture.aws.cloudFormation('describeStacks', { | ||
StackName: fixture.fullStackName('simple-1'), | ||
})).rejects.toThrow('does not exist'); | ||
})); | ||
// Ensure stack was not deployed | ||
await expect( | ||
fixture.aws.cloudFormation.send( | ||
new DescribeStacksCommand({ | ||
StackName: fixture.fullStackName('simple-1'), | ||
}), | ||
), | ||
).rejects.toThrow('does not exist'); | ||
}), | ||
); |
Oops, something went wrong.