Skip to content

Commit b8878b1

Browse files
torresxb1hawflau
andauthored
test: Add tests for intrinsics support for DefinitionBody (#2407)
* test: Add tests for intrinsics support for DefinitionBody * Update intrinsic test for DefinitionBody Co-authored-by: Wing Fung Lau <[email protected]>
1 parent 243db8a commit b8878b1

File tree

5 files changed

+536
-0
lines changed

5 files changed

+536
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: >
4+
DefinitionBody currently only supports intrinsics when SwaggerEditor/OpenApiEditor is not used (as of 2022-05-30).
5+
Let's add tests to make sure we keep this support, because we've had a regression where we accidentally
6+
removed this intrinsics support by using the SwaggerEditor.
7+
Note that the only supported intrinsic function for DefinitionBody is Fn::If. Other intrinsics are not supported
8+
because they don't resolve to dictionary.
9+
10+
Conditions:
11+
FalseCondition:
12+
Fn::Equals:
13+
- true
14+
- false
15+
16+
Resources:
17+
# Rest Api with DefinitionBody under If intrinsic, SwaggerEditor not used
18+
RestApiIfIntrinsicAndNoSwaggerEditor:
19+
Type: AWS::Serverless::Api
20+
Properties:
21+
StageName: prod
22+
DefinitionBody:
23+
Fn::If:
24+
- FalseCondition
25+
-
26+
swagger: '2.0'
27+
info:
28+
title: !Sub ${AWS::StackName}-Api
29+
paths:
30+
/post:
31+
post:
32+
x-amazon-apigateway-integration:
33+
httpMethod: POST
34+
type: aws_proxy
35+
uri: https://www.alphavantage.co/
36+
payloadFormatVersion: '1.0'
37+
-
38+
swagger: '2.0'
39+
info:
40+
title: !Sub ${AWS::StackName}-Api
41+
paths:
42+
/post:
43+
post:
44+
x-amazon-apigateway-integration:
45+
httpMethod: POST
46+
type: aws_proxy
47+
uri: https://www.otheruri.co/
48+
payloadFormatVersion: '1.0'
49+
50+
# HttpApi with DefinitionBody under If intrinsic, OpenApiEditor not used
51+
HttpApiIfIntrinsicAndNoOpenApiEditor:
52+
Type: AWS::Serverless::HttpApi
53+
Properties:
54+
StageName: prod
55+
DefinitionBody:
56+
Fn::If:
57+
- FalseCondition
58+
-
59+
openapi: '3.0'
60+
info:
61+
title: !Sub ${AWS::StackName}-Api
62+
paths:
63+
/post:
64+
post:
65+
x-amazon-apigateway-integration:
66+
httpMethod: POST
67+
type: aws_proxy
68+
uri: https://www.alphavantage.co/
69+
payloadFormatVersion: '1.0'
70+
-
71+
openapi: '3.0'
72+
info:
73+
title: !Sub ${AWS::StackName}-Api
74+
paths:
75+
/post:
76+
post:
77+
x-amazon-apigateway-integration:
78+
httpMethod: POST
79+
type: aws_proxy
80+
uri: https://www.otheruri.co/
81+
payloadFormatVersion: '1.0'
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Description": "DefinitionBody currently only supports intrinsics when SwaggerEditor/OpenApiEditor is not used (as of 2022-05-30). Let's add tests to make sure we keep this support, because we've had a regression where we accidentally removed this intrinsics support by using the SwaggerEditor. Note that the only supported intrinsic function for DefinitionBody is Fn::If. Other intrinsics are not supported because they don't resolve to dictionary. \n",
4+
"Conditions": {
5+
"FalseCondition": {
6+
"Fn::Equals": [
7+
true,
8+
false
9+
]
10+
}
11+
},
12+
"Resources": {
13+
"RestApiIfIntrinsicAndNoSwaggerEditorDeployment2f0411dccd": {
14+
"Type": "AWS::ApiGateway::Deployment",
15+
"Properties": {
16+
"Description": "RestApi deployment id: 2f0411dccde517dcb5c82d3848dbc431e7479ebc",
17+
"RestApiId": {
18+
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditor"
19+
},
20+
"StageName": "Stage"
21+
}
22+
},
23+
"RestApiIfIntrinsicAndNoSwaggerEditorprodStage": {
24+
"Type": "AWS::ApiGateway::Stage",
25+
"Properties": {
26+
"DeploymentId": {
27+
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditorDeployment2f0411dccd"
28+
},
29+
"RestApiId": {
30+
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditor"
31+
},
32+
"StageName": "prod"
33+
}
34+
},
35+
"HttpApiIfIntrinsicAndNoOpenApiEditorprodStage": {
36+
"Type": "AWS::ApiGatewayV2::Stage",
37+
"Properties": {
38+
"ApiId": {
39+
"Ref": "HttpApiIfIntrinsicAndNoOpenApiEditor"
40+
},
41+
"StageName": "prod",
42+
"AutoDeploy": true
43+
}
44+
},
45+
"RestApiIfIntrinsicAndNoSwaggerEditor": {
46+
"Type": "AWS::ApiGateway::RestApi",
47+
"Properties": {
48+
"Body": {
49+
"Fn::If": [
50+
"FalseCondition",
51+
{
52+
"info": {
53+
"title": {
54+
"Fn::Sub": "${AWS::StackName}-Api"
55+
}
56+
},
57+
"paths": {
58+
"/post": {
59+
"post": {
60+
"x-amazon-apigateway-integration": {
61+
"httpMethod": "POST",
62+
"type": "aws_proxy",
63+
"uri": "https://www.alphavantage.co/",
64+
"payloadFormatVersion": "1.0"
65+
}
66+
}
67+
}
68+
},
69+
"swagger": "2.0"
70+
},
71+
{
72+
"info": {
73+
"title": {
74+
"Fn::Sub": "${AWS::StackName}-Api"
75+
}
76+
},
77+
"paths": {
78+
"/post": {
79+
"post": {
80+
"x-amazon-apigateway-integration": {
81+
"httpMethod": "POST",
82+
"type": "aws_proxy",
83+
"uri": "https://www.otheruri.co/",
84+
"payloadFormatVersion": "1.0"
85+
}
86+
}
87+
}
88+
},
89+
"swagger": "2.0"
90+
}
91+
]
92+
},
93+
"Parameters": {
94+
"endpointConfigurationTypes": "REGIONAL"
95+
},
96+
"EndpointConfiguration": {
97+
"Types": [
98+
"REGIONAL"
99+
]
100+
}
101+
}
102+
},
103+
"HttpApiIfIntrinsicAndNoOpenApiEditor": {
104+
"Type": "AWS::ApiGatewayV2::Api",
105+
"Properties": {
106+
"Body": {
107+
"Fn::If": [
108+
"FalseCondition",
109+
{
110+
"info": {
111+
"title": {
112+
"Fn::Sub": "${AWS::StackName}-Api"
113+
}
114+
},
115+
"paths": {
116+
"/post": {
117+
"post": {
118+
"x-amazon-apigateway-integration": {
119+
"httpMethod": "POST",
120+
"type": "aws_proxy",
121+
"uri": "https://www.alphavantage.co/",
122+
"payloadFormatVersion": "1.0"
123+
}
124+
}
125+
}
126+
},
127+
"openapi": "3.0"
128+
},
129+
{
130+
"info": {
131+
"title": {
132+
"Fn::Sub": "${AWS::StackName}-Api"
133+
}
134+
},
135+
"paths": {
136+
"/post": {
137+
"post": {
138+
"x-amazon-apigateway-integration": {
139+
"httpMethod": "POST",
140+
"type": "aws_proxy",
141+
"uri": "https://www.otheruri.co/",
142+
"payloadFormatVersion": "1.0"
143+
}
144+
}
145+
}
146+
},
147+
"openapi": "3.0"
148+
}
149+
]
150+
}
151+
}
152+
}
153+
}
154+
}
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Description": "DefinitionBody currently only supports intrinsics when SwaggerEditor/OpenApiEditor is not used (as of 2022-05-30). Let's add tests to make sure we keep this support, because we've had a regression where we accidentally removed this intrinsics support by using the SwaggerEditor. Note that the only supported intrinsic function for DefinitionBody is Fn::If. Other intrinsics are not supported because they don't resolve to dictionary. \n",
4+
"Conditions": {
5+
"FalseCondition": {
6+
"Fn::Equals": [
7+
true,
8+
false
9+
]
10+
}
11+
},
12+
"Resources": {
13+
"RestApiIfIntrinsicAndNoSwaggerEditorDeployment2f0411dccd": {
14+
"Type": "AWS::ApiGateway::Deployment",
15+
"Properties": {
16+
"Description": "RestApi deployment id: 2f0411dccde517dcb5c82d3848dbc431e7479ebc",
17+
"RestApiId": {
18+
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditor"
19+
},
20+
"StageName": "Stage"
21+
}
22+
},
23+
"RestApiIfIntrinsicAndNoSwaggerEditorprodStage": {
24+
"Type": "AWS::ApiGateway::Stage",
25+
"Properties": {
26+
"DeploymentId": {
27+
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditorDeployment2f0411dccd"
28+
},
29+
"RestApiId": {
30+
"Ref": "RestApiIfIntrinsicAndNoSwaggerEditor"
31+
},
32+
"StageName": "prod"
33+
}
34+
},
35+
"HttpApiIfIntrinsicAndNoOpenApiEditorprodStage": {
36+
"Type": "AWS::ApiGatewayV2::Stage",
37+
"Properties": {
38+
"ApiId": {
39+
"Ref": "HttpApiIfIntrinsicAndNoOpenApiEditor"
40+
},
41+
"StageName": "prod",
42+
"AutoDeploy": true
43+
}
44+
},
45+
"RestApiIfIntrinsicAndNoSwaggerEditor": {
46+
"Type": "AWS::ApiGateway::RestApi",
47+
"Properties": {
48+
"Body": {
49+
"Fn::If": [
50+
"FalseCondition",
51+
{
52+
"info": {
53+
"title": {
54+
"Fn::Sub": "${AWS::StackName}-Api"
55+
}
56+
},
57+
"paths": {
58+
"/post": {
59+
"post": {
60+
"x-amazon-apigateway-integration": {
61+
"httpMethod": "POST",
62+
"type": "aws_proxy",
63+
"uri": "https://www.alphavantage.co/",
64+
"payloadFormatVersion": "1.0"
65+
}
66+
}
67+
}
68+
},
69+
"swagger": "2.0"
70+
},
71+
{
72+
"info": {
73+
"title": {
74+
"Fn::Sub": "${AWS::StackName}-Api"
75+
}
76+
},
77+
"paths": {
78+
"/post": {
79+
"post": {
80+
"x-amazon-apigateway-integration": {
81+
"httpMethod": "POST",
82+
"type": "aws_proxy",
83+
"uri": "https://www.otheruri.co/",
84+
"payloadFormatVersion": "1.0"
85+
}
86+
}
87+
}
88+
},
89+
"swagger": "2.0"
90+
}
91+
]
92+
},
93+
"Parameters": {
94+
"endpointConfigurationTypes": "REGIONAL"
95+
},
96+
"EndpointConfiguration": {
97+
"Types": [
98+
"REGIONAL"
99+
]
100+
}
101+
}
102+
},
103+
"HttpApiIfIntrinsicAndNoOpenApiEditor": {
104+
"Type": "AWS::ApiGatewayV2::Api",
105+
"Properties": {
106+
"Body": {
107+
"Fn::If": [
108+
"FalseCondition",
109+
{
110+
"info": {
111+
"title": {
112+
"Fn::Sub": "${AWS::StackName}-Api"
113+
}
114+
},
115+
"paths": {
116+
"/post": {
117+
"post": {
118+
"x-amazon-apigateway-integration": {
119+
"httpMethod": "POST",
120+
"type": "aws_proxy",
121+
"uri": "https://www.alphavantage.co/",
122+
"payloadFormatVersion": "1.0"
123+
}
124+
}
125+
}
126+
},
127+
"openapi": "3.0"
128+
},
129+
{
130+
"info": {
131+
"title": {
132+
"Fn::Sub": "${AWS::StackName}-Api"
133+
}
134+
},
135+
"paths": {
136+
"/post": {
137+
"post": {
138+
"x-amazon-apigateway-integration": {
139+
"httpMethod": "POST",
140+
"type": "aws_proxy",
141+
"uri": "https://www.otheruri.co/",
142+
"payloadFormatVersion": "1.0"
143+
}
144+
}
145+
}
146+
},
147+
"openapi": "3.0"
148+
}
149+
]
150+
}
151+
}
152+
}
153+
}
154+
}

0 commit comments

Comments
 (0)