Skip to content

Commit f360335

Browse files
committed
Adding api_request_model any tests
1 parent e7a1496 commit f360335

File tree

4 files changed

+167
-35
lines changed

4 files changed

+167
-35
lines changed

tests/translator/input/api_request_model.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ Resources:
1515
RequestModel:
1616
Model: User
1717
Required: true
18+
AnyPath:
19+
Type: Api
20+
Properties:
21+
RestApiId: HtmlApi
22+
Path: /any
23+
Method: any
24+
RequestModel:
25+
Model: User
26+
Required: true
1827

1928
HtmlApi:
2029
Type: AWS::Serverless::Api

tests/translator/output/api_request_model.json

Lines changed: 70 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Resources": {
33
"HtmlFunctionRole": {
4-
"Type": "AWS::IAM::Role",
4+
"Type": "AWS::IAM::Role",
55
"Properties": {
66
"ManagedPolicyArns": [
77
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
@@ -13,13 +13,13 @@
1313
}
1414
],
1515
"AssumeRolePolicyDocument": {
16-
"Version": "2012-10-17",
16+
"Version": "2012-10-17",
1717
"Statement": [
1818
{
1919
"Action": [
2020
"sts:AssumeRole"
21-
],
22-
"Effect": "Allow",
21+
],
22+
"Effect": "Allow",
2323
"Principal": {
2424
"Service": [
2525
"lambda.amazonaws.com"
@@ -29,30 +29,30 @@
2929
]
3030
}
3131
}
32-
},
32+
},
3333
"HtmlApiProdStage": {
34-
"Type": "AWS::ApiGateway::Stage",
34+
"Type": "AWS::ApiGateway::Stage",
3535
"Properties": {
3636
"DeploymentId": {
37-
"Ref": "HtmlApiDeploymentdd6198efe6"
38-
},
37+
"Ref": "HtmlApiDeploymentcb065c609e"
38+
},
3939
"RestApiId": {
4040
"Ref": "HtmlApi"
41-
},
41+
},
4242
"StageName": "Prod"
4343
}
44-
},
44+
},
4545
"HtmlFunctionGetHtmlPermissionProd": {
46-
"Type": "AWS::Lambda::Permission",
46+
"Type": "AWS::Lambda::Permission",
4747
"Properties": {
48-
"Action": "lambda:InvokeFunction",
49-
"Principal": "apigateway.amazonaws.com",
48+
"Action": "lambda:InvokeFunction",
49+
"Principal": "apigateway.amazonaws.com",
5050
"FunctionName": {
5151
"Ref": "HtmlFunction"
52-
},
52+
},
5353
"SourceArn": {
5454
"Fn::Sub": [
55-
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/",
55+
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/",
5656
{
5757
"__Stage__": "*",
5858
"__ApiId__": "HtmlApi"
@@ -61,18 +61,37 @@
6161
}
6262
}
6363
},
64-
"HtmlApiDeploymentdd6198efe6": {
65-
"Type": "AWS::ApiGateway::Deployment",
64+
"HtmlFunctionAnyPathPermissionProd": {
65+
"Type": "AWS::Lambda::Permission",
66+
"Properties": {
67+
"Action": "lambda:InvokeFunction",
68+
"FunctionName": {
69+
"Ref": "HtmlFunction"
70+
},
71+
"Principal": "apigateway.amazonaws.com",
72+
"SourceArn": {
73+
"Fn::Sub": [
74+
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*/any",
75+
{
76+
"__ApiId__": "HtmlApi",
77+
"__Stage__": "*"
78+
}
79+
]
80+
}
81+
}
82+
},
83+
"HtmlApiDeploymentcb065c609e": {
84+
"Type": "AWS::ApiGateway::Deployment",
6685
"Properties": {
6786
"RestApiId": {
6887
"Ref": "HtmlApi"
69-
},
70-
"Description": "RestApi deployment id: dd6198efe68d8db17c8bf6b680a8a6763e4f36b5",
88+
},
89+
"Description": "RestApi deployment id: cb065c609e3452b9ac6cc88cd778dce0647a0a10",
7190
"StageName": "Stage"
7291
}
73-
},
92+
},
7493
"HtmlApi": {
75-
"Type": "AWS::ApiGateway::RestApi",
94+
"Type": "AWS::ApiGateway::RestApi",
7695
"Properties": {
7796
"Body": {
7897
"info": {
@@ -103,6 +122,28 @@
103122
}
104123
]
105124
}
125+
},
126+
"/any": {
127+
"x-amazon-apigateway-any-method": {
128+
"x-amazon-apigateway-integration": {
129+
"type": "aws_proxy",
130+
"httpMethod": "POST",
131+
"uri": {
132+
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HtmlFunction.Arn}/invocations"
133+
}
134+
},
135+
"responses": {},
136+
"parameters": [
137+
{
138+
"in": "body",
139+
"name": "user",
140+
"schema": {
141+
"$ref": "#/definitions/user"
142+
},
143+
"required": true
144+
}
145+
]
146+
}
106147
}
107148
},
108149
"swagger": "2.0",
@@ -118,25 +159,25 @@
118159
}
119160
}
120161
}
121-
},
162+
},
122163
"HtmlFunction": {
123-
"Type": "AWS::Lambda::Function",
164+
"Type": "AWS::Lambda::Function",
124165
"Properties": {
125166
"Code": {
126-
"S3Bucket": "sam-demo-bucket",
167+
"S3Bucket": "sam-demo-bucket",
127168
"S3Key": "member_portal.zip"
128-
},
129-
"Handler": "index.gethtml",
169+
},
170+
"Handler": "index.gethtml",
130171
"Role": {
131172
"Fn::GetAtt": [
132-
"HtmlFunctionRole",
173+
"HtmlFunctionRole",
133174
"Arn"
134175
]
135-
},
176+
},
136177
"Runtime": "nodejs12.x",
137178
"Tags": [
138179
{
139-
"Value": "SAM",
180+
"Value": "SAM",
140181
"Key": "lambda:createdBy"
141182
}
142183
]

tests/translator/output/aws-cn/api_request_model.json

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"Type": "AWS::ApiGateway::Stage",
3535
"Properties": {
3636
"DeploymentId": {
37-
"Ref": "HtmlApiDeploymentd7bcfbe715"
37+
"Ref": "HtmlApiDeployment37c4e9609d"
3838
},
3939
"RestApiId": {
4040
"Ref": "HtmlApi"
@@ -61,13 +61,32 @@
6161
}
6262
}
6363
},
64-
"HtmlApiDeploymentd7bcfbe715": {
64+
"HtmlFunctionAnyPathPermissionProd": {
65+
"Type": "AWS::Lambda::Permission",
66+
"Properties": {
67+
"Action": "lambda:InvokeFunction",
68+
"FunctionName": {
69+
"Ref": "HtmlFunction"
70+
},
71+
"Principal": "apigateway.amazonaws.com",
72+
"SourceArn": {
73+
"Fn::Sub": [
74+
"arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*/any",
75+
{
76+
"__ApiId__": "HtmlApi",
77+
"__Stage__": "*"
78+
}
79+
]
80+
}
81+
}
82+
},
83+
"HtmlApiDeployment37c4e9609d": {
6584
"Type": "AWS::ApiGateway::Deployment",
6685
"Properties": {
6786
"RestApiId": {
6887
"Ref": "HtmlApi"
6988
},
70-
"Description": "RestApi deployment id: d7bcfbe7157513b0b1a2debffbe44655fb332d60",
89+
"Description": "RestApi deployment id: 37c4e9609d82528be3f2388c7b7e80b7b78cd31f",
7190
"StageName": "Stage"
7291
}
7392
},
@@ -108,6 +127,28 @@
108127
}
109128
]
110129
}
130+
},
131+
"/any": {
132+
"x-amazon-apigateway-any-method": {
133+
"x-amazon-apigateway-integration": {
134+
"type": "aws_proxy",
135+
"httpMethod": "POST",
136+
"uri": {
137+
"Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HtmlFunction.Arn}/invocations"
138+
}
139+
},
140+
"responses": {},
141+
"parameters": [
142+
{
143+
"in": "body",
144+
"name": "user",
145+
"schema": {
146+
"$ref": "#/definitions/user"
147+
},
148+
"required": true
149+
}
150+
]
151+
}
111152
}
112153
},
113154
"swagger": "2.0",

tests/translator/output/aws-us-gov/api_request_model.json

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"Type": "AWS::ApiGateway::Stage",
3535
"Properties": {
3636
"DeploymentId": {
37-
"Ref": "HtmlApiDeployment3744537077"
37+
"Ref": "HtmlApiDeploymenta918aefe10"
3838
},
3939
"RestApiId": {
4040
"Ref": "HtmlApi"
@@ -61,13 +61,32 @@
6161
}
6262
}
6363
},
64-
"HtmlApiDeployment3744537077": {
64+
"HtmlFunctionAnyPathPermissionProd": {
65+
"Type": "AWS::Lambda::Permission",
66+
"Properties": {
67+
"Action": "lambda:InvokeFunction",
68+
"FunctionName": {
69+
"Ref": "HtmlFunction"
70+
},
71+
"Principal": "apigateway.amazonaws.com",
72+
"SourceArn": {
73+
"Fn::Sub": [
74+
"arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*/any",
75+
{
76+
"__ApiId__": "HtmlApi",
77+
"__Stage__": "*"
78+
}
79+
]
80+
}
81+
}
82+
},
83+
"HtmlApiDeploymenta918aefe10": {
6584
"Type": "AWS::ApiGateway::Deployment",
6685
"Properties": {
6786
"RestApiId": {
6887
"Ref": "HtmlApi"
6988
},
70-
"Description": "RestApi deployment id: 374453707756d2ce5439fb8f0995a4ced3659a0e",
89+
"Description": "RestApi deployment id: a918aefe10cedb759cd5d8b070774d1e1804de32",
7190
"StageName": "Stage"
7291
}
7392
},
@@ -108,6 +127,28 @@
108127
}
109128
]
110129
}
130+
},
131+
"/any": {
132+
"x-amazon-apigateway-any-method": {
133+
"x-amazon-apigateway-integration": {
134+
"type": "aws_proxy",
135+
"httpMethod": "POST",
136+
"uri": {
137+
"Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HtmlFunction.Arn}/invocations"
138+
}
139+
},
140+
"responses": {},
141+
"parameters": [
142+
{
143+
"in": "body",
144+
"name": "user",
145+
"schema": {
146+
"$ref": "#/definitions/user"
147+
},
148+
"required": true
149+
}
150+
]
151+
}
111152
}
112153
},
113154
"swagger": "2.0",

0 commit comments

Comments
 (0)