diff --git a/packages/@aws-cdk/integ-tests-alpha/lib/assertions/common.ts b/packages/@aws-cdk/integ-tests-alpha/lib/assertions/common.ts index 57eba2d41e52c..65e335076311c 100644 --- a/packages/@aws-cdk/integ-tests-alpha/lib/assertions/common.ts +++ b/packages/@aws-cdk/integ-tests-alpha/lib/assertions/common.ts @@ -55,6 +55,8 @@ export abstract class ExpectedResult { * ExpectedResult.exact({ * stringParam: 'hello', * }); + * + * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-exactpattern */ public static exact(expected: any): ExpectedResult { return { @@ -74,11 +76,15 @@ export abstract class ExpectedResult { * stringParam: 'hello', * numberParam: 3, * booleanParam: true, + * objectParam: { prop1: 'value', prop2: 'value' }, * }; * // pass * ExpectedResult.objectLike({ * stringParam: 'hello', + * objectParam: { prop1: 'value' }, * }); + * + * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-objectwbrlikepattern */ public static objectLike(expected: { [key: string]: any }): ExpectedResult { return { @@ -108,6 +114,8 @@ export abstract class ExpectedResult { * stringParam: 'hello', * }, * ]); + * + * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-arraywbrwithpattern */ public static arrayWith(expected: any[]): ExpectedResult { return { @@ -126,6 +134,8 @@ export abstract class ExpectedResult { * * // pass * ExpectedResult.stringLikeRegexp('value'); + * + * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-stringwbrlikewbrregexppattern */ public static stringLikeRegexp(expected: string): ExpectedResult { return { diff --git a/packages/@aws-cdk/integ-tests-alpha/lib/assertions/http-call.ts b/packages/@aws-cdk/integ-tests-alpha/lib/assertions/http-call.ts index 41e3bdf0e2a88..473131ecbbe4c 100644 --- a/packages/@aws-cdk/integ-tests-alpha/lib/assertions/http-call.ts +++ b/packages/@aws-cdk/integ-tests-alpha/lib/assertions/http-call.ts @@ -47,7 +47,7 @@ export class HttpApiCall extends ApiCallBase { new CfnOutput(node, 'AssertionResults', { value: result, - }).overrideLogicalId(`AssertionResults${id}`); + }).overrideLogicalId(`AssertionResults${id.replace(/[\W_]+/g, '')}`); } } }, diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/deploy-assert.test.ts b/packages/@aws-cdk/integ-tests-alpha/test/assertions/deploy-assert.test.ts index b31e8328fe465..5f6bbf064b2f2 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/deploy-assert.test.ts +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/deploy-assert.test.ts @@ -268,6 +268,27 @@ describe('DeployAssert', () => { })); }); + test('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?param=value¶m2#hash'); + query.expect(ExpectedResult.objectLike({ status: 200 })); + + // THEN + Template.fromStack(deplossert.scope).hasOutput( + // Output name should only contain alphanumeric characters + 'AssertionResultsHttpApiCallexamplecomtest1237c0018be9f253e38cad30092c2fa2a91', + { + Value: { + 'Fn::GetAtt': ['HttpApiCallexamplecomtest1237c0018be9f253e38cad30092c2fa2a91', 'assertion'], + }, + }, + ); + }); + test('multiple calls can be configured', () => { // GIVEN const app = new App(); diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.assets.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.assets.json new file mode 100644 index 0000000000000..29cf2a5a8e87c --- /dev/null +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.assets.json @@ -0,0 +1,32 @@ +{ + "version": "36.0.0", + "files": { + "980ab41b674bbe2a714081b8b83c3b7bc45c4f8bb52a347bc93fc308857eadec": { + "source": { + "path": "asset.980ab41b674bbe2a714081b8b83c3b7bc45c4f8bb52a347bc93fc308857eadec.bundle", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "980ab41b674bbe2a714081b8b83c3b7bc45c4f8bb52a347bc93fc308857eadec.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "50a9f7f8eefab0b355a2ce03bbac0a10a5daafbdf65cdc3a014650815ee0731f": { + "source": { + "path": "AssertionsTestDefaultTestDeployAssertDC0672BB.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "50a9f7f8eefab0b355a2ce03bbac0a10a5daafbdf65cdc3a014650815ee0731f.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.template.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.template.json new file mode 100644 index 0000000000000..34e9431d887c2 --- /dev/null +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.template.json @@ -0,0 +1,309 @@ +{ + "Resources": { + "HttpApiCall5f7069701a458c2283dbb422b313fd3a": { + "Type": "Custom::DeployAssert@HttpCall", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "parameters": { + "url": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::ImportValue": "InvokeFunctionAssertions:ExportsOutputRefHttpApiF5A9A8A7F70B5BDD" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".", + { + "Ref": "AWS::URLSuffix" + }, + "/dev/get" + ] + ] + } + }, + "expected": "{\"$ObjectLike\":{\"status\":200,\"ok\":true,\"body\":\"Hello!\"}}", + "salt": "1712425490127" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ] + }, + "ManagedPolicyArns": [ + { + "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + } + ] + } + }, + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Runtime": "nodejs18.x", + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "980ab41b674bbe2a714081b8b83c3b7bc45c4f8bb52a347bc93fc308857eadec.zip" + }, + "Timeout": 120, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73", + "Arn" + ] + } + } + }, + "HttpApiCall1219698b15310d985020a947d89e593e": { + "Type": "Custom::DeployAssert@HttpCall", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "parameters": { + "url": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::ImportValue": "InvokeFunctionAssertions:ExportsOutputRefHttpApiF5A9A8A7F70B5BDD" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".", + { + "Ref": "AWS::URLSuffix" + }, + "/dev/post" + ] + ] + }, + "fetchOptions": { + "method": "POST", + "body": "{\"key\":\"value\"}", + "headers": { + "Content-Type": "application/json" + } + } + }, + "expected": "{\"$ObjectLike\":{\"status\":200,\"ok\":true,\"body\":\"Received body: {\\\"key\\\":\\\"value\\\"}\"}}", + "salt": "1712425490128" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "HttpApiCallf16d32bb38fdf952b8530f86260d5337": { + "Type": "Custom::DeployAssert@HttpCall", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "parameters": { + "url": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::ImportValue": "InvokeFunctionAssertions:ExportsOutputRefHttpApiF5A9A8A7F70B5BDD" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".", + { + "Ref": "AWS::URLSuffix" + }, + "/dev/status/403" + ] + ] + } + }, + "expected": "{\"$ObjectLike\":{\"status\":403,\"ok\":false}}", + "salt": "1712425490128" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "HttpApiCallhttpbinorggetcd942067e1d112f86d205b2008dcab31": { + "Type": "Custom::DeployAssert@HttpCallhttpbinorgget", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "parameters": { + "url": "https://httpbin.org/get?key=value#hash" + }, + "expected": "{\"$ObjectLike\":{\"status\":200,\"ok\":true,\"body\":{\"url\":\"https://httpbin.org/get?key=value\",\"args\":{\"key\":\"value\"}}}}", + "salt": "1712425490129" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "HttpApiCallhttpbinorgpost57c1eb9b16e045b0fe0eadcc8fcfe86f": { + "Type": "Custom::DeployAssert@HttpCallhttpbinorgpost", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "parameters": { + "url": "https://httpbin.org/post", + "fetchOptions": { + "method": "POST", + "body": "{\"key\":\"value\"}", + "headers": { + "Content-Type": "application/json" + } + } + }, + "expected": "{\"$ObjectLike\":{\"status\":200,\"ok\":true,\"body\":{\"url\":\"https://httpbin.org/post\",\"json\":{\"key\":\"value\"}}}}", + "salt": "1712425490129" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "HttpApiCallhttpbinorgstatus403241ddf94e19f31ae5405653ddcc7ea8b": { + "Type": "Custom::DeployAssert@HttpCallhttpbinorgstatus403", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "parameters": { + "url": "https://httpbin.org/status/403" + }, + "expected": "{\"$ObjectLike\":{\"status\":403,\"ok\":false}}", + "salt": "1712425490129" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + } + }, + "Outputs": { + "AssertionResultsHttpApiCall5f7069701a458c2283dbb422b313fd3a": { + "Value": { + "Fn::GetAtt": [ + "HttpApiCall5f7069701a458c2283dbb422b313fd3a", + "assertion" + ] + } + }, + "AssertionResultsHttpApiCall1219698b15310d985020a947d89e593e": { + "Value": { + "Fn::GetAtt": [ + "HttpApiCall1219698b15310d985020a947d89e593e", + "assertion" + ] + } + }, + "AssertionResultsHttpApiCallf16d32bb38fdf952b8530f86260d5337": { + "Value": { + "Fn::GetAtt": [ + "HttpApiCallf16d32bb38fdf952b8530f86260d5337", + "assertion" + ] + } + }, + "AssertionResultsHttpApiCallhttpbinorggetcd942067e1d112f86d205b2008dcab31": { + "Value": { + "Fn::GetAtt": [ + "HttpApiCallhttpbinorggetcd942067e1d112f86d205b2008dcab31", + "assertion" + ] + } + }, + "AssertionResultsHttpApiCallhttpbinorgpost57c1eb9b16e045b0fe0eadcc8fcfe86f": { + "Value": { + "Fn::GetAtt": [ + "HttpApiCallhttpbinorgpost57c1eb9b16e045b0fe0eadcc8fcfe86f", + "assertion" + ] + } + }, + "AssertionResultsHttpApiCallhttpbinorgstatus403241ddf94e19f31ae5405653ddcc7ea8b": { + "Value": { + "Fn::GetAtt": [ + "HttpApiCallhttpbinorgstatus403241ddf94e19f31ae5405653ddcc7ea8b", + "assertion" + ] + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/InvokeFunctionAssertions.assets.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/InvokeFunctionAssertions.assets.json new file mode 100644 index 0000000000000..73a3712774d33 --- /dev/null +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/InvokeFunctionAssertions.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "36e80ce5dbc492c642dac9ca0257e10d8e34c3caf3f30260ac762e52e4b238c2": { + "source": { + "path": "InvokeFunctionAssertions.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "36e80ce5dbc492c642dac9ca0257e10d8e34c3caf3f30260ac762e52e4b238c2.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/InvokeFunctionAssertions.template.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/InvokeFunctionAssertions.template.json new file mode 100644 index 0000000000000..89a8bcc468530 --- /dev/null +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/InvokeFunctionAssertions.template.json @@ -0,0 +1,447 @@ +{ + "Resources": { + "HttpApiF5A9A8A7": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Name": "HttpApi", + "ProtocolType": "HTTP" + } + }, + "HttpApiDefaultStage3EEB07D6": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "AutoDeploy": true, + "StageName": "$default" + } + }, + "HttpApiGETgetGetIntegration0F6699AF": { + "Type": "AWS::ApiGatewayV2::Integration", + "Properties": { + "ApiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "IntegrationType": "AWS_PROXY", + "IntegrationUri": { + "Fn::GetAtt": [ + "GetHandlerEF5E42BB", + "Arn" + ] + }, + "PayloadFormatVersion": "2.0" + } + }, + "HttpApiGETgetGetIntegrationPermissionEF8D4F02": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Fn::GetAtt": [ + "GetHandlerEF5E42BB", + "Arn" + ] + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "HttpApiF5A9A8A7" + }, + "/*/*/get" + ] + ] + } + } + }, + "HttpApiGETget6DC8518D": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "AuthorizationType": "NONE", + "RouteKey": "GET /get", + "Target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "HttpApiGETgetGetIntegration0F6699AF" + } + ] + ] + } + } + }, + "HttpApiPOSTpostPostIntegration717DC0BB": { + "Type": "AWS::ApiGatewayV2::Integration", + "Properties": { + "ApiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "IntegrationType": "AWS_PROXY", + "IntegrationUri": { + "Fn::GetAtt": [ + "PostHandler0D20EBFB", + "Arn" + ] + }, + "PayloadFormatVersion": "2.0" + } + }, + "HttpApiPOSTpostPostIntegrationPermission1B542DB2": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Fn::GetAtt": [ + "PostHandler0D20EBFB", + "Arn" + ] + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "HttpApiF5A9A8A7" + }, + "/*/*/post" + ] + ] + } + } + }, + "HttpApiPOSTpost791E2291": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "AuthorizationType": "NONE", + "RouteKey": "POST /post", + "Target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "HttpApiPOSTpostPostIntegration717DC0BB" + } + ] + ] + } + } + }, + "HttpApiGETstatus403ForbiddenIntegrationAF458604": { + "Type": "AWS::ApiGatewayV2::Integration", + "Properties": { + "ApiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "IntegrationType": "AWS_PROXY", + "IntegrationUri": { + "Fn::GetAtt": [ + "ForbiddenHandler630D1ED1", + "Arn" + ] + }, + "PayloadFormatVersion": "2.0" + } + }, + "HttpApiGETstatus403ForbiddenIntegrationPermissionE26C308F": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Fn::GetAtt": [ + "ForbiddenHandler630D1ED1", + "Arn" + ] + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "HttpApiF5A9A8A7" + }, + "/*/*/status/403" + ] + ] + } + } + }, + "HttpApiGETstatus403A55D5D16": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "AuthorizationType": "NONE", + "RouteKey": "GET /status/403", + "Target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "HttpApiGETstatus403ForbiddenIntegrationAF458604" + } + ] + ] + } + } + }, + "GetHandlerServiceRole9313FCB8": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "GetHandlerEF5E42BB": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "\n exports.handler = async () => ({\n statusCode: 200,\n body: 'Hello!',\n });" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "GetHandlerServiceRole9313FCB8", + "Arn" + ] + }, + "Runtime": "nodejs20.x" + }, + "DependsOn": [ + "GetHandlerServiceRole9313FCB8" + ] + }, + "PostHandlerServiceRoleA5E1C273": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "PostHandler0D20EBFB": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "\n exports.handler = async ({ body }) => ({\n statusCode: 200,\n body: 'Received body: ' + body,\n });" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "PostHandlerServiceRoleA5E1C273", + "Arn" + ] + }, + "Runtime": "nodejs20.x" + }, + "DependsOn": [ + "PostHandlerServiceRoleA5E1C273" + ] + }, + "ForbiddenHandlerServiceRole993EA274": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "ForbiddenHandler630D1ED1": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "\n exports.handler = async ({ body }) => ({\n statusCode: 403,\n });" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "ForbiddenHandlerServiceRole993EA274", + "Arn" + ] + }, + "Runtime": "nodejs20.x" + }, + "DependsOn": [ + "ForbiddenHandlerServiceRole993EA274" + ] + }, + "Stage0E8C2AF5": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "AutoDeploy": true, + "StageName": "dev" + } + } + }, + "Outputs": { + "ExportsOutputRefHttpApiF5A9A8A7F70B5BDD": { + "Value": { + "Ref": "HttpApiF5A9A8A7" + }, + "Export": { + "Name": "InvokeFunctionAssertions:ExportsOutputRefHttpApiF5A9A8A7F70B5BDD" + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/cdk.out b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/cdk.out new file mode 100644 index 0000000000000..1f0068d32659a --- /dev/null +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"36.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/integ.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/integ.json new file mode 100644 index 0000000000000..59d255ada934a --- /dev/null +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.0", + "testCases": { + "AssertionsTest/DefaultTest": { + "stacks": [ + "InvokeFunctionAssertions" + ], + "assertionStack": "AssertionsTest/DefaultTest/DeployAssert", + "assertionStackName": "AssertionsTestDefaultTestDeployAssertDC0672BB" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/manifest.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/manifest.json new file mode 100644 index 0000000000000..706291c78dadb --- /dev/null +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/manifest.json @@ -0,0 +1,306 @@ +{ + "version": "36.0.0", + "artifacts": { + "InvokeFunctionAssertions.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "InvokeFunctionAssertions.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "InvokeFunctionAssertions": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "InvokeFunctionAssertions.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/36e80ce5dbc492c642dac9ca0257e10d8e34c3caf3f30260ac762e52e4b238c2.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "InvokeFunctionAssertions.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "InvokeFunctionAssertions.assets" + ], + "metadata": { + "/InvokeFunctionAssertions/HttpApi/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiF5A9A8A7" + } + ], + "/InvokeFunctionAssertions/HttpApi/DefaultStage/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiDefaultStage3EEB07D6" + } + ], + "/InvokeFunctionAssertions/HttpApi/GET--get/GetIntegration/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiGETgetGetIntegration0F6699AF" + } + ], + "/InvokeFunctionAssertions/HttpApi/GET--get/GetIntegration-Permission": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiGETgetGetIntegrationPermissionEF8D4F02" + } + ], + "/InvokeFunctionAssertions/HttpApi/GET--get/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiGETget6DC8518D" + } + ], + "/InvokeFunctionAssertions/HttpApi/POST--post/PostIntegration/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiPOSTpostPostIntegration717DC0BB" + } + ], + "/InvokeFunctionAssertions/HttpApi/POST--post/PostIntegration-Permission": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiPOSTpostPostIntegrationPermission1B542DB2" + } + ], + "/InvokeFunctionAssertions/HttpApi/POST--post/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiPOSTpost791E2291" + } + ], + "/InvokeFunctionAssertions/HttpApi/GET--status--403/ForbiddenIntegration/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiGETstatus403ForbiddenIntegrationAF458604" + } + ], + "/InvokeFunctionAssertions/HttpApi/GET--status--403/ForbiddenIntegration-Permission": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiGETstatus403ForbiddenIntegrationPermissionE26C308F" + } + ], + "/InvokeFunctionAssertions/HttpApi/GET--status--403/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiGETstatus403A55D5D16" + } + ], + "/InvokeFunctionAssertions/GetHandler/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "GetHandlerServiceRole9313FCB8" + } + ], + "/InvokeFunctionAssertions/GetHandler/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "GetHandlerEF5E42BB" + } + ], + "/InvokeFunctionAssertions/PostHandler/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "PostHandlerServiceRoleA5E1C273" + } + ], + "/InvokeFunctionAssertions/PostHandler/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "PostHandler0D20EBFB" + } + ], + "/InvokeFunctionAssertions/ForbiddenHandler/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ForbiddenHandlerServiceRole993EA274" + } + ], + "/InvokeFunctionAssertions/ForbiddenHandler/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ForbiddenHandler630D1ED1" + } + ], + "/InvokeFunctionAssertions/Stage/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Stage0E8C2AF5" + } + ], + "/InvokeFunctionAssertions/Exports/Output{\"Ref\":\"HttpApiF5A9A8A7\"}": [ + { + "type": "aws:cdk:logicalId", + "data": "ExportsOutputRefHttpApiF5A9A8A7F70B5BDD" + } + ], + "/InvokeFunctionAssertions/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/InvokeFunctionAssertions/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "InvokeFunctionAssertions" + }, + "AssertionsTestDefaultTestDeployAssertDC0672BB.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "AssertionsTestDefaultTestDeployAssertDC0672BB.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "AssertionsTestDefaultTestDeployAssertDC0672BB": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "AssertionsTestDefaultTestDeployAssertDC0672BB.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/50a9f7f8eefab0b355a2ce03bbac0a10a5daafbdf65cdc3a014650815ee0731f.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "AssertionsTestDefaultTestDeployAssertDC0672BB.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "InvokeFunctionAssertions", + "AssertionsTestDefaultTestDeployAssertDC0672BB.assets" + ], + "metadata": { + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCall5f7069701a458c2283dbb422b313fd3a/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiCall5f7069701a458c2283dbb422b313fd3a" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCall5f7069701a458c2283dbb422b313fd3a/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsHttpApiCall5f7069701a458c2283dbb422b313fd3a" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role": [ + { + "type": "aws:cdk:logicalId", + "data": "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Handler": [ + { + "type": "aws:cdk:logicalId", + "data": "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCall1219698b15310d985020a947d89e593e/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiCall1219698b15310d985020a947d89e593e" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCall1219698b15310d985020a947d89e593e/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsHttpApiCall1219698b15310d985020a947d89e593e" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCallf16d32bb38fdf952b8530f86260d5337/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiCallf16d32bb38fdf952b8530f86260d5337" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCallf16d32bb38fdf952b8530f86260d5337/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsHttpApiCallf16d32bb38fdf952b8530f86260d5337" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiCallhttpbinorggetcd942067e1d112f86d205b2008dcab31" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsHttpApiCallhttpbinorggetcd942067e1d112f86d205b2008dcab31" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiCallhttpbinorgpost57c1eb9b16e045b0fe0eadcc8fcfe86f" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsHttpApiCallhttpbinorgpost57c1eb9b16e045b0fe0eadcc8fcfe86f" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "HttpApiCallhttpbinorgstatus403241ddf94e19f31ae5405653ddcc7ea8b" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsHttpApiCallhttpbinorgstatus403241ddf94e19f31ae5405653ddcc7ea8b" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "AssertionsTest/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/tree.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/tree.json new file mode 100644 index 0000000000000..f0d504dc80660 --- /dev/null +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.js.snapshot/tree.json @@ -0,0 +1,1185 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "InvokeFunctionAssertions": { + "id": "InvokeFunctionAssertions", + "path": "InvokeFunctionAssertions", + "children": { + "HttpApi": { + "id": "HttpApi", + "path": "InvokeFunctionAssertions/HttpApi", + "children": { + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/HttpApi/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGatewayV2::Api", + "aws:cdk:cloudformation:props": { + "name": "HttpApi", + "protocolType": "HTTP" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.CfnApi", + "version": "0.0.0" + } + }, + "DefaultStage": { + "id": "DefaultStage", + "path": "InvokeFunctionAssertions/HttpApi/DefaultStage", + "children": { + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/HttpApi/DefaultStage/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGatewayV2::Stage", + "aws:cdk:cloudformation:props": { + "apiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "autoDeploy": true, + "stageName": "$default" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.CfnStage", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.HttpStage", + "version": "0.0.0" + } + }, + "GET--get": { + "id": "GET--get", + "path": "InvokeFunctionAssertions/HttpApi/GET--get", + "children": { + "GetIntegration": { + "id": "GetIntegration", + "path": "InvokeFunctionAssertions/HttpApi/GET--get/GetIntegration", + "children": { + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/HttpApi/GET--get/GetIntegration/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGatewayV2::Integration", + "aws:cdk:cloudformation:props": { + "apiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "integrationType": "AWS_PROXY", + "integrationUri": { + "Fn::GetAtt": [ + "GetHandlerEF5E42BB", + "Arn" + ] + }, + "payloadFormatVersion": "2.0" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.CfnIntegration", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.HttpIntegration", + "version": "0.0.0" + } + }, + "GetIntegration-Permission": { + "id": "GetIntegration-Permission", + "path": "InvokeFunctionAssertions/HttpApi/GET--get/GetIntegration-Permission", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Permission", + "aws:cdk:cloudformation:props": { + "action": "lambda:InvokeFunction", + "functionName": { + "Fn::GetAtt": [ + "GetHandlerEF5E42BB", + "Arn" + ] + }, + "principal": "apigateway.amazonaws.com", + "sourceArn": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "HttpApiF5A9A8A7" + }, + "/*/*/get" + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnPermission", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/HttpApi/GET--get/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGatewayV2::Route", + "aws:cdk:cloudformation:props": { + "apiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "authorizationType": "NONE", + "routeKey": "GET /get", + "target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "HttpApiGETgetGetIntegration0F6699AF" + } + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.HttpRoute", + "version": "0.0.0" + } + }, + "POST--post": { + "id": "POST--post", + "path": "InvokeFunctionAssertions/HttpApi/POST--post", + "children": { + "PostIntegration": { + "id": "PostIntegration", + "path": "InvokeFunctionAssertions/HttpApi/POST--post/PostIntegration", + "children": { + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/HttpApi/POST--post/PostIntegration/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGatewayV2::Integration", + "aws:cdk:cloudformation:props": { + "apiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "integrationType": "AWS_PROXY", + "integrationUri": { + "Fn::GetAtt": [ + "PostHandler0D20EBFB", + "Arn" + ] + }, + "payloadFormatVersion": "2.0" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.CfnIntegration", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.HttpIntegration", + "version": "0.0.0" + } + }, + "PostIntegration-Permission": { + "id": "PostIntegration-Permission", + "path": "InvokeFunctionAssertions/HttpApi/POST--post/PostIntegration-Permission", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Permission", + "aws:cdk:cloudformation:props": { + "action": "lambda:InvokeFunction", + "functionName": { + "Fn::GetAtt": [ + "PostHandler0D20EBFB", + "Arn" + ] + }, + "principal": "apigateway.amazonaws.com", + "sourceArn": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "HttpApiF5A9A8A7" + }, + "/*/*/post" + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnPermission", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/HttpApi/POST--post/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGatewayV2::Route", + "aws:cdk:cloudformation:props": { + "apiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "authorizationType": "NONE", + "routeKey": "POST /post", + "target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "HttpApiPOSTpostPostIntegration717DC0BB" + } + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.HttpRoute", + "version": "0.0.0" + } + }, + "GET--status--403": { + "id": "GET--status--403", + "path": "InvokeFunctionAssertions/HttpApi/GET--status--403", + "children": { + "ForbiddenIntegration": { + "id": "ForbiddenIntegration", + "path": "InvokeFunctionAssertions/HttpApi/GET--status--403/ForbiddenIntegration", + "children": { + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/HttpApi/GET--status--403/ForbiddenIntegration/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGatewayV2::Integration", + "aws:cdk:cloudformation:props": { + "apiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "integrationType": "AWS_PROXY", + "integrationUri": { + "Fn::GetAtt": [ + "ForbiddenHandler630D1ED1", + "Arn" + ] + }, + "payloadFormatVersion": "2.0" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.CfnIntegration", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.HttpIntegration", + "version": "0.0.0" + } + }, + "ForbiddenIntegration-Permission": { + "id": "ForbiddenIntegration-Permission", + "path": "InvokeFunctionAssertions/HttpApi/GET--status--403/ForbiddenIntegration-Permission", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Permission", + "aws:cdk:cloudformation:props": { + "action": "lambda:InvokeFunction", + "functionName": { + "Fn::GetAtt": [ + "ForbiddenHandler630D1ED1", + "Arn" + ] + }, + "principal": "apigateway.amazonaws.com", + "sourceArn": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "HttpApiF5A9A8A7" + }, + "/*/*/status/403" + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnPermission", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/HttpApi/GET--status--403/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGatewayV2::Route", + "aws:cdk:cloudformation:props": { + "apiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "authorizationType": "NONE", + "routeKey": "GET /status/403", + "target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "HttpApiGETstatus403ForbiddenIntegrationAF458604" + } + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.HttpRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.HttpApi", + "version": "0.0.0" + } + }, + "GetHandler": { + "id": "GetHandler", + "path": "InvokeFunctionAssertions/GetHandler", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "InvokeFunctionAssertions/GetHandler/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "InvokeFunctionAssertions/GetHandler/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/GetHandler/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/GetHandler/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "\n exports.handler = async () => ({\n statusCode: 200,\n body: 'Hello!',\n });" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "GetHandlerServiceRole9313FCB8", + "Arn" + ] + }, + "runtime": "nodejs20.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "PostHandler": { + "id": "PostHandler", + "path": "InvokeFunctionAssertions/PostHandler", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "InvokeFunctionAssertions/PostHandler/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "InvokeFunctionAssertions/PostHandler/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/PostHandler/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/PostHandler/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "\n exports.handler = async ({ body }) => ({\n statusCode: 200,\n body: 'Received body: ' + body,\n });" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "PostHandlerServiceRoleA5E1C273", + "Arn" + ] + }, + "runtime": "nodejs20.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "ForbiddenHandler": { + "id": "ForbiddenHandler", + "path": "InvokeFunctionAssertions/ForbiddenHandler", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "InvokeFunctionAssertions/ForbiddenHandler/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "InvokeFunctionAssertions/ForbiddenHandler/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/ForbiddenHandler/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/ForbiddenHandler/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "\n exports.handler = async ({ body }) => ({\n statusCode: 403,\n });" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "ForbiddenHandlerServiceRole993EA274", + "Arn" + ] + }, + "runtime": "nodejs20.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "Stage": { + "id": "Stage", + "path": "InvokeFunctionAssertions/Stage", + "children": { + "Resource": { + "id": "Resource", + "path": "InvokeFunctionAssertions/Stage/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGatewayV2::Stage", + "aws:cdk:cloudformation:props": { + "apiId": { + "Ref": "HttpApiF5A9A8A7" + }, + "autoDeploy": true, + "stageName": "dev" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.CfnStage", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigatewayv2.HttpStage", + "version": "0.0.0" + } + }, + "Exports": { + "id": "Exports", + "path": "InvokeFunctionAssertions/Exports", + "children": { + "Output{\"Ref\":\"HttpApiF5A9A8A7\"}": { + "id": "Output{\"Ref\":\"HttpApiF5A9A8A7\"}", + "path": "InvokeFunctionAssertions/Exports/Output{\"Ref\":\"HttpApiF5A9A8A7\"}", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "InvokeFunctionAssertions/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "InvokeFunctionAssertions/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "AssertionsTest": { + "id": "AssertionsTest", + "path": "AssertionsTest", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "AssertionsTest/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "AssertionsTest/DefaultTest/DeployAssert", + "children": { + "HttpApiCall5f7069701a458c2283dbb422b313fd3a": { + "id": "HttpApiCall5f7069701a458c2283dbb422b313fd3a", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall5f7069701a458c2283dbb422b313fd3a", + "children": { + "HttpProvider": { + "id": "HttpProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall5f7069701a458c2283dbb422b313fd3a/HttpProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall5f7069701a458c2283dbb422b313fd3a/HttpProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall5f7069701a458c2283dbb422b313fd3a/Default", + "children": { + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall5f7069701a458c2283dbb422b313fd3a/Default/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall5f7069701a458c2283dbb422b313fd3a/AssertionResults", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.HttpApiCall", + "version": "0.0.0" + } + }, + "SingletonFunction1488541a7b23466481b69b4408076b81": { + "id": "SingletonFunction1488541a7b23466481b69b4408076b81", + "path": "AssertionsTest/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81", + "children": { + "Staging": { + "id": "Staging", + "path": "AssertionsTest/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Staging", + "constructInfo": { + "fqn": "aws-cdk-lib.AssetStaging", + "version": "0.0.0" + } + }, + "Role": { + "id": "Role", + "path": "AssertionsTest/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + }, + "Handler": { + "id": "Handler", + "path": "AssertionsTest/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Handler", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "HttpApiCall1219698b15310d985020a947d89e593e": { + "id": "HttpApiCall1219698b15310d985020a947d89e593e", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall1219698b15310d985020a947d89e593e", + "children": { + "HttpProvider": { + "id": "HttpProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall1219698b15310d985020a947d89e593e/HttpProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall1219698b15310d985020a947d89e593e/HttpProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall1219698b15310d985020a947d89e593e/Default", + "children": { + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall1219698b15310d985020a947d89e593e/Default/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCall1219698b15310d985020a947d89e593e/AssertionResults", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.HttpApiCall", + "version": "0.0.0" + } + }, + "HttpApiCallf16d32bb38fdf952b8530f86260d5337": { + "id": "HttpApiCallf16d32bb38fdf952b8530f86260d5337", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallf16d32bb38fdf952b8530f86260d5337", + "children": { + "HttpProvider": { + "id": "HttpProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallf16d32bb38fdf952b8530f86260d5337/HttpProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallf16d32bb38fdf952b8530f86260d5337/HttpProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallf16d32bb38fdf952b8530f86260d5337/Default", + "children": { + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallf16d32bb38fdf952b8530f86260d5337/Default/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallf16d32bb38fdf952b8530f86260d5337/AssertionResults", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.HttpApiCall", + "version": "0.0.0" + } + }, + "HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31": { + "id": "HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31", + "children": { + "HttpProvider": { + "id": "HttpProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31/HttpProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31/HttpProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31/Default", + "children": { + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31/Default/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--getcd942067e1d112f86d205b2008dcab31/AssertionResults", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.HttpApiCall", + "version": "0.0.0" + } + }, + "HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f": { + "id": "HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f", + "children": { + "HttpProvider": { + "id": "HttpProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f/HttpProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f/HttpProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f/Default", + "children": { + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f/Default/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--post57c1eb9b16e045b0fe0eadcc8fcfe86f/AssertionResults", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.HttpApiCall", + "version": "0.0.0" + } + }, + "HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b": { + "id": "HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b", + "children": { + "HttpProvider": { + "id": "HttpProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b/HttpProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b/HttpProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b/Default", + "children": { + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b/Default/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "AssertionsTest/DefaultTest/DeployAssert/HttpApiCallhttpbin.org--status--403241ddf94e19f31ae5405653ddcc7ea8b/AssertionResults", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.HttpApiCall", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "AssertionsTest/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "AssertionsTest/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.ts b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.ts new file mode 100644 index 0000000000000..e3c1bd42b2702 --- /dev/null +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.http-api-call-assertions.ts @@ -0,0 +1,140 @@ +import { App, Stack } from 'aws-cdk-lib'; +import { ExpectedResult, IntegTest } from '../../../lib'; +import * as apigwv2 from 'aws-cdk-lib/aws-apigatewayv2'; +import * as lambda from 'aws-cdk-lib/aws-lambda'; +import * as integrations from 'aws-cdk-lib/aws-apigatewayv2-integrations'; + +const app = new App(); +const stack = new Stack(app, 'InvokeFunctionAssertions'); +const integ = new IntegTest(app, 'AssertionsTest', { + testCases: [stack], +}); + +const httpApi = new apigwv2.HttpApi(stack, 'HttpApi'); + +httpApi.addRoutes({ + path: '/get', + methods: [apigwv2.HttpMethod.GET], + integration: new integrations.HttpLambdaIntegration('GetIntegration', + new lambda.Function(stack, 'GetHandler', { + runtime: lambda.Runtime.NODEJS_20_X, + handler: 'index.handler', + code: new lambda.InlineCode(` + exports.handler = async () => ({ + statusCode: 200, + body: 'Hello!', + });`), + })), +}); + +httpApi.addRoutes({ + path: '/post', + methods: [apigwv2.HttpMethod.POST], + integration: new integrations.HttpLambdaIntegration('PostIntegration', + new lambda.Function(stack, 'PostHandler', { + runtime: lambda.Runtime.NODEJS_20_X, + handler: 'index.handler', + code: new lambda.InlineCode(` + exports.handler = async ({ body }) => ({ + statusCode: 200, + body: 'Received body: ' + body, + });`), + })), +}); + +httpApi.addRoutes({ + path: '/status/403', + methods: [apigwv2.HttpMethod.GET], + integration: new integrations.HttpLambdaIntegration('ForbiddenIntegration', + new lambda.Function(stack, 'ForbiddenHandler', { + runtime: lambda.Runtime.NODEJS_20_X, + handler: 'index.handler', + code: new lambda.InlineCode(` + exports.handler = async ({ body }) => ({ + statusCode: 403, + });`), + })), +}); + +const stage = new apigwv2.HttpStage(stack, 'Stage', { + httpApi, + stageName: 'dev', + autoDeploy: true, +}); + +integ.assertions.httpApiCall( + `${stage.url}/get`, +).expect( + ExpectedResult.objectLike({ + status: 200, + ok: true, + body: 'Hello!', + }), +); + +integ.assertions.httpApiCall( + `${stage.url}/post`, + { + method: 'POST', + body: JSON.stringify({ key: 'value' }), + headers: { 'Content-Type': 'application/json' }, + }, +).expect( + ExpectedResult.objectLike({ + status: 200, + ok: true, + body: 'Received body: {"key":"value"}', + }), +); + +integ.assertions.httpApiCall( + `${stage.url}/status/403`, +).expect( + ExpectedResult.objectLike({ + status: 403, + ok: false, + }), +); + +// We are also using httpbin.org to test the assertions with a fixed URL +// See https://github.com/aws/aws-cdk/issues/29700 + +integ.assertions.httpApiCall( + 'https://httpbin.org/get?key=value#hash', +).expect( + ExpectedResult.objectLike({ + status: 200, + ok: true, + body: { + url: 'https://httpbin.org/get?key=value', + args: { key: 'value' }, + }, + }), +); + +integ.assertions.httpApiCall( + 'https://httpbin.org/post', + { + method: 'POST', + body: JSON.stringify({ key: 'value' }), + headers: { 'Content-Type': 'application/json' }, + }, +).expect( + ExpectedResult.objectLike({ + status: 200, + ok: true, + body: { + url: 'https://httpbin.org/post', + json: { key: 'value' }, + }, + }), +); + +integ.assertions.httpApiCall( + 'https://httpbin.org/status/403', +).expect( + ExpectedResult.objectLike({ + status: 403, + ok: false, + }), +);