Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tests): Adding any tests #2053

Merged
merged 6 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/translator/input/api_request_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ Resources:
RequestModel:
Model: User
Required: true
AnyPath:
Type: Api
Properties:
RestApiId: HtmlApi
Path: /any
Method: any
RequestModel:
Model: User
Required: true

HtmlApi:
Type: AWS::Serverless::Api
Expand Down
12 changes: 12 additions & 0 deletions tests/translator/input/api_request_model_openapi_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ Resources:
Path: /iam
Auth:
Authorizer: AWS_IAM
AnyIam:
Type: Api
Properties:
RequestModel:
Model: User
Required: true
RestApiId:
Ref: HtmlApi
Method: any
Path: /any/iam
Auth:
Authorizer: AWS_IAM


HtmlApi:
Expand Down
8 changes: 8 additions & 0 deletions tests/translator/input/api_with_apikey_required.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ Resources:
Method: get
Auth:
ApiKeyRequired: true
MyApiWithApiKeyRequiredAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithoutAuth
Path: /any/ApiKeyRequiredTrue
Method: any
Auth:
ApiKeyRequired: true
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ Resources:
Method: get
Auth:
ApiKeyRequired: true
MyApiWithApiKeyRequiredAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithoutAuth
Path: /any/ApiKeyRequiredTrue
Method: any
Auth:
ApiKeyRequired: true
52 changes: 49 additions & 3 deletions tests/translator/input/api_with_auth_all_maximum.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Resources:
Context:
- Authorization4
ReauthorizeEvery: 0

MyFunction:
Type: AWS::Serverless::Function
Properties:
Expand All @@ -66,6 +66,14 @@ Resources:
Method: get
Auth:
Authorizer: NONE
WithNoAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/noauth
Method: any
Auth:
Authorizer: NONE
WithCognitoMultipleUserPoolsAuthorizer:
Type: Api
Properties:
Expand All @@ -74,6 +82,14 @@ Resources:
Method: post
Auth:
Authorizer: MyCognitoAuthMultipleUserPools
WithCognitoMultipleUserPoolsAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/cognitomultiple
Method: any
Auth:
Authorizer: MyCognitoAuthMultipleUserPools
WithLambdaTokenAuthorizer:
Type: Api
Properties:
Expand All @@ -82,14 +98,30 @@ Resources:
Method: get
Auth:
Authorizer: MyLambdaTokenAuth
WithLambdaTokenAuthorizer:
WithLambdaTokenAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/lambdatoken
Method: any
Auth:
Authorizer: MyLambdaTokenAuth
WithLambdaTokenNoneAuthorizer:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /users
Method: patch
Auth:
Authorizer: MyLambdaTokenAuthNoneFunctionInvokeRole
WithLambdaTokenNoneAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/lambdatokennone
Method: any
Auth:
Authorizer: MyLambdaTokenAuthNoneFunctionInvokeRole
WithLambdaRequestAuthorizer:
Type: Api
Properties:
Expand All @@ -98,9 +130,23 @@ Resources:
Method: delete
Auth:
Authorizer: MyLambdaRequestAuth
WithLambdaRequestAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/lambdarequest
Method: any
Auth:
Authorizer: MyLambdaRequestAuth
WithDefaultAuthorizer:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /users
Method: put
Method: put
WithDefaultAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/default
Method: any
52 changes: 49 additions & 3 deletions tests/translator/input/api_with_auth_all_maximum_openapi_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Resources:
Context:
- Authorization4
ReauthorizeEvery: 0

MyFunction:
Type: AWS::Serverless::Function
Properties:
Expand All @@ -67,6 +67,14 @@ Resources:
Method: get
Auth:
Authorizer: NONE
WithNoAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/noauth
Method: any
Auth:
Authorizer: NONE
WithCognitoMultipleUserPoolsAuthorizer:
Type: Api
Properties:
Expand All @@ -75,6 +83,14 @@ Resources:
Method: post
Auth:
Authorizer: MyCognitoAuthMultipleUserPools
WithCognitoMultipleUserPoolsAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/cognitomultiple
Method: any
Auth:
Authorizer: MyCognitoAuthMultipleUserPools
WithLambdaTokenAuthorizer:
Type: Api
Properties:
Expand All @@ -83,14 +99,30 @@ Resources:
Method: get
Auth:
Authorizer: MyLambdaTokenAuth
WithLambdaTokenAuthorizer:
WithLambdaTokenAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/lambdatoken
Method: any
Auth:
Authorizer: MyLambdaTokenAuth
WithLambdaTokenNoneAuthorizer:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /users
Method: patch
Auth:
Authorizer: MyLambdaTokenAuthNoneFunctionInvokeRole
WithLambdaTokenNoneAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/lambdatokennone
Method: any
Auth:
Authorizer: MyLambdaTokenAuthNoneFunctionInvokeRole
WithLambdaRequestAuthorizer:
Type: Api
Properties:
Expand All @@ -99,9 +131,23 @@ Resources:
Method: delete
Auth:
Authorizer: MyLambdaRequestAuth
WithLambdaRequestAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/lambdarequest
Method: any
Auth:
Authorizer: MyLambdaRequestAuth
WithDefaultAuthorizer:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /users
Method: put
Method: put
WithDefaultAuthorizerAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /any/default
Method: any
18 changes: 18 additions & 0 deletions tests/translator/input/api_with_auth_all_minimum.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,36 @@ Resources:
RestApiId: !Ref MyApiWithCognitoAuth
Method: get
Path: /cognito
CognitoAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithCognitoAuth
Method: any
Path: /any/cognito
LambdaToken:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaTokenAuth
Method: get
Path: /lambda-token
LambdaTokenAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaTokenAuth
Method: any
Path: /any/lambda-token
LambdaRequest:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaRequestAuth
Method: get
Path: /lambda-request
LambdaRequestAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaRequestAuth
Method: any
Path: /any/lambda-request
MyUserPool:
Type: AWS::Cognito::UserPool
Properties:
Expand Down
18 changes: 18 additions & 0 deletions tests/translator/input/api_with_auth_all_minimum_openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,36 @@ Resources:
RestApiId: !Ref MyApiWithCognitoAuth
Method: get
Path: /cognito
CognitoAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithCognitoAuth
Method: any
Path: /any/cognito
LambdaToken:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaTokenAuth
Method: get
Path: /lambda-token
LambdaTokenAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaTokenAuth
Method: any
Path: /any/lambda-token
LambdaRequest:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaRequestAuth
Method: get
Path: /lambda-request
LambdaRequestAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaRequestAuth
Method: any
Path: /any/lambda-request
MyUserPool:
Type: AWS::Cognito::UserPool
Properties:
Expand Down
18 changes: 18 additions & 0 deletions tests/translator/input/api_with_auth_no_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,36 @@ Resources:
RestApiId: !Ref MyApiWithCognitoAuth
Method: get
Path: /cognito
CognitoAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithCognitoAuth
Method: any
Path: /any/cognito
LambdaToken:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaTokenAuth
Method: get
Path: /lambda-token
LambdaTokenAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaTokenAuth
Method: any
Path: /any/lambda-token
LambdaRequest:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaRequestAuth
Method: get
Path: /lambda-request
LambdaRequestAnyMethod:
Type: Api
Properties:
RestApiId: !Ref MyApiWithLambdaRequestAuth
Method: any
Path: /any/lambda-request
MyUserPool:
Type: AWS::Cognito::UserPool
Properties:
Expand Down
6 changes: 6 additions & 0 deletions tests/translator/input/api_with_aws_account_blacklist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ Resources:
Properties:
Method: Put
Path: /get
Any:
Type: Api
Properties:
Method: any
Path: /any

13 changes: 13 additions & 0 deletions tests/translator/input/api_with_aws_account_whitelist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,16 @@ Resources:
]
Method: Put
Path: /get
Any:
Type: Api
Properties:
Auth:
ResourcePolicy:
AwsAccountWhitelist: [
"12345"
]
AwsAccountBlacklist: [
"67890"
]
Method: any
Path: /any
Loading