-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
@aws-cdk/integ-testsbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2
Description
Describe the bug
When adding an assertion to a httpApiCall, the CDK generates an invalid logical ID for its CfnOutput
Expected Behavior
The generated CfnOutput should have a valid logical ID
Current Behavior
The URL used to override the CfnOutput logical ID is not sluggified:
| new CfnOutput(node, 'AssertionResults', { | |
| value: result, | |
| }).overrideLogicalId(`AssertionResults${id}`); |
Reproduction Steps
Raised by Tobias Vollmer on https://cdk.dev/:
import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha';
import { App, Stack } from 'aws-cdk-lib';
const app = new App();
const testStack = new Stack(app, 'integTestStack', {});
const integ = new IntegTest(app, 'BaseIntegrationTest', {
testCases: [testStack], regions: ['eu-central-1'] });
integ.assertions.httpApiCall(
'https://httpbin.org/get',
{}
).expect(
ExpectedResult.objectLike({
status: 200,
})
);$ npx integ-runner --directory ./test-integ-tests --parallel-regions eu-central-1 --force
Deployment failed: Error [ValidationError]: Template format error: Outputs name 'AssertionResultsHttpApiCallhttpbin.org/get0f06632dfa7261b35a1569da58f981ba' is non alphanumeric.I confirmed this by adding this unit test to deploy-assert.test.ts:
test.only('expect creates a valid CfnOutput', () => {
// GIVEN
const app = new App();
const deplossert = new DeployAssert(app);
// WHEN
const query = deplossert.httpApiCall('https://example.com/test/123');
query.expect(ExpectedResult.objectLike({ status: 200 }));
// THEN
Template.fromStack(deplossert.scope).hasOutput(
'AssertionResultsHttpApiCallexample.com/test/1235ffa3a1b41e83da401e71706d1d9bc9a',
{
Value: {
'Fn::GetAtt': ['HttpApiCallexamplecomtest1235ffa3a1b41e83da401e71706d1d9bc9a', 'assertion'],
},
},
);
});Possible Solution
Slugify the URL before appending it to the logical ID
Additional Information/Context
No response
CDK CLI Version
2.135.0
Framework Version
No response
Node.js Version
v20.11.1
OS
macOS 14.4.1
Language
TypeScript
Language Version
5.4.3
Other information
I'll open a PR to fix this shortly. I'll also check to make sure that invokeFunction and awsApiCall do not run into the same issue, and have tests to check it
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/integ-testsbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2