Skip to content

Commit

Permalink
Adding functional tests to verify proper error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarun Mall committed Nov 2, 2021
1 parent 4c83783 commit 5c2fbbb
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
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
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"
}

0 comments on commit 5c2fbbb

Please sign in to comment.