From 2c50310dc451fbbb90e3ac1ff3ddf2315428c861 Mon Sep 17 00:00:00 2001 From: Austin Atchley Date: Sat, 20 Nov 2021 05:48:22 +0000 Subject: [PATCH 1/5] Add mock integration type --- .../lib/websocket/mock.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts new file mode 100644 index 0000000000000..c9a2dfc68e88d --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts @@ -0,0 +1,33 @@ +import { + IWebSocketRouteIntegration, + WebSocketIntegrationType, + WebSocketRouteIntegrationBindOptions, + WebSocketRouteIntegrationConfig, +} from '@aws-cdk/aws-apigatewayv2'; + +/** + * Mock WebSocket Integration props + */ +export interface MockWebSocketIntegrationProps { + // TODO: any props? + /** + * Prop description + */ + //readonly prop: IFunction + readonly prop: string; +} + +/** + * Mock WebSocket Integration + */ +export class MockWebSocketIntegration implements IWebSocketRouteIntegration { + constructor(private props: MockWebSocketIntegrationProps) {} + + bind(options: WebSocketRouteIntegrationBindOptions): WebSocketRouteIntegrationConfig { + options; this.props; + return { + type: WebSocketIntegrationType.AWS_PROXY, + uri: '', + }; + } +} From b6ffd968d0fbc19dfb6b0f9d29456ff76cc496cc Mon Sep 17 00:00:00 2001 From: Austin Atchley Date: Sat, 20 Nov 2021 06:37:25 +0000 Subject: [PATCH 2/5] fix import issues. add tests --- .../lib/websocket/index.ts | 1 + .../lib/websocket/mock.ts | 1 - .../test/websocket/integ.mock.ts | 29 ++++++++++++ .../test/websocket/mock.test.ts | 47 +++++++++++++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts create mode 100644 packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/index.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/index.ts index 04a64da0c7540..9c6035e3957d4 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/index.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/index.ts @@ -1 +1,2 @@ export * from './lambda'; +export * from './mock'; diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts index c9a2dfc68e88d..60b5457af40c9 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts @@ -14,7 +14,6 @@ export interface MockWebSocketIntegrationProps { * Prop description */ //readonly prop: IFunction - readonly prop: string; } /** diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts new file mode 100644 index 0000000000000..291cbbeb894be --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts @@ -0,0 +1,29 @@ +import { WebSocketApi, WebSocketStage } from '@aws-cdk/aws-apigatewayv2'; +import { App, CfnOutput, Stack } from '@aws-cdk/core'; +import { MockWebSocketIntegration } from '../../lib'; + +/* + * Stack verification steps: + * 1. Connect: 'wscat -c '. Should connect successfully and print event data containing connectionId in cloudwatch + * 2. SendMessage: '> {"action": "sendmessage", "data": "some-data"}'. Should send the message successfully + * 3. Default: '> {"data": "some-data"}'. Should send the message successfully + * 4. Disconnect: disconnect from the wscat. Should disconnect successfully + */ + +const app = new App(); +const stack = new Stack(app, 'WebSocketApiInteg'); + +const webSocketApi = new WebSocketApi(stack, 'mywsapi', { + connectRouteOptions: { integration: new MockWebSocketIntegration({ }) }, + disconnectRouteOptions: { integration: new MockWebSocketIntegration({ }) }, + defaultRouteOptions: { integration: new MockWebSocketIntegration({ }) }, +}); +const stage = new WebSocketStage(stack, 'mystage', { + webSocketApi, + stageName: 'dev', + autoDeploy: true, +}); + +webSocketApi.addRoute('sendmessage', { integration: new MockWebSocketIntegration({ }) }); + +new CfnOutput(stack, 'ApiEndpoint', { value: stage.url }); diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts new file mode 100644 index 0000000000000..f04782bf9dd30 --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts @@ -0,0 +1,47 @@ +import { Template } from '@aws-cdk/assertions'; +import { WebSocketApi } from '@aws-cdk/aws-apigatewayv2'; +import { Stack } from '@aws-cdk/core'; +import { MockWebSocketIntegration } from '../../lib'; + + +describe('MockWebSocketIntegration', () => { + test('default', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + new WebSocketApi(stack, 'Api', { + connectRouteOptions: { + integration: new MockWebSocketIntegration({}), + }, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Integration', { + IntegrationType: 'MOCK', + IntegrationUri: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':apigateway:', + { + Ref: 'AWS::Region', + }, + ':lambda:path/2015-03-31/functions/', + { + 'Fn::GetAtt': [ + 'Fn9270CBC0', + 'Arn', + ], + }, + '/invocations', + ], + ], + }, + }); + }); +}); From 58fd288f62778a006793eb9d179358a0c7650c88 Mon Sep 17 00:00:00 2001 From: Austin Atchley Date: Tue, 21 Dec 2021 22:42:52 -0600 Subject: [PATCH 3/5] Add mock integration type to enum and add expected json template to test dir --- .../lib/websocket/mock.ts | 2 +- .../test/websocket/integ.mock.expected.json | 136 ++++++++++++++++++ .../test/websocket/integ.mock.ts | 2 +- .../test/websocket/mock.test.ts | 24 +--- .../lib/websocket/integration.ts | 6 +- 5 files changed, 144 insertions(+), 26 deletions(-) create mode 100644 packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.expected.json diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts index 60b5457af40c9..698b5780d7875 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts @@ -25,7 +25,7 @@ export class MockWebSocketIntegration implements IWebSocketRouteIntegration { bind(options: WebSocketRouteIntegrationBindOptions): WebSocketRouteIntegrationConfig { options; this.props; return { - type: WebSocketIntegrationType.AWS_PROXY, + type: WebSocketIntegrationType.MOCK, uri: '', }; } diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.expected.json b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.expected.json new file mode 100644 index 0000000000000..cc9dc38f8376c --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.expected.json @@ -0,0 +1,136 @@ +{ + "Resources": { + "mywsapi32E6CE11": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Name": "mywsapi", + "ProtocolType": "WEBSOCKET", + "RouteSelectionExpression": "$request.body.action" + } + }, + "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6": { + "Type": "AWS::ApiGatewayV2::Integration", + "Properties": { + "ApiId": { + "Ref": "mywsapi32E6CE11" + }, + "IntegrationType": "MOCK", + "IntegrationUri": "" + } + }, + "mywsapiconnectRoute45A0ED6A": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "mywsapi32E6CE11" + }, + "RouteKey": "$connect", + "Target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6" + } + ] + ] + } + } + }, + "mywsapidisconnectRoute421A8CB9": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "mywsapi32E6CE11" + }, + "RouteKey": "$disconnect", + "Target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6" + } + ] + ] + } + } + }, + "mywsapidefaultRouteE9382DF8": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "mywsapi32E6CE11" + }, + "RouteKey": "$default", + "Target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6" + } + ] + ] + } + } + }, + "mywsapisendmessageRouteAE873328": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "mywsapi32E6CE11" + }, + "RouteKey": "sendmessage", + "Target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6" + } + ] + ] + } + } + }, + "mystage114C35EC": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "mywsapi32E6CE11" + }, + "StageName": "dev", + "AutoDeploy": true + } + } + }, + "Outputs": { + "ApiEndpoint": { + "Value": { + "Fn::Join": [ + "", + [ + "wss://", + { + "Ref": "mywsapi32E6CE11" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".", + { + "Ref": "AWS::URLSuffix" + }, + "/dev" + ] + ] + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts index 291cbbeb894be..ec5c76cb9ae8a 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts @@ -11,7 +11,7 @@ import { MockWebSocketIntegration } from '../../lib'; */ const app = new App(); -const stack = new Stack(app, 'WebSocketApiInteg'); +const stack = new Stack(app, 'integ-mock-websocket-integration'); const webSocketApi = new WebSocketApi(stack, 'mywsapi', { connectRouteOptions: { integration: new MockWebSocketIntegration({ }) }, diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts index f04782bf9dd30..4d6bc9085afef 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts @@ -19,29 +19,7 @@ describe('MockWebSocketIntegration', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Integration', { IntegrationType: 'MOCK', - IntegrationUri: { - 'Fn::Join': [ - '', - [ - 'arn:', - { - Ref: 'AWS::Partition', - }, - ':apigateway:', - { - Ref: 'AWS::Region', - }, - ':lambda:path/2015-03-31/functions/', - { - 'Fn::GetAtt': [ - 'Fn9270CBC0', - 'Arn', - ], - }, - '/invocations', - ], - ], - }, + IntegrationUri: '', }); }); }); diff --git a/packages/@aws-cdk/aws-apigatewayv2/lib/websocket/integration.ts b/packages/@aws-cdk/aws-apigatewayv2/lib/websocket/integration.ts index b5366be83f2ba..028dfd07b7a97 100644 --- a/packages/@aws-cdk/aws-apigatewayv2/lib/websocket/integration.ts +++ b/packages/@aws-cdk/aws-apigatewayv2/lib/websocket/integration.ts @@ -24,7 +24,11 @@ export enum WebSocketIntegrationType { /** * AWS Proxy Integration Type */ - AWS_PROXY = 'AWS_PROXY' + AWS_PROXY = 'AWS_PROXY', + /** + * Mock Integration Type + */ + MOCK = 'MOCK' } /** From 52b8b61fd56a210b25a95f44e15eb42328a4b802 Mon Sep 17 00:00:00 2001 From: Austin Atchley Date: Tue, 21 Dec 2021 23:41:52 -0600 Subject: [PATCH 4/5] re-implement after fast-forwarding --- .../lib/websocket/mock.ts | 25 ++++------ .../test/websocket/integ.mock.expected.json | 50 ++++--------------- .../test/websocket/integ.mock.ts | 11 ++-- .../test/websocket/mock.test.ts | 4 +- 4 files changed, 25 insertions(+), 65 deletions(-) diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts index 698b5780d7875..c1692756fd815 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts @@ -1,29 +1,24 @@ import { - IWebSocketRouteIntegration, + WebSocketRouteIntegration, WebSocketIntegrationType, - WebSocketRouteIntegrationBindOptions, WebSocketRouteIntegrationConfig, + WebSocketRouteIntegrationBindOptions, } from '@aws-cdk/aws-apigatewayv2'; /** - * Mock WebSocket Integration props + * Mock WebSocket Integration */ -export interface MockWebSocketIntegrationProps { - // TODO: any props? +export class MockWebSocketIntegration extends WebSocketRouteIntegration { + /** - * Prop description + * @param id id of the underlying integration construct */ - //readonly prop: IFunction -} - -/** - * Mock WebSocket Integration - */ -export class MockWebSocketIntegration implements IWebSocketRouteIntegration { - constructor(private props: MockWebSocketIntegrationProps) {} + constructor(id: string) { + super(id); + } bind(options: WebSocketRouteIntegrationBindOptions): WebSocketRouteIntegrationConfig { - options; this.props; + options; return { type: WebSocketIntegrationType.MOCK, uri: '', diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.expected.json b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.expected.json index cc9dc38f8376c..dede3af2298b4 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.expected.json +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.expected.json @@ -8,7 +8,7 @@ "RouteSelectionExpression": "$request.body.action" } }, - "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6": { + "mywsapidefaultRouteDefaultIntegrationFFCB3BA9": { "Type": "AWS::ApiGatewayV2::Integration", "Properties": { "ApiId": { @@ -18,64 +18,35 @@ "IntegrationUri": "" } }, - "mywsapiconnectRoute45A0ED6A": { - "Type": "AWS::ApiGatewayV2::Route", - "Properties": { - "ApiId": { - "Ref": "mywsapi32E6CE11" - }, - "RouteKey": "$connect", - "Target": { - "Fn::Join": [ - "", - [ - "integrations/", - { - "Ref": "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6" - } - ] - ] - } - } - }, - "mywsapidisconnectRoute421A8CB9": { + "mywsapidefaultRouteE9382DF8": { "Type": "AWS::ApiGatewayV2::Route", "Properties": { "ApiId": { "Ref": "mywsapi32E6CE11" }, - "RouteKey": "$disconnect", + "RouteKey": "$default", + "AuthorizationType": "NONE", "Target": { "Fn::Join": [ "", [ "integrations/", { - "Ref": "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6" + "Ref": "mywsapidefaultRouteDefaultIntegrationFFCB3BA9" } ] ] } } }, - "mywsapidefaultRouteE9382DF8": { - "Type": "AWS::ApiGatewayV2::Route", + "mywsapisendmessageRouteSendMessageIntegrationD29E12F9": { + "Type": "AWS::ApiGatewayV2::Integration", "Properties": { "ApiId": { "Ref": "mywsapi32E6CE11" }, - "RouteKey": "$default", - "Target": { - "Fn::Join": [ - "", - [ - "integrations/", - { - "Ref": "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6" - } - ] - ] - } + "IntegrationType": "MOCK", + "IntegrationUri": "" } }, "mywsapisendmessageRouteAE873328": { @@ -85,13 +56,14 @@ "Ref": "mywsapi32E6CE11" }, "RouteKey": "sendmessage", + "AuthorizationType": "NONE", "Target": { "Fn::Join": [ "", [ "integrations/", { - "Ref": "mywsapiconnectRouteWebSocketIntegration127d0ae2db4af590bf857fb7403b7d4d61CE41B6" + "Ref": "mywsapisendmessageRouteSendMessageIntegrationD29E12F9" } ] ] diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts index ec5c76cb9ae8a..6f086c3c6b0d3 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts @@ -4,19 +4,14 @@ import { MockWebSocketIntegration } from '../../lib'; /* * Stack verification steps: - * 1. Connect: 'wscat -c '. Should connect successfully and print event data containing connectionId in cloudwatch - * 2. SendMessage: '> {"action": "sendmessage", "data": "some-data"}'. Should send the message successfully - * 3. Default: '> {"data": "some-data"}'. Should send the message successfully - * 4. Disconnect: disconnect from the wscat. Should disconnect successfully + * 1. Verify manually that the integration has type "MOCK" */ const app = new App(); const stack = new Stack(app, 'integ-mock-websocket-integration'); const webSocketApi = new WebSocketApi(stack, 'mywsapi', { - connectRouteOptions: { integration: new MockWebSocketIntegration({ }) }, - disconnectRouteOptions: { integration: new MockWebSocketIntegration({ }) }, - defaultRouteOptions: { integration: new MockWebSocketIntegration({ }) }, + defaultRouteOptions: { integration: new MockWebSocketIntegration('DefaultIntegration') }, }); const stage = new WebSocketStage(stack, 'mystage', { webSocketApi, @@ -24,6 +19,6 @@ const stage = new WebSocketStage(stack, 'mystage', { autoDeploy: true, }); -webSocketApi.addRoute('sendmessage', { integration: new MockWebSocketIntegration({ }) }); +webSocketApi.addRoute('sendmessage', { integration: new MockWebSocketIntegration('SendMessageIntegration') }); new CfnOutput(stack, 'ApiEndpoint', { value: stage.url }); diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts index 4d6bc9085afef..8f1f8a147fcf8 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts @@ -11,9 +11,7 @@ describe('MockWebSocketIntegration', () => { // WHEN new WebSocketApi(stack, 'Api', { - connectRouteOptions: { - integration: new MockWebSocketIntegration({}), - }, + defaultRouteOptions: { integration: new MockWebSocketIntegration('DefaultIntegration') }, }); // THEN From 6fd5086ba0da9227465d1dc70e7c7d7c9ba1ac96 Mon Sep 17 00:00:00 2001 From: Austin Atchley Date: Thu, 23 Dec 2021 13:18:17 -0600 Subject: [PATCH 5/5] change integration class name to match naming standards --- .../aws-apigatewayv2-integrations/lib/websocket/mock.ts | 2 +- .../test/websocket/integ.mock.ts | 6 +++--- .../test/websocket/mock.test.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts index c1692756fd815..9c7a83ece4538 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/mock.ts @@ -8,7 +8,7 @@ import { /** * Mock WebSocket Integration */ -export class MockWebSocketIntegration extends WebSocketRouteIntegration { +export class WebSocketMockIntegration extends WebSocketRouteIntegration { /** * @param id id of the underlying integration construct diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts index 6f086c3c6b0d3..672378b42d375 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/integ.mock.ts @@ -1,6 +1,6 @@ import { WebSocketApi, WebSocketStage } from '@aws-cdk/aws-apigatewayv2'; import { App, CfnOutput, Stack } from '@aws-cdk/core'; -import { MockWebSocketIntegration } from '../../lib'; +import { WebSocketMockIntegration } from '../../lib'; /* * Stack verification steps: @@ -11,7 +11,7 @@ const app = new App(); const stack = new Stack(app, 'integ-mock-websocket-integration'); const webSocketApi = new WebSocketApi(stack, 'mywsapi', { - defaultRouteOptions: { integration: new MockWebSocketIntegration('DefaultIntegration') }, + defaultRouteOptions: { integration: new WebSocketMockIntegration('DefaultIntegration') }, }); const stage = new WebSocketStage(stack, 'mystage', { webSocketApi, @@ -19,6 +19,6 @@ const stage = new WebSocketStage(stack, 'mystage', { autoDeploy: true, }); -webSocketApi.addRoute('sendmessage', { integration: new MockWebSocketIntegration('SendMessageIntegration') }); +webSocketApi.addRoute('sendmessage', { integration: new WebSocketMockIntegration('SendMessageIntegration') }); new CfnOutput(stack, 'ApiEndpoint', { value: stage.url }); diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts index 8f1f8a147fcf8..4bd7eccd9fc7b 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/test/websocket/mock.test.ts @@ -1,7 +1,7 @@ import { Template } from '@aws-cdk/assertions'; import { WebSocketApi } from '@aws-cdk/aws-apigatewayv2'; import { Stack } from '@aws-cdk/core'; -import { MockWebSocketIntegration } from '../../lib'; +import { WebSocketMockIntegration } from '../../lib'; describe('MockWebSocketIntegration', () => { @@ -11,7 +11,7 @@ describe('MockWebSocketIntegration', () => { // WHEN new WebSocketApi(stack, 'Api', { - defaultRouteOptions: { integration: new MockWebSocketIntegration('DefaultIntegration') }, + defaultRouteOptions: { integration: new WebSocketMockIntegration('DefaultIntegration') }, }); // THEN