Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(apigatewayv2): support for mock integration type #18129

Merged
merged 6 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add mock integration type to enum and add expected json template to test
dir
  • Loading branch information
atchla committed Dec 22, 2021
commit 58fd288f62778a006793eb9d179358a0c7650c88
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
]
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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({ }) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export enum WebSocketIntegrationType {
/**
* AWS Proxy Integration Type
*/
AWS_PROXY = 'AWS_PROXY'
AWS_PROXY = 'AWS_PROXY',
/**
* Mock Integration Type
*/
MOCK = 'MOCK'
}

/**
Expand Down