-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixing case when no allowed origin is passed. * Adding functional tests to verify proper error message. Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
102 additions
and
11 deletions.
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
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
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
80 changes: 80 additions & 0 deletions
80
tests/translator/input/error_api_with_cors_and_empty_allow_origin.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,80 @@ | ||
Globals: | ||
Api: | ||
Cors: { | ||
"Fn::Join": [",", ["www.amazon.com", "www.google.com"]] | ||
} | ||
|
||
Resources: | ||
ImplicitApiFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs12.x | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
Path: / | ||
Method: get | ||
AnyApi: | ||
Type: Api | ||
Properties: | ||
Path: /foo | ||
Method: any | ||
RestApiFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.handler | ||
Runtime: nodejs12.x | ||
GetHtmlFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.handler | ||
Runtime: nodejs12.x | ||
ExplicitApi: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: Prod | ||
DefinitionBody: { | ||
"info": { | ||
"version": "1.0", | ||
"title": { | ||
"Ref": "AWS::StackName" | ||
} | ||
}, | ||
"paths": { | ||
"/add": { | ||
"post": { | ||
"x-amazon-apigateway-integration": { | ||
"httpMethod": "POST", | ||
"type": "aws_proxy", | ||
"uri": { | ||
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RestApiFunction.Arn}/invocations" | ||
} | ||
}, | ||
"responses": {} | ||
} | ||
}, | ||
"/{proxy+}": { | ||
"x-amazon-apigateway-any-method": { | ||
"x-amazon-apigateway-integration": { | ||
"httpMethod": "POST", | ||
"type": "aws_proxy", | ||
"uri": { | ||
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations" | ||
} | ||
}, | ||
"responses": {} | ||
} | ||
} | ||
}, | ||
"swagger": "2.0" | ||
} | ||
Cors: | ||
AllowMethods: "methods" | ||
AllowHeaders: "headers" | ||
AllowOrigin: "" | ||
AllowCredentials: true |
8 changes: 8 additions & 0 deletions
8
tests/translator/output/error_api_with_cors_and_empty_allow_origin.json
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,8 @@ | ||
{ | ||
"errors": [ | ||
{ | ||
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ExplicitApi] is invalid. Structure of the SAM template is invalid. Invalid input. Value for AllowedOrigins is required" | ||
} | ||
], | ||
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ExplicitApi] is invalid. Structure of the SAM template is invalid. Invalid input. Value for AllowedOrigins is required" | ||
} |