Skip to content

Commit b1b3a9c

Browse files
authored
tests: add test for DefaultAuthorizers not a string in API (#2313)
In issue #1245, we had a cases were SAM would fail due to improper validation. In updating #1286, I noticed this was patched in #1774 but we only added tests for AWS::Serverless::StateMachine. This commit adds an additional test to cover AWS::Serverless::Api. Co-authored-by: Jacob Fuss <[email protected]>
1 parent 521abe3 commit b1b3a9c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Transform: "AWS::Serverless-2016-10-31"
3+
4+
Resources:
5+
MyApi:
6+
Type: "AWS::Serverless::Api"
7+
Properties:
8+
StageName: Prod
9+
Auth:
10+
DefaultAuthorizer: !Ref MyCognitoAuth
11+
Authorizers:
12+
MyCognitoAuth:
13+
UserPoolArn: arn:aws:1
14+
Identity:
15+
Header: MyAuthorizationHeader
16+
ValidationExpression: myauthvalidationexpression
17+
18+
MyFunction:
19+
Type: AWS::Serverless::Function
20+
Properties:
21+
CodeUri: s3://sam-demo-bucket/thumbnails.zip
22+
Handler: index.handler
23+
Runtime: nodejs8.10
24+
Events:
25+
Api:
26+
Type: Api
27+
Properties:
28+
RestApiId: !Ref MyApi
29+
Path: /
30+
Method: get
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MyApi] is invalid. DefaultAuthorizer is not a string."
3+
}

0 commit comments

Comments
 (0)