-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add functional tests for http api (#1635)
- Loading branch information
Showing
11 changed files
with
678 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
tests/functional/commands/validate/lib/models/explicit_http_api.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Resources: | ||
HttpApiFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/todo_list.zip | ||
Handler: index.restapi | ||
Runtime: python3.7 | ||
Events: | ||
SimpleCase: | ||
Type: HttpApi | ||
Properties: | ||
ApiId: !Ref MyApi | ||
SimpleCase2: | ||
Type: HttpApi | ||
Properties: | ||
ApiId: !Ref MyApi2 | ||
MyApi: | ||
Type: AWS::Serverless::HttpApi | ||
Properties: | ||
Auth: | ||
Authorizers: | ||
OAuth2: | ||
AuthorizationScopes: | ||
- scope4 | ||
JwtConfiguration: | ||
issuer: "https://www.example.com/v1/connect/oidc" | ||
audience: | ||
- MyApi | ||
IdentitySource: "$request.querystring.param" | ||
DefaultAuthorizer: OAuth2 | ||
|
||
MyApi2: | ||
Type: AWS::Serverless::HttpApi | ||
Properties: | ||
Auth: | ||
Authorizers: | ||
OAuth2: | ||
JwtConfiguration: | ||
issuer: "https://www.example.com/v1/connect/oidc" | ||
audience: | ||
- MyApi | ||
IdentitySource: "$request.querystring.param" | ||
DefaultAuthorizer: OAuth2 |
12 changes: 12 additions & 0 deletions
12
tests/functional/commands/validate/lib/models/explicit_http_api_minimum.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Resources: | ||
Api: | ||
Type: AWS::Serverless::HttpApi | ||
Function: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: index.handler | ||
CodeUri: s3://bucket/key | ||
Runtime: python3.7 | ||
Events: | ||
Api: | ||
Type: HttpApi |
34 changes: 34 additions & 0 deletions
34
tests/functional/commands/validate/lib/models/http_api_def_uri.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Resources: | ||
MyApi: | ||
Type: AWS::Serverless::HttpApi | ||
Properties: | ||
DefinitionUri: s3://bucket/key | ||
Tags: | ||
Tag: value | ||
StageName: !Join ["", ["Stage", "Name"]] | ||
|
||
MyApi2: | ||
Type: AWS::Serverless::HttpApi | ||
Properties: | ||
DefinitionUri: | ||
Bucket: bucket | ||
Key: key | ||
Version: version | ||
Tags: | ||
Tag: value | ||
|
||
Function: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Runtime: python3.7 | ||
Handler: index.handler | ||
CodeUri: s3://bucket/key | ||
Events: | ||
Api: | ||
Type: HttpApi | ||
Properties: | ||
ApiId: MyApi | ||
Api2: | ||
Type: HttpApi | ||
Properties: | ||
ApiId: !Ref MyApi2 |
94 changes: 94 additions & 0 deletions
94
tests/functional/commands/validate/lib/models/http_api_existing_openapi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
Resources: | ||
HttpApiFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/todo_list.zip | ||
Handler: index.restapi | ||
Runtime: nodejs4.3 | ||
Policies: AmazonDynamoDBFullAccess | ||
Events: | ||
Basic: # integration exists | ||
Type: HttpApi | ||
Properties: | ||
Path: /basic | ||
Method: post | ||
ApiId: !Ref MyApi | ||
SimpleCase: # path exists, integration doesn't | ||
Type: HttpApi | ||
Properties: | ||
ApiId: !Ref MyApi | ||
MyApi: | ||
Type: AWS::Serverless::HttpApi | ||
Properties: | ||
DefinitionBody: | ||
info: | ||
version: '1.0' | ||
title: | ||
Ref: AWS::StackName | ||
paths: | ||
"/basic": | ||
post: | ||
x-amazon-apigateway-integration: | ||
httpMethod: POST | ||
type: aws_proxy | ||
uri: | ||
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DifferentFunction.Arn}/invocations | ||
payloadFormatVersion: '1.0' | ||
security: | ||
- OpenIdAuth: | ||
- scope3 | ||
responses: {} | ||
"/integration": | ||
post: | ||
x-amazon-apigateway-integration: | ||
httpMethod: POST | ||
type: aws_proxy | ||
uri: | ||
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations | ||
payloadFormatVersion: '1.0' | ||
security: | ||
- OpenIdAuth: | ||
- scope1 | ||
- scope2 | ||
responses: {} | ||
"$default": | ||
x-amazon-apigateway-any-method: | ||
isDefaultRoute: true | ||
security: | ||
- OpenIdAuth: | ||
- scope1 | ||
- scope2 | ||
responses: {} | ||
"/oauth2": | ||
post: | ||
x-amazon-apigateway-integration: | ||
httpMethod: POST | ||
type: aws_proxy | ||
uri: | ||
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations | ||
payloadFormatVersion: '1.0' | ||
security: | ||
- oauth2Auth: | ||
- scope4 | ||
responses: {} | ||
openapi: 3.0.1 | ||
securitySchemes: | ||
oauth2Auth: | ||
type: oauth2 | ||
x-amazon-apigateway-authorizer: | ||
identitySource: "$request.querystring.param" | ||
type: jwt | ||
jwtConfiguration: | ||
audience: | ||
- MyApi | ||
issuer: https://www.example.com/v1/connect/oidc | ||
OpenIdAuth: | ||
type: openIdConnect | ||
x-amazon-apigateway-authorizer: | ||
identitySource: "$request.querystring.param" | ||
type: jwt | ||
jwtConfiguration: | ||
audience: | ||
- MyApi | ||
issuer: https://www.example.com/v1/connect/oidc | ||
openIdConnectUrl: https://www.example.com/v1/connect |
128 changes: 128 additions & 0 deletions
128
tests/functional/commands/validate/lib/models/http_api_existing_openapi_conditions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
Conditions: | ||
condition: | ||
Fn::Equals: | ||
- true | ||
- true | ||
Resources: | ||
HttpApiFunction: | ||
Condition: condition | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/todo_list.zip | ||
Handler: index.restapi | ||
Runtime: python3.7 | ||
Events: | ||
Basic: # integration exists | ||
Type: HttpApi | ||
Properties: | ||
Path: /basic | ||
Method: post | ||
ApiId: !Ref MyApi | ||
Basic2: # integration exists, auth doesn't | ||
Type: HttpApi | ||
Properties: | ||
Path: /basic | ||
Method: get | ||
ApiId: !Ref MyApi | ||
Auth: | ||
Authorizer: OAuth2 | ||
AuthorizationScopes: | ||
- basic | ||
SimpleCase: # path exists, integration doesn't | ||
Type: HttpApi | ||
Properties: | ||
ApiId: !Ref MyApi | ||
MyApi: | ||
Type: AWS::Serverless::HttpApi | ||
Properties: | ||
Auth: | ||
Authorizers: | ||
OAuth2: | ||
AuthorizationScopes: | ||
- scope4 | ||
JwtConfiguration: | ||
issuer: "https://www.example.com/v1/connect/oidc" | ||
audience: | ||
- MyApi | ||
IdentitySource: "$request.querystring.param" | ||
DefaultAuthorizer: OAuth2 | ||
DefinitionBody: | ||
info: | ||
version: '1.0' | ||
title: | ||
Ref: AWS::StackName | ||
paths: | ||
"/basic": | ||
post: | ||
x-amazon-apigateway-integration: | ||
httpMethod: POST | ||
type: aws_proxy | ||
uri: | ||
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DifferentFunction.Arn}/invocations | ||
payloadFormatVersion: '1.0' | ||
security: | ||
- OpenIdAuth: | ||
- scope3 | ||
responses: {} | ||
get: | ||
x-amazon-apigateway-integration: | ||
httpMethod: POST | ||
type: aws_proxy | ||
uri: | ||
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DifferentFunction.Arn}/invocations | ||
payloadFormatVersion: '1.0' | ||
responses: {} | ||
"/integration": | ||
post: | ||
x-amazon-apigateway-integration: | ||
httpMethod: POST | ||
type: aws_proxy | ||
uri: | ||
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations | ||
payloadFormatVersion: '1.0' | ||
security: | ||
- OpenIdAuth: | ||
- scope1 | ||
- scope2 | ||
responses: {} | ||
"$default": | ||
x-amazon-apigateway-any-method: | ||
isDefaultRoute: true | ||
security: | ||
- OpenIdAuth: | ||
- scope1 | ||
- scope2 | ||
responses: {} | ||
"/oauth2": | ||
post: | ||
x-amazon-apigateway-integration: | ||
httpMethod: POST | ||
type: aws_proxy | ||
uri: | ||
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations | ||
payloadFormatVersion: '1.0' | ||
security: | ||
- oauth2Auth: | ||
- scope4 | ||
responses: {} | ||
openapi: 3.0.1 | ||
securitySchemes: | ||
oauth2Auth: | ||
type: oauth2 | ||
x-amazon-apigateway-authorizer: | ||
identitySource: "$request.querystring.param" | ||
type: jwt | ||
jwtConfiguration: | ||
audience: | ||
- MyApi | ||
issuer: https://www.example.com/v1/connect/oidc | ||
OpenIdAuth: | ||
type: openIdConnect | ||
x-amazon-apigateway-authorizer: | ||
identitySource: "$request.querystring.param" | ||
type: jwt | ||
jwtConfiguration: | ||
audience: | ||
- MyApi | ||
issuer: https://www.example.com/v1/connect/oidc | ||
openIdConnectUrl: https://www.example.com/v1/connect |
16 changes: 16 additions & 0 deletions
16
tests/functional/commands/validate/lib/models/http_api_explicit_stage.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Resources: | ||
HttpApiFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/todo_list.zip | ||
Handler: index.restapi | ||
Runtime: nodejs4.3 | ||
Events: | ||
SimpleCase: | ||
Type: HttpApi | ||
Properties: | ||
ApiId: !Ref MyApi | ||
MyApi: | ||
Type: AWS::Serverless::HttpApi | ||
Properties: | ||
StageName: Prod |
30 changes: 30 additions & 0 deletions
30
tests/functional/commands/validate/lib/models/implicit_http_api.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Resources: | ||
HttpApiFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/todo_list.zip | ||
Handler: index.restapi | ||
Runtime: nodejs4.3 | ||
Policies: AmazonDynamoDBFullAccess | ||
Events: | ||
Basic: | ||
Type: HttpApi | ||
Properties: | ||
Path: /basic | ||
Method: post | ||
SimpleCase: | ||
Type: HttpApi | ||
|
||
HttpApiFunction2: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/todo_list.zip | ||
Handler: index.restapi | ||
Runtime: nodejs4.3 | ||
Policies: AmazonDynamoDBFullAccess | ||
Events: | ||
Basic2: | ||
Type: HttpApi | ||
Properties: | ||
Path: /basic2 | ||
Method: post |
Oops, something went wrong.