From 0464b276fc525e4e7e657662439abd40076b1724 Mon Sep 17 00:00:00 2001 From: Shreya Date: Mon, 21 Oct 2019 11:49:48 -0700 Subject: [PATCH] Update aws-sam-translator Dependency (#1448) * Added test templates as a part of SAM 1.15.1 release * removed templates of application resource type and corrected the errors in sam template validator * removed the application resource yaml files * fix: set isolated.txt to have aws-sam-translator (1.15.1) * Bump start-api integ tests from 300 to 600 --- requirements/base.txt | 2 +- requirements/isolated.txt | 2 +- .../lib/models/all_policy_templates.yaml | 9 +- .../lib/models/api_request_model.yaml | 2 +- .../models/api_request_model_openapi_3.yaml | 2 +- .../api_with_apikey_default_override.yaml | 51 ++++++ .../lib/models/api_with_apikey_required.yaml | 21 +++ .../api_with_apikey_required_openapi_3.yaml | 22 +++ .../lib/models/api_with_auth_all_maximum.yaml | 1 + .../api_with_auth_all_maximum_openapi_3.yaml | 1 + .../api_with_aws_account_blacklist.yaml | 25 +++ .../api_with_aws_account_whitelist.yaml | 28 ++++ .../api_with_aws_iam_auth_overrides.yaml | 68 ++++++++ ...efault_aws_iam_auth_and_no_auth_route.yaml | 29 ++++ .../api_with_incompatible_stage_name.yaml | 56 +++++++ .../models/api_with_ip_range_blacklist.yaml | 26 +++ .../models/api_with_ip_range_whitelist.yaml | 26 +++ .../lib/models/api_with_open_api_version.yaml | 2 +- .../lib/models/api_with_path_parameters.yaml | 20 +++ .../lib/models/api_with_resource_policy.yaml | 41 +++++ .../api_with_resource_policy_global.yaml | 59 +++++++ ..._with_resource_policy_global_implicit.yaml | 26 +++ .../models/api_with_source_vpc_blacklist.yaml | 26 +++ .../models/api_with_source_vpc_whitelist.yaml | 38 +++++ .../lib/models/api_with_stage_tags.yaml | 16 ++ .../cloudwatchevent_schedule_properties.yaml | 30 ++++ .../models/cognito_userpool_with_event.yaml | 25 +++ .../models/function_with_batch_window.yaml | 69 ++++++++ ...ction_with_conditional_managed_policy.yaml | 17 ++ ...ional_managed_policy_and_ref_no_value.yaml | 17 ++ ...tion_with_conditional_policy_template.yaml | 19 +++ ...onal_policy_template_and_ref_no_value.yaml | 18 ++ .../function_with_request_parameters.yaml | 40 +++++ ..._with_sns_event_source_all_parameters.yaml | 1 + .../validate/lib/models/globals_for_api.yaml | 1 + ...icit_api_with_auth_and_conditions_max.yaml | 4 +- .../commands/validate/lib/models/sns_sqs.yaml | 23 +++ .../lib/test_sam_template_validator.py | 36 ++++ .../local/start_api/test_start_api.py | 158 +++++++++--------- 39 files changed, 970 insertions(+), 87 deletions(-) create mode 100644 tests/functional/commands/validate/lib/models/api_with_apikey_default_override.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_apikey_required.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_apikey_required_openapi_3.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_aws_account_blacklist.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_aws_account_whitelist.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth_and_no_auth_route.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_incompatible_stage_name.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_ip_range_blacklist.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_ip_range_whitelist.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_path_parameters.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_resource_policy.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_resource_policy_global.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_resource_policy_global_implicit.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_source_vpc_blacklist.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_source_vpc_whitelist.yaml create mode 100644 tests/functional/commands/validate/lib/models/api_with_stage_tags.yaml create mode 100644 tests/functional/commands/validate/lib/models/cloudwatchevent_schedule_properties.yaml create mode 100644 tests/functional/commands/validate/lib/models/cognito_userpool_with_event.yaml create mode 100644 tests/functional/commands/validate/lib/models/function_with_batch_window.yaml create mode 100644 tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy.yaml create mode 100644 tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy_and_ref_no_value.yaml create mode 100644 tests/functional/commands/validate/lib/models/function_with_conditional_policy_template.yaml create mode 100644 tests/functional/commands/validate/lib/models/function_with_conditional_policy_template_and_ref_no_value.yaml create mode 100644 tests/functional/commands/validate/lib/models/function_with_request_parameters.yaml create mode 100644 tests/functional/commands/validate/lib/models/sns_sqs.yaml diff --git a/requirements/base.txt b/requirements/base.txt index dfec903526..39a0699fdf 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -6,7 +6,7 @@ Flask~=1.0.2 boto3~=1.9, >=1.9.56 PyYAML~=5.1 cookiecutter~=1.6.0 -aws-sam-translator==1.14.0 +aws-sam-translator==1.15.1 docker~=4.0 dateparser~=0.7 python-dateutil~=2.6 diff --git a/requirements/isolated.txt b/requirements/isolated.txt index 6feffbace0..0dbc04bb8e 100644 --- a/requirements/isolated.txt +++ b/requirements/isolated.txt @@ -1,7 +1,7 @@ arrow==0.15.2 attrs==19.1.0 aws-lambda-builders==0.5.0 -aws-sam-translator==1.14.0 +aws-sam-translator==1.15.1 binaryornot==0.4.4 boto3==1.9.228 botocore==1.12.228 diff --git a/tests/functional/commands/validate/lib/models/all_policy_templates.yaml b/tests/functional/commands/validate/lib/models/all_policy_templates.yaml index 2cca6996f8..47509c70ea 100644 --- a/tests/functional/commands/validate/lib/models/all_policy_templates.yaml +++ b/tests/functional/commands/validate/lib/models/all_policy_templates.yaml @@ -98,8 +98,7 @@ Resources: - CloudWatchDashboardPolicy: {} - - RekognitionFacesPolicy: - CollectionId: collection + - RekognitionFacesPolicy: {} - RekognitionLabelsPolicy: {} @@ -146,3 +145,9 @@ Resources: - StepFunctionsExecutionPolicy: StateMachineName: name + + - CodeCommitCrudPolicy: + RepositoryName: name + + - CodeCommitReadPolicy: + RepositoryName: name diff --git a/tests/functional/commands/validate/lib/models/api_request_model.yaml b/tests/functional/commands/validate/lib/models/api_request_model.yaml index b7b8ed768a..6acb575750 100644 --- a/tests/functional/commands/validate/lib/models/api_request_model.yaml +++ b/tests/functional/commands/validate/lib/models/api_request_model.yaml @@ -25,4 +25,4 @@ Resources: type: object properties: username: - type: string + type: string \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/api_request_model_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_request_model_openapi_3.yaml index 0394ca5153..38c2224504 100644 --- a/tests/functional/commands/validate/lib/models/api_request_model_openapi_3.yaml +++ b/tests/functional/commands/validate/lib/models/api_request_model_openapi_3.yaml @@ -33,7 +33,7 @@ Resources: Type: AWS::Serverless::Api Properties: StageName: Prod - OpenApiVersion: '3.0.1' + OpenApiVersion: 3.0 Models: User: type: object diff --git a/tests/functional/commands/validate/lib/models/api_with_apikey_default_override.yaml b/tests/functional/commands/validate/lib/models/api_with_apikey_default_override.yaml new file mode 100644 index 0000000000..53a94e3b62 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_apikey_default_override.yaml @@ -0,0 +1,51 @@ +Resources: + MyApiWithAuth: + Type: "AWS::Serverless::Api" + Properties: + StageName: Prod + Auth: + ApiKeyRequired: true + + MyFunctionWithApiKeyRequiredDefault: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + MyApiWithApiKeyRequiredDefault: + Type: Api + Properties: + RestApiId: !Ref MyApiWithAuth + Path: /ApiKeyDefault + Method: get + MyFunctionWithApiKeyRequiredTrue: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + MyApiWithApiKeyRequiredTrue: + Type: Api + Properties: + RestApiId: !Ref MyApiWithAuth + Path: /ApiKeyTrue + Method: get + Auth: + ApiKeyRequired: true + MyFunctionWithApiKeyRequiredFalse: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + MyApiWithApiKeyRequiredFalse: + Type: Api + Properties: + RestApiId: !Ref MyApiWithAuth + Path: /ApiKeyFalse + Method: get + Auth: + ApiKeyRequired: false diff --git a/tests/functional/commands/validate/lib/models/api_with_apikey_required.yaml b/tests/functional/commands/validate/lib/models/api_with_apikey_required.yaml new file mode 100644 index 0000000000..e5c562c916 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_apikey_required.yaml @@ -0,0 +1,21 @@ +Resources: + MyApiWithoutAuth: + Type: "AWS::Serverless::Api" + Properties: + StageName: Prod + + MyFunctionWithApiKeyRequired: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + MyApiWithApiKeyRequired: + Type: Api + Properties: + RestApiId: !Ref MyApiWithoutAuth + Path: /ApiKeyRequiredTrue + Method: get + Auth: + ApiKeyRequired: true diff --git a/tests/functional/commands/validate/lib/models/api_with_apikey_required_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_with_apikey_required_openapi_3.yaml new file mode 100644 index 0000000000..95d7727c58 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_apikey_required_openapi_3.yaml @@ -0,0 +1,22 @@ +Resources: + MyApiWithoutAuth: + Type: "AWS::Serverless::Api" + Properties: + StageName: Prod + OpenApiVersion: '3.0.1' + + MyFunctionWithApiKeyRequired: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + MyApiWithApiKeyRequired: + Type: Api + Properties: + RestApiId: !Ref MyApiWithoutAuth + Path: /ApiKeyRequiredTrue + Method: get + Auth: + ApiKeyRequired: true diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum.yaml index 89c94fdc7e..e3dbd397b3 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum.yaml @@ -5,6 +5,7 @@ Resources: StageName: Prod Auth: DefaultAuthorizer: MyCognitoAuth + ApiKeyRequired: true Authorizers: MyCognitoAuth: UserPoolArn: arn:aws:1 diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum_openapi_3.yaml index 8cab3cd48c..bb236464fe 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum_openapi_3.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum_openapi_3.yaml @@ -6,6 +6,7 @@ Resources: OpenApiVersion: '3.0.1' Auth: DefaultAuthorizer: MyCognitoAuth + ApiKeyRequired: true Authorizers: MyCognitoAuth: UserPoolArn: arn:aws:1 diff --git a/tests/functional/commands/validate/lib/models/api_with_aws_account_blacklist.yaml b/tests/functional/commands/validate/lib/models/api_with_aws_account_blacklist.yaml new file mode 100644 index 0000000000..7d64715887 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_aws_account_blacklist.yaml @@ -0,0 +1,25 @@ +Globals: + Api: + Auth: + ResourcePolicy: + AwsAccountBlacklist: ['12345'] +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + InlineCode: | + exports.handler = async (event) => { + const response = { + statusCode: 200, + body: JSON.stringify('Hello from Lambda!'), + }; + return response; + }; + Handler: index.handler + Runtime: nodejs8.10 + Events: + Api: + Type: Api + Properties: + Method: Put + Path: /get diff --git a/tests/functional/commands/validate/lib/models/api_with_aws_account_whitelist.yaml b/tests/functional/commands/validate/lib/models/api_with_aws_account_whitelist.yaml new file mode 100644 index 0000000000..09c57d5e0d --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_aws_account_whitelist.yaml @@ -0,0 +1,28 @@ +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + InlineCode: | + exports.handler = async (event) => { + const response = { + statusCode: 200, + body: JSON.stringify('Hello from Lambda!'), + }; + return response; + }; + Handler: index.handler + Runtime: nodejs8.10 + Events: + Api: + Type: Api + Properties: + Auth: + ResourcePolicy: + AwsAccountWhitelist: [ + "12345" + ] + AwsAccountBlacklist: [ + "67890" + ] + Method: Put + Path: /get diff --git a/tests/functional/commands/validate/lib/models/api_with_aws_iam_auth_overrides.yaml b/tests/functional/commands/validate/lib/models/api_with_aws_iam_auth_overrides.yaml index f9cd47765a..5ce61f7924 100644 --- a/tests/functional/commands/validate/lib/models/api_with_aws_iam_auth_overrides.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_aws_iam_auth_overrides.yaml @@ -1,4 +1,11 @@ Resources: + MyApiWithAwsIamAuthNoCallerCredentials: + Type: "AWS::Serverless::Api" + Properties: + StageName: Prod + Auth: + DefaultAuthorizer: AWS_IAM + InvokeRole: NONE MyApiWithAwsIamAuth: Type: "AWS::Serverless::Api" Properties: @@ -84,3 +91,64 @@ Resources: Auth: Authorizer: AWS_IAM InvokeRole: arn:aws:iam::456::role/something-else + MyFunctionNONEInvokeRole: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + API3: + Type: Api + Properties: + RestApiId: !Ref MyApiWithAwsIamAuth + Method: get + Path: /MyFunctionNONEInvokeRole + Auth: + Authorizer: AWS_IAM + InvokeRole: NONE + MyFunctionNullInvokeRole: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + API3: + Type: Api + Properties: + RestApiId: !Ref MyApiWithAwsIamAuth + Method: get + Path: /MyFunctionNullInvokeRole + Auth: + Authorizer: AWS_IAM + InvokeRole: null + MyFunctionCallerCredentialsOverride: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + API3: + Type: Api + Properties: + RestApiId: !Ref MyApiWithAwsIamAuthNoCallerCredentials + Method: get + Path: / + Auth: + Authorizer: AWS_IAM + InvokeRole: CALLER_CREDENTIALS + MyFunctionNoCallerCredentials: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + API3: + Type: Api + Properties: + RestApiId: !Ref MyApiWithAwsIamAuthNoCallerCredentials + Method: post + Path: / diff --git a/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth_and_no_auth_route.yaml b/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth_and_no_auth_route.yaml new file mode 100644 index 0000000000..f777d20087 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth_and_no_auth_route.yaml @@ -0,0 +1,29 @@ +Resources: + MyApiWithAwsIamAuth: + Type: "AWS::Serverless::Api" + Properties: + StageName: Prod + Auth: + DefaultAuthorizer: AWS_IAM + + MyFunctionWithAwsIamAuth: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://bucket/key + Handler: index.handler + Runtime: nodejs8.10 + Events: + MyApiWithAwsIamAuth: + Type: Api + Properties: + RestApiId: !Ref MyApiWithAwsIamAuth + Path: / + Method: post + MyApiWithNoAuth: + Type: Api + Properties: + RestApiId: !Ref MyApiWithAwsIamAuth + Path: / + Method: get + Auth: + Authorizer: 'NONE' diff --git a/tests/functional/commands/validate/lib/models/api_with_incompatible_stage_name.yaml b/tests/functional/commands/validate/lib/models/api_with_incompatible_stage_name.yaml new file mode 100644 index 0000000000..e6905c3cfa --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_incompatible_stage_name.yaml @@ -0,0 +1,56 @@ +Resources: + HyphenFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/member_portal.zip + Handler: index.gethtml + Runtime: nodejs4.3 + Events: + GetHtml: + Type: Api + Properties: + RestApiId: HyphenApi + Path: / + Method: get + RequestModel: + Model: User + Required: true + + HyphenApi: + Type: AWS::Serverless::Api + Properties: + StageName: hoge-fuga + Models: + User: + type: object + properties: + username: + type: string + + UnderscoreFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/member_portal.zip + Handler: index.gethtml + Runtime: nodejs4.3 + Events: + GetHtml: + Type: Api + Properties: + RestApiId: UnderscoreApi + Path: / + Method: get + RequestModel: + Model: User + Required: true + + UnderscoreApi: + Type: AWS::Serverless::Api + Properties: + StageName: hoge_fuga + Models: + User: + type: object + properties: + username: + type: string \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/api_with_ip_range_blacklist.yaml b/tests/functional/commands/validate/lib/models/api_with_ip_range_blacklist.yaml new file mode 100644 index 0000000000..1e68425bce --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_ip_range_blacklist.yaml @@ -0,0 +1,26 @@ +Globals: + Api: + Auth: + ResourcePolicy: + IpRangeBlacklist: ['1.2.3.4'] + AwsAccountWhitelist: ['12345'] +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + InlineCode: | + exports.handler = async (event) => { + const response = { + statusCode: 200, + body: JSON.stringify('Hello from Lambda!'), + }; + return response; + }; + Handler: index.handler + Runtime: nodejs8.10 + Events: + Api: + Type: Api + Properties: + Method: Put + Path: /get diff --git a/tests/functional/commands/validate/lib/models/api_with_ip_range_whitelist.yaml b/tests/functional/commands/validate/lib/models/api_with_ip_range_whitelist.yaml new file mode 100644 index 0000000000..508fe7bf22 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_ip_range_whitelist.yaml @@ -0,0 +1,26 @@ +Globals: + Api: + Auth: + ResourcePolicy: + IpRangeWhitelist: ['1.2.3.4'] + IpRangeBlacklist: ['1.2.3.4'] +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + InlineCode: | + exports.handler = async (event) => { + const response = { + statusCode: 200, + body: JSON.stringify('Hello from Lambda!'), + }; + return response; + }; + Handler: index.handler + Runtime: nodejs8.10 + Events: + Api: + Type: Api + Properties: + Method: Put + Path: /get diff --git a/tests/functional/commands/validate/lib/models/api_with_open_api_version.yaml b/tests/functional/commands/validate/lib/models/api_with_open_api_version.yaml index dd91b26c9c..33d8c9e1ce 100644 --- a/tests/functional/commands/validate/lib/models/api_with_open_api_version.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_open_api_version.yaml @@ -1,6 +1,6 @@ Globals: Api: - OpenApiVersion: '3.0.1' + OpenApiVersion: 3.0.1 Cors: '*' Resources: diff --git a/tests/functional/commands/validate/lib/models/api_with_path_parameters.yaml b/tests/functional/commands/validate/lib/models/api_with_path_parameters.yaml new file mode 100644 index 0000000000..4e1b751051 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_path_parameters.yaml @@ -0,0 +1,20 @@ +Resources: + HtmlFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/member_portal.zip + Handler: index.gethtml + Runtime: nodejs4.3 + Events: + GetHtml: + Type: Api + Properties: + RestApiId: HtmlApi + Path: /{prameter}/resources + Method: get + + HtmlApi: + Type: AWS::Serverless::Api + Properties: + StageName: Prod + DefinitionUri: s3://sam-demo-bucket/webpage_swagger.json diff --git a/tests/functional/commands/validate/lib/models/api_with_resource_policy.yaml b/tests/functional/commands/validate/lib/models/api_with_resource_policy.yaml new file mode 100644 index 0000000000..becb35be9d --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_resource_policy.yaml @@ -0,0 +1,41 @@ +Resources: + ExplicitApi: + Type: AWS::Serverless::Api + Properties: + StageName: Prod + Auth: + ResourcePolicy: + CustomStatements: { + Action: 'execute-api:Invoke', + Resource: ['execute-api:/*/*/*'] + } + ExplicitApiFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/member_portal.zip + Handler: index.gethtml + Runtime: nodejs4.3 + Events: + GetHtml: + Type: Api + Properties: + RestApiId: + Ref: ExplicitApi + Path: /one + Method: get + PostHtml: + Type: Api + Properties: + RestApiId: + Ref: ExplicitApi + Path: /two + Method: post + PutHtml: + Type: Api + Properties: + RestApiId: + Ref: ExplicitApi + Path: /three + Method: put + + \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/api_with_resource_policy_global.yaml b/tests/functional/commands/validate/lib/models/api_with_resource_policy_global.yaml new file mode 100644 index 0000000000..acc834b916 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_resource_policy_global.yaml @@ -0,0 +1,59 @@ +Parameters: + StageName: + Type: String + Default: MyOwnStage +Globals: + Api: + Auth: + ResourcePolicy: + CustomStatements: [{ + Action: 'execute-api:Invoke', + Resource: ['execute-api:/*/*/*'] + }, + { + Action: 'execute-api:blah', + Resource: ['execute-api:/*/*/*'] + } + ] + IpRangeWhitelist: [ '1.2.3.4' ] +Resources: + ExplicitApiFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/member_portal.zip + Handler: index.gethtml + Runtime: nodejs4.3 + Events: + GetHtml: + Type: Api + Properties: + RestApiId: + Ref: ExplicitApi + Path: / + Method: get + + ExplicitApi: + Type: AWS::Serverless::Api + Properties: + StageName: !Ref StageName + DefinitionBody: + swagger: 2.0 + info: + version: '1.0' + title: !Ref AWS::StackName + paths: + "/": + get: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ExplicitApiFunction.Arn}/invocations + responses: {} + x-amazon-apigateway-policy: + Version: '2012-10-17' + Statement: + Action: 'sts:AssumeRole' + Effect: Allow + Principal: + Service: 'lambda.amazonaws.com' + diff --git a/tests/functional/commands/validate/lib/models/api_with_resource_policy_global_implicit.yaml b/tests/functional/commands/validate/lib/models/api_with_resource_policy_global_implicit.yaml new file mode 100644 index 0000000000..5ec9536e4b --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_resource_policy_global_implicit.yaml @@ -0,0 +1,26 @@ +Globals: + Api: + Auth: + ResourcePolicy: + CustomStatements: [{ + Action: 'execute-api:Invoke', + Resource: ['execute-api:/*/*/*'] + }, + { + Action: 'execute-api:blah', + Resource: ['execute-api:/*/*/*'] + }] +Resources: + MinimalFunction: + Type: 'AWS::Serverless::Function' + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python2.7 + Events: + AddItem: + Type: Api + Properties: + Path: /add + Method: post + diff --git a/tests/functional/commands/validate/lib/models/api_with_source_vpc_blacklist.yaml b/tests/functional/commands/validate/lib/models/api_with_source_vpc_blacklist.yaml new file mode 100644 index 0000000000..f8b4e00a5d --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_source_vpc_blacklist.yaml @@ -0,0 +1,26 @@ +Globals: + Api: + Auth: + ResourcePolicy: + SourceVpcBlacklist: ['vpce-3456'] +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + InlineCode: | + exports.handler = async (event) => { + const response = { + statusCode: 200, + body: JSON.stringify('Hello from Lambda!'), + }; + return response; + }; + Handler: index.handler + Runtime: nodejs8.10 + Events: + Api: + Type: Api + Properties: + Method: Put + Path: /get + diff --git a/tests/functional/commands/validate/lib/models/api_with_source_vpc_whitelist.yaml b/tests/functional/commands/validate/lib/models/api_with_source_vpc_whitelist.yaml new file mode 100644 index 0000000000..0c81b17f46 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_source_vpc_whitelist.yaml @@ -0,0 +1,38 @@ +Globals: + Api: + Auth: + ResourcePolicy: + SourceVpcWhitelist: ['vpc-1234'] + SourceVpcBlacklist: ['vpce-5678'] + +Resources: + MyFunction: + Type: AWS::Serverless::Function + Properties: + InlineCode: | + exports.handler = async (event) => { + const response = { + statusCode: 200, + body: JSON.stringify('Hello from Lambda!'), + }; + return response; + }; + Handler: index.handler + Runtime: nodejs8.10 + Events: + Api: + Type: Api + Properties: + Method: Put + Path: /get + Fetch: + Type: Api + Properties: + Method: Post + Path: /fetch + + MyApi: + Type: AWS::Serverless::Api + Properties: + StageName: Prod + diff --git a/tests/functional/commands/validate/lib/models/api_with_stage_tags.yaml b/tests/functional/commands/validate/lib/models/api_with_stage_tags.yaml new file mode 100644 index 0000000000..83473e1163 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_stage_tags.yaml @@ -0,0 +1,16 @@ +Parameters: + TagValueParam: + Type: String + Default: value + +Resources: + MyApiWithStageTags: + Type: "AWS::Serverless::Api" + Properties: + StageName: Prod + Tags: + TagKey1: TagValue1 + TagKey2: "" + TagKey3: + Ref: TagValueParam + TagKey4: "123" diff --git a/tests/functional/commands/validate/lib/models/cloudwatchevent_schedule_properties.yaml b/tests/functional/commands/validate/lib/models/cloudwatchevent_schedule_properties.yaml new file mode 100644 index 0000000000..72a6120347 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/cloudwatchevent_schedule_properties.yaml @@ -0,0 +1,30 @@ +Resources: + ScheduledFunction: + Type: 'AWS::Serverless::Function' + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO + Handler: hello.handler + Runtime: python2.7 + Events: + Schedule: + Type: Schedule + Properties: + Schedule: 'rate(1 minute)' + Name: test-schedule + Description: Test Schedule + Enabled: True + + TriggeredFunction: + Type: 'AWS::Serverless::Function' + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO + Handler: hello.handler + Runtime: python2.7 + Events: + OnTerminate: + Type: CloudWatchEvent + Properties: + Pattern: + detail: + state: + - terminated diff --git a/tests/functional/commands/validate/lib/models/cognito_userpool_with_event.yaml b/tests/functional/commands/validate/lib/models/cognito_userpool_with_event.yaml new file mode 100644 index 0000000000..bcd6b474ff --- /dev/null +++ b/tests/functional/commands/validate/lib/models/cognito_userpool_with_event.yaml @@ -0,0 +1,25 @@ +Resources: + UserPool: + Type: AWS::Cognito::UserPool + Properties: + LambdaConfig: + PreAuthentication: "Test" + ImplicitApiFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/member_portal.zip + Handler: index.gethtml + Runtime: nodejs4.3 + Events: + OneTrigger: + Type: Cognito + Properties: + UserPool: + Ref: UserPool + Trigger: PreSignUp + TwoTrigger: + Type: Cognito + Properties: + UserPool: + Ref: UserPool + Trigger: [Test1, Test2] \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/function_with_batch_window.yaml b/tests/functional/commands/validate/lib/models/function_with_batch_window.yaml new file mode 100644 index 0000000000..606734458b --- /dev/null +++ b/tests/functional/commands/validate/lib/models/function_with_batch_window.yaml @@ -0,0 +1,69 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: EventSourceMapping example with MaximumBatchingWindowInSeconds property + +Parameters: + MyBatchingWindowParam: + Type: Number + Default: 45 + Description: parameter for batching window in seconds + +Resources: + MyFunctionForBatchingExample: + Type: AWS::Serverless::Function + Properties: + Handler: index.handler + InlineCode: | + + exports.handler = async (event) => { + return { + statusCode: 200, + body: JSON.stringify(event), + headers: {} + } + } + Runtime: nodejs8.10 + Events: + Stream: + Type: Kinesis + Properties: + Stream: !GetAtt KinesisStream.Arn + MaximumBatchingWindowInSeconds: 20 + StartingPosition: LATEST + StreamEvent: + Type: Kinesis + Properties: + Stream: !GetAtt KinesisStream1.Arn + MaximumBatchingWindowInSeconds: !Ref MyBatchingWindowParam + StartingPosition: LATEST + DynamoDBStreamEvent: + Type: DynamoDB + Properties: + Stream: !GetAtt DynamoDBTable.StreamArn + BatchSize: 100 + MaximumBatchingWindowInSeconds: !Ref MyBatchingWindowParam + StartingPosition: TRIM_HORIZON + + KinesisStream: + Type: AWS::Kinesis::Stream + Properties: + ShardCount: 1 + + KinesisStream1: + Type: AWS::Kinesis::Stream + Properties: + ShardCount: 1 + DynamoDBTable: + Type: AWS::DynamoDB::Table + Properties: + AttributeDefinitions: + - AttributeName: id + AttributeType: S + KeySchema: + - AttributeName: id + KeyType: HASH + ProvisionedThroughput: + ReadCapacityUnits: 5 + WriteCapacityUnits: 5 + StreamSpecification: + StreamViewType: NEW_IMAGE \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy.yaml b/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy.yaml new file mode 100644 index 0000000000..6bfed9d071 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy.yaml @@ -0,0 +1,17 @@ +Conditions: + DummyCondition: + !Equals ["", ""] + +Resources: + FunctionWithConditionalPolicy: + Type: AWS::Serverless::Function + Properties: + Description: A function that has Fn::If in the policies property + Handler: hello.handler + Runtime: python2.7 + CodeUri: s3://sam-demo-bucket/hello.zip + Policies: + - !If + - DummyCondition + - !Sub arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess + - !Sub arn:${AWS::Partition}:iam::aws:policy/ReadOnlyAccess \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy_and_ref_no_value.yaml b/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy_and_ref_no_value.yaml new file mode 100644 index 0000000000..62f9528016 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy_and_ref_no_value.yaml @@ -0,0 +1,17 @@ +Conditions: + DummyCondition: + !Equals ["", ""] + +Resources: + FunctionWithConditionalPolicy: + Type: AWS::Serverless::Function + Properties: + Description: A function that has Fn::If in the policies property + Handler: hello.handler + Runtime: python2.7 + CodeUri: s3://sam-demo-bucket/hello.zip + Policies: + - !If + - DummyCondition + - !Sub arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess + - !Ref "AWS::NoValue" \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template.yaml b/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template.yaml new file mode 100644 index 0000000000..4b7a0b8fe9 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template.yaml @@ -0,0 +1,19 @@ +Conditions: + DummyCondition: + !Equals ["", ""] + +Resources: + FunctionWithConditionalPolicy: + Type: AWS::Serverless::Function + Properties: + Description: A function that has Fn::If in the policies property + Handler: hello.handler + Runtime: python2.7 + CodeUri: s3://sam-demo-bucket/hello.zip + Policies: + - !If + - DummyCondition + - AWSSecretsManagerGetSecretValuePolicy: + SecretArn: "Dummy Secret Arn" + - AWSSecretsManagerRotationPolicy: + FunctionName: "Dummy Function Name" \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template_and_ref_no_value.yaml b/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template_and_ref_no_value.yaml new file mode 100644 index 0000000000..432b4db2ab --- /dev/null +++ b/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template_and_ref_no_value.yaml @@ -0,0 +1,18 @@ +Conditions: + DummyCondition: + !Equals ["", ""] + +Resources: + FunctionWithConditionalPolicy: + Type: AWS::Serverless::Function + Properties: + Description: A function that has Fn::If in the policies property + Handler: hello.handler + Runtime: python2.7 + CodeUri: s3://sam-demo-bucket/hello.zip + Policies: + - !If + - DummyCondition + - AWSSecretsManagerGetSecretValuePolicy: + SecretArn: "Dummy Secret Arn" + - !Ref "AWS::NoValue" \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/function_with_request_parameters.yaml b/tests/functional/commands/validate/lib/models/function_with_request_parameters.yaml new file mode 100644 index 0000000000..ebc89f8937 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/function_with_request_parameters.yaml @@ -0,0 +1,40 @@ +Resources: + + Api: + Type: AWS::Serverless::Api + Properties: + StageName: Prod + + ApiParameterFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/member_portal.zip + Handler: index.gethtml + Runtime: nodejs4.3 + Events: + GetHtml: + Type: Api + Properties: + RestApiId: Api + Path: / + Method: get + RequestParameters: + - method.request.header.Authorization: + Required: true + Caching: true + + NoApiParameterFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/member_portal.zip + Handler: index.gethtml + Runtime: nodejs4.3 + Events: + GetHtml: + Type: Api + Properties: + Path: / + Method: get + RequestParameters: + - method.request.querystring.type + - method.request.path.id diff --git a/tests/functional/commands/validate/lib/models/function_with_sns_event_source_all_parameters.yaml b/tests/functional/commands/validate/lib/models/function_with_sns_event_source_all_parameters.yaml index a745b2f9c8..65711e7330 100644 --- a/tests/functional/commands/validate/lib/models/function_with_sns_event_source_all_parameters.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_sns_event_source_all_parameters.yaml @@ -11,6 +11,7 @@ Resources: Type: SNS Properties: Topic: topicArn + Region: region FilterPolicy: store: - example_corp diff --git a/tests/functional/commands/validate/lib/models/globals_for_api.yaml b/tests/functional/commands/validate/lib/models/globals_for_api.yaml index 5d3a956322..92aca3703e 100644 --- a/tests/functional/commands/validate/lib/models/globals_for_api.yaml +++ b/tests/functional/commands/validate/lib/models/globals_for_api.yaml @@ -8,6 +8,7 @@ Globals: Authorizers: MyCognitoAuth: UserPoolArn: !GetAtt MyUserPool.Arn + ApiKeyRequired: true Variables: SomeVar: Value diff --git a/tests/functional/commands/validate/lib/models/implicit_api_with_auth_and_conditions_max.yaml b/tests/functional/commands/validate/lib/models/implicit_api_with_auth_and_conditions_max.yaml index 61d2751a21..3c0ac05049 100644 --- a/tests/functional/commands/validate/lib/models/implicit_api_with_auth_and_conditions_max.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_api_with_auth_and_conditions_max.yaml @@ -161,4 +161,6 @@ Resources: Type: Api Properties: Path: /users - Method: put \ No newline at end of file + Method: put + Auth: + ApiKeyRequired: true \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/sns_sqs.yaml b/tests/functional/commands/validate/lib/models/sns_sqs.yaml new file mode 100644 index 0000000000..06f262fec5 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/sns_sqs.yaml @@ -0,0 +1,23 @@ +Resources: + SaveNotificationFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/notifications.zip + Handler: index.save_notification + Runtime: nodejs8.10 + Events: + NotificationTopic: + Type: SNS + Properties: + Topic: !Ref Notifications + SqsSubscription: true + FilterPolicy: + store: + - example_corp + price_usd: + - numeric: + - ">=" + - 100 + + Notifications: + Type: AWS::SNS::Topic diff --git a/tests/functional/commands/validate/lib/test_sam_template_validator.py b/tests/functional/commands/validate/lib/test_sam_template_validator.py index f24cd6f7e9..f421a0d4ec 100644 --- a/tests/functional/commands/validate/lib/test_sam_template_validator.py +++ b/tests/functional/commands/validate/lib/test_sam_template_validator.py @@ -19,12 +19,17 @@ class TestValidate(TestCase): ("tests/functional/commands/validate/lib/models/api_request_model.yaml"), ("tests/functional/commands/validate/lib/models/api_request_model_openapi_3.yaml"), ("tests/functional/commands/validate/lib/models/api_with_access_log_setting.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_apikey_default_override.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_apikey_required.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_apikey_required_openapi_3.yaml"), ("tests/functional/commands/validate/lib/models/api_with_auth_all_maximum.yaml"), ("tests/functional/commands/validate/lib/models/api_with_auth_all_maximum_openapi_3.yaml"), ("tests/functional/commands/validate/lib/models/api_with_auth_all_minimum.yaml"), ("tests/functional/commands/validate/lib/models/api_with_auth_all_minimum_openapi.yaml"), ("tests/functional/commands/validate/lib/models/api_with_auth_and_conditions_all_max.yaml"), ("tests/functional/commands/validate/lib/models/api_with_auth_no_default.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_aws_account_blacklist.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_aws_account_whitelist.yaml"), ("tests/functional/commands/validate/lib/models/api_with_aws_iam_auth_overrides.yaml"), ("tests/functional/commands/validate/lib/models/api_with_binary_media_types.yaml"), ("tests/functional/commands/validate/lib/models/api_with_binary_media_types_definition_body.yaml"), @@ -41,26 +46,40 @@ class TestValidate(TestCase): ("tests/functional/commands/validate/lib/models/api_with_cors_no_definitionbody.yaml"), ("tests/functional/commands/validate/lib/models/api_with_cors_openapi_3.yaml"), ("tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth_and_no_auth_route.yaml"), ("tests/functional/commands/validate/lib/models/api_with_gateway_responses.yaml"), ("tests/functional/commands/validate/lib/models/api_with_gateway_responses_all.yaml"), ("tests/functional/commands/validate/lib/models/api_with_gateway_responses_all_openapi_3.yaml"), ("tests/functional/commands/validate/lib/models/api_with_gateway_responses_implicit.yaml"), ("tests/functional/commands/validate/lib/models/api_with_gateway_responses_minimal.yaml"), ("tests/functional/commands/validate/lib/models/api_with_gateway_responses_string_status_code.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_incompatible_stage_name.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_ip_range_blacklist.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_ip_range_whitelist.yaml"), ("tests/functional/commands/validate/lib/models/api_with_method_aws_iam_auth.yaml"), ("tests/functional/commands/validate/lib/models/api_with_method_settings.yaml"), ("tests/functional/commands/validate/lib/models/api_with_minimum_compression_size.yaml"), ("tests/functional/commands/validate/lib/models/api_with_open_api_version.yaml"), ("tests/functional/commands/validate/lib/models/api_with_open_api_version_2.yaml"), ("tests/functional/commands/validate/lib/models/api_with_openapi_definition_body_no_flag.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_path_parameters.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_resource_policy.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_resource_policy_global.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_resource_policy_global_implicit.yaml"), ("tests/functional/commands/validate/lib/models/api_with_resource_refs.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_source_vpc_blacklist.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_source_vpc_whitelist.yaml"), + ("tests/functional/commands/validate/lib/models/api_with_stage_tags.yaml"), ("tests/functional/commands/validate/lib/models/api_with_swagger_and_openapi_with_auth.yaml"), ("tests/functional/commands/validate/lib/models/api_with_xray_tracing.yaml"), + ("tests/functional/commands/validate/lib/models/basic_function.yaml"), ("tests/functional/commands/validate/lib/models/basic_function_with_tags.yaml"), ("tests/functional/commands/validate/lib/models/basic_layer.yaml"), ("tests/functional/commands/validate/lib/models/cloudwatch_logs_with_ref.yaml"), ("tests/functional/commands/validate/lib/models/cloudwatchevent.yaml"), + ("tests/functional/commands/validate/lib/models/cloudwatchevent_schedule_properties.yaml"), ("tests/functional/commands/validate/lib/models/cloudwatchlog.yaml"), + ("tests/functional/commands/validate/lib/models/cognito_userpool_with_event.yaml"), ("tests/functional/commands/validate/lib/models/depends_on.yaml"), ("tests/functional/commands/validate/lib/models/explicit_api.yaml"), ("tests/functional/commands/validate/lib/models/explicit_api_openapi_3.yaml"), @@ -71,7 +90,16 @@ class TestValidate(TestCase): ("tests/functional/commands/validate/lib/models/function_with_alias.yaml"), ("tests/functional/commands/validate/lib/models/function_with_alias_and_event_sources.yaml"), ("tests/functional/commands/validate/lib/models/function_with_alias_intrinsics.yaml"), + ("tests/functional/commands/validate/lib/models/function_with_batch_window.yaml"), ("tests/functional/commands/validate/lib/models/function_with_condition.yaml"), + ("tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy.yaml"), + ( + "tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy_and_ref_no_value.yaml" + ), + ("tests/functional/commands/validate/lib/models/function_with_conditional_policy_template.yaml"), + ( + "tests/functional/commands/validate/lib/models/function_with_conditional_policy_template_and_ref_no_value.yaml" + ), ("tests/functional/commands/validate/lib/models/function_with_custom_codedeploy_deployment_preference.yaml"), ( "tests/functional/commands/validate/lib/models/function_with_custom_conditional_codedeploy_deployment_preference.yaml" @@ -91,6 +119,7 @@ class TestValidate(TestCase): ("tests/functional/commands/validate/lib/models/function_with_many_layers.yaml"), ("tests/functional/commands/validate/lib/models/function_with_permissions_boundary.yaml"), ("tests/functional/commands/validate/lib/models/function_with_policy_templates.yaml"), + ("tests/functional/commands/validate/lib/models/function_with_request_parameters.yaml"), ("tests/functional/commands/validate/lib/models/function_with_resource_refs.yaml"), ("tests/functional/commands/validate/lib/models/function_with_sns_event_source_all_parameters.yaml"), ("tests/functional/commands/validate/lib/models/global_handle_path_level_parameter.yaml"), @@ -124,10 +153,17 @@ class TestValidate(TestCase): ("tests/functional/commands/validate/lib/models/simpletable_with_sse.yaml"), ("tests/functional/commands/validate/lib/models/sns.yaml"), ("tests/functional/commands/validate/lib/models/sns_existing_other_subscription.yaml"), + ("tests/functional/commands/validate/lib/models/sns_sqs.yaml"), ("tests/functional/commands/validate/lib/models/sns_topic_outside_template.yaml"), ("tests/functional/commands/validate/lib/models/sqs.yaml"), ("tests/functional/commands/validate/lib/models/streams.yaml"), ("tests/functional/commands/validate/lib/models/unsupported_resources.yaml"), + ( + "tests/functional/commands/validate/lib/models/function_with_custom_conditional_codedeploy_deployment_preference.yaml" + ), + ( + "tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations.yaml" + ), ] def test_valid_template(self): diff --git a/tests/integration/local/start_api/test_start_api.py b/tests/integration/local/start_api/test_start_api.py index 01140d6c98..272600c90b 100644 --- a/tests/integration/local/start_api/test_start_api.py +++ b/tests/integration/local/start_api/test_start_api.py @@ -19,7 +19,7 @@ class TestParallelRequests(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_same_endpoint(self): """ Send two requests to the same path at the same time. This is to ensure we can handle @@ -44,7 +44,7 @@ def test_same_endpoint(self): self.assertEqual(result.status_code, 200) self.assertEqual(result.json(), {"message": "HelloWorld! I just slept and waking up."}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_different_endpoints(self): """ Send two requests to different paths at the same time. This is to ensure we can handle @@ -83,28 +83,28 @@ class TestServiceErrorResponses(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_invalid_http_verb_for_endpoint(self): response = requests.get(self.url + "/id") self.assertEqual(response.status_code, 403) self.assertEqual(response.json(), {"message": "Missing Authentication Token"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_invalid_response_from_lambda(self): response = requests.get(self.url + "/invalidresponsereturned") self.assertEqual(response.status_code, 502) self.assertEqual(response.json(), {"message": "Internal server error"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_invalid_json_response_from_lambda(self): response = requests.get(self.url + "/invalidresponsehash") self.assertEqual(response.status_code, 502) self.assertEqual(response.json(), {"message": "Internal server error"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_request_timeout(self): pass @@ -122,14 +122,14 @@ def setUp(self): def test_static_directory(self): pass - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_calling_proxy_endpoint(self): response = requests.get(self.url + "/proxypath/this/is/some/path") self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_get_call_with_path_setup_with_any_implicit_api(self): """ Get Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events @@ -139,7 +139,7 @@ def test_get_call_with_path_setup_with_any_implicit_api(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_post_call_with_path_setup_with_any_implicit_api(self): """ Post Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events @@ -149,7 +149,7 @@ def test_post_call_with_path_setup_with_any_implicit_api(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_put_call_with_path_setup_with_any_implicit_api(self): """ Put Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events @@ -159,7 +159,7 @@ def test_put_call_with_path_setup_with_any_implicit_api(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_head_call_with_path_setup_with_any_implicit_api(self): """ Head Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events @@ -168,7 +168,7 @@ def test_head_call_with_path_setup_with_any_implicit_api(self): self.assertEqual(response.status_code, 200) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_delete_call_with_path_setup_with_any_implicit_api(self): """ Delete Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events @@ -178,7 +178,7 @@ def test_delete_call_with_path_setup_with_any_implicit_api(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_options_call_with_path_setup_with_any_implicit_api(self): """ Options Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events @@ -187,7 +187,7 @@ def test_options_call_with_path_setup_with_any_implicit_api(self): self.assertEqual(response.status_code, 200) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_patch_call_with_path_setup_with_any_implicit_api(self): """ Patch Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events @@ -205,7 +205,7 @@ class TestStartApiWithSwaggerApis(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_get_call_with_path_setup_with_any_swagger(self): """ Get Request to a path that was defined as ANY in SAM through Swagger @@ -215,7 +215,7 @@ def test_get_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_post_call_with_path_setup_with_any_swagger(self): """ Post Request to a path that was defined as ANY in SAM through Swagger @@ -225,7 +225,7 @@ def test_post_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_put_call_with_path_setup_with_any_swagger(self): """ Put Request to a path that was defined as ANY in SAM through Swagger @@ -235,7 +235,7 @@ def test_put_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_head_call_with_path_setup_with_any_swagger(self): """ Head Request to a path that was defined as ANY in SAM through Swagger @@ -244,7 +244,7 @@ def test_head_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_delete_call_with_path_setup_with_any_swagger(self): """ Delete Request to a path that was defined as ANY in SAM through Swagger @@ -254,7 +254,7 @@ def test_delete_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_options_call_with_path_setup_with_any_swagger(self): """ Options Request to a path that was defined as ANY in SAM through Swagger @@ -263,7 +263,7 @@ def test_options_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_patch_call_with_path_setup_with_any_swagger(self): """ Patch Request to a path that was defined as ANY in SAM through Swagger @@ -273,28 +273,28 @@ def test_patch_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_function_not_defined_in_template(self): response = requests.get(self.url + "/nofunctionfound") self.assertEqual(response.status_code, 502) self.assertEqual(response.json(), {"message": "No function defined for resource method"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_function_with_no_api_event_is_reachable(self): response = requests.get(self.url + "/functionwithnoapievent") self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_lambda_function_resource_is_reachable(self): response = requests.get(self.url + "/nonserverlessfunction") self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_binary_request(self): """ This tests that the service can accept and invoke a lambda when given binary data in a request @@ -308,7 +308,7 @@ def test_binary_request(self): self.assertEqual(response.headers.get("Content-Type"), "image/gif") self.assertEqual(response.content, input_data) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_binary_response(self): """ Binary data is returned correctly @@ -329,7 +329,7 @@ class TestStartApiWithSwaggerRestApis(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_get_call_with_path_setup_with_any_swagger(self): """ Get Request to a path that was defined as ANY in SAM through Swagger @@ -339,7 +339,7 @@ def test_get_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_post_call_with_path_setup_with_any_swagger(self): """ Post Request to a path that was defined as ANY in SAM through Swagger @@ -349,7 +349,7 @@ def test_post_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_put_call_with_path_setup_with_any_swagger(self): """ Put Request to a path that was defined as ANY in SAM through Swagger @@ -359,7 +359,7 @@ def test_put_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_head_call_with_path_setup_with_any_swagger(self): """ Head Request to a path that was defined as ANY in SAM through Swagger @@ -368,7 +368,7 @@ def test_head_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_delete_call_with_path_setup_with_any_swagger(self): """ Delete Request to a path that was defined as ANY in SAM through Swagger @@ -378,7 +378,7 @@ def test_delete_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_options_call_with_path_setup_with_any_swagger(self): """ Options Request to a path that was defined as ANY in SAM through Swagger @@ -387,7 +387,7 @@ def test_options_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_patch_call_with_path_setup_with_any_swagger(self): """ Patch Request to a path that was defined as ANY in SAM through Swagger @@ -397,21 +397,21 @@ def test_patch_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_function_not_defined_in_template(self): response = requests.get(self.url + "/nofunctionfound") self.assertEqual(response.status_code, 502) self.assertEqual(response.json(), {"message": "No function defined for resource method"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_lambda_function_resource_is_reachable(self): response = requests.get(self.url + "/nonserverlessfunction") self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_binary_request(self): """ This tests that the service can accept and invoke a lambda when given binary data in a request @@ -425,7 +425,7 @@ def test_binary_request(self): self.assertEqual(response.headers.get("Content-Type"), "image/gif") self.assertEqual(response.content, input_data) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_binary_response(self): """ Binary data is returned correctly @@ -450,7 +450,7 @@ class TestServiceResponses(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_multiple_headers_response(self): response = requests.get(self.url + "/multipleheaders") @@ -458,7 +458,7 @@ def test_multiple_headers_response(self): self.assertEqual(response.headers.get("Content-Type"), "text/plain") self.assertEqual(response.headers.get("MyCustomHeader"), "Value1, Value2") - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_multiple_headers_overrides_headers_response(self): response = requests.get(self.url + "/multipleheadersoverridesheaders") @@ -466,7 +466,7 @@ def test_multiple_headers_overrides_headers_response(self): self.assertEqual(response.headers.get("Content-Type"), "text/plain") self.assertEqual(response.headers.get("MyCustomHeader"), "Value1, Value2, Custom") - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_binary_response(self): """ Binary data is returned correctly @@ -479,7 +479,7 @@ def test_binary_response(self): self.assertEqual(response.headers.get("Content-Type"), "image/gif") self.assertEqual(response.content, expected) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_default_header_content_type(self): """ Test that if no ContentType is given the default is "application/json" @@ -490,7 +490,7 @@ def test_default_header_content_type(self): self.assertEqual(response.content.decode("utf-8"), "no data") self.assertEqual(response.headers.get("Content-Type"), "application/json") - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_default_status_code(self): """ Test that if no status_code is given, the status code is 200 @@ -501,7 +501,7 @@ def test_default_status_code(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_string_status_code(self): """ Test that an integer-string can be returned as the status code @@ -510,7 +510,7 @@ def test_string_status_code(self): self.assertEqual(response.status_code, 200) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_default_body(self): """ Test that if no body is given, the response is 'no data' @@ -520,21 +520,21 @@ def test_default_body(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.content.decode("utf-8"), "no data") - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_function_writing_to_stdout(self): response = requests.get(self.url + "/writetostdout") self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_function_writing_to_stderr(self): response = requests.get(self.url + "/writetostderr") self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_integer_body(self): response = requests.get(self.url + "/echo_integer_body") @@ -553,7 +553,7 @@ class TestServiceRequests(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_binary_request(self): """ This tests that the service can accept and invoke a lambda when given binary data in a request @@ -567,7 +567,7 @@ def test_binary_request(self): self.assertEqual(response.headers.get("Content-Type"), "image/gif") self.assertEqual(response.content, input_data) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_request_with_form_data(self): """ Form-encoded data should be put into the Event to Lambda @@ -583,7 +583,7 @@ def test_request_with_form_data(self): self.assertEqual(response_data.get("headers").get("Content-Type"), "application/x-www-form-urlencoded") self.assertEqual(response_data.get("body"), "key=value") - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_request_to_an_endpoint_with_two_different_handlers(self): response = requests.get(self.url + "/echoeventbody") @@ -593,7 +593,7 @@ def test_request_to_an_endpoint_with_two_different_handlers(self): self.assertEqual(response_data.get("handler"), "echo_event_handler_2") - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_request_with_multi_value_headers(self): response = requests.get( self.url + "/echoeventbody", headers={"Content-Type": "application/x-www-form-urlencoded, image/gif"} @@ -608,7 +608,7 @@ def test_request_with_multi_value_headers(self): response_data.get("headers").get("Content-Type"), "application/x-www-form-urlencoded, image/gif" ) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_request_with_query_params(self): """ Query params given should be put into the Event to Lambda @@ -622,7 +622,7 @@ def test_request_with_query_params(self): self.assertEqual(response_data.get("queryStringParameters"), {"key": "value"}) self.assertEqual(response_data.get("multiValueQueryStringParameters"), {"key": ["value"]}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_request_with_list_of_query_params(self): """ Query params given should be put into the Event to Lambda @@ -636,7 +636,7 @@ def test_request_with_list_of_query_params(self): self.assertEqual(response_data.get("queryStringParameters"), {"key": "value2"}) self.assertEqual(response_data.get("multiValueQueryStringParameters"), {"key": ["value", "value2"]}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_request_with_path_params(self): """ Path Parameters given should be put into the Event to Lambda @@ -649,7 +649,7 @@ def test_request_with_path_params(self): self.assertEqual(response_data.get("pathParameters"), {"id": "4"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_request_with_many_path_params(self): """ Path Parameters given should be put into the Event to Lambda @@ -662,7 +662,7 @@ def test_request_with_many_path_params(self): self.assertEqual(response_data.get("pathParameters"), {"id": "4", "user": "jacob"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_forward_headers_are_added_to_event(self): """ Test the Forwarding Headers exist in the Api Event to Lambda @@ -687,7 +687,7 @@ class TestStartApiWithStage(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_default_stage_name(self): response = requests.get(self.url + "/echoeventbody") @@ -697,7 +697,7 @@ def test_default_stage_name(self): self.assertEqual(response_data.get("requestContext", {}).get("stage"), "Prod") - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_global_stage_variables(self): response = requests.get(self.url + "/echoeventbody") @@ -718,7 +718,7 @@ class TestStartApiWithStageAndSwagger(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_swagger_stage_name(self): response = requests.get(self.url + "/echoeventbody") @@ -727,7 +727,7 @@ def test_swagger_stage_name(self): response_data = response.json() self.assertEqual(response_data.get("requestContext", {}).get("stage"), "dev") - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_swagger_stage_variable(self): response = requests.get(self.url + "/echoeventbody") @@ -748,7 +748,7 @@ class TestServiceCorsSwaggerRequests(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_cors_swagger_options(self): """ This tests that the Cors are added to option requests in the swagger template @@ -773,7 +773,7 @@ class TestServiceCorsGlobalRequests(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_cors_global(self): """ This tests that the Cors are added to options requests when the global property is set @@ -786,7 +786,7 @@ def test_cors_global(self): self.assertEqual(response.headers.get("Access-Control-Allow-Methods"), ",".join(sorted(Route.ANY_HTTP_METHODS))) self.assertEqual(response.headers.get("Access-Control-Max-Age"), None) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_cors_global_get(self): """ This tests that the Cors are added to post requests when the global property is set @@ -812,7 +812,7 @@ class TestStartApiWithCloudFormationStage(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_default_stage_name(self): response = requests.get(self.url + "/echoeventbody") @@ -821,7 +821,7 @@ def test_default_stage_name(self): response_data = response.json() self.assertEqual(response_data.get("requestContext", {}).get("stage"), "Dev") - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_global_stage_variables(self): response = requests.get(self.url + "/echoeventbody") @@ -839,7 +839,7 @@ class TestStartApiWithMethodsAndResources(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_get_call_with_path_setup_with_any_swagger(self): """ Get Request to a path that was defined as ANY in SAM through Swagger @@ -849,7 +849,7 @@ def test_get_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_post_call_with_path_setup_with_any_swagger(self): """ Post Request to a path that was defined as ANY in SAM through Swagger @@ -859,7 +859,7 @@ def test_post_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_put_call_with_path_setup_with_any_swagger(self): """ Put Request to a path that was defined as ANY in SAM through Swagger @@ -869,7 +869,7 @@ def test_put_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_head_call_with_path_setup_with_any_swagger(self): """ Head Request to a path that was defined as ANY in SAM through Swagger @@ -878,7 +878,7 @@ def test_head_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_delete_call_with_path_setup_with_any_swagger(self): """ Delete Request to a path that was defined as ANY in SAM through Swagger @@ -888,7 +888,7 @@ def test_delete_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_options_call_with_path_setup_with_any_swagger(self): """ Options Request to a path that was defined as ANY in SAM through Swagger @@ -897,7 +897,7 @@ def test_options_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_patch_call_with_path_setup_with_any_swagger(self): """ Patch Request to a path that was defined as ANY in SAM through Swagger @@ -907,21 +907,21 @@ def test_patch_call_with_path_setup_with_any_swagger(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_function_not_defined_in_template(self): response = requests.get(self.url + "/root/nofunctionfound") self.assertEqual(response.status_code, 502) self.assertEqual(response.json(), {"message": "No function defined for resource method"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_lambda_function_resource_is_reachable(self): response = requests.get(self.url + "/root/nonserverlessfunction") self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), {"hello": "world"}) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_binary_request(self): """ This tests that the service can accept and invoke a lambda when given binary data in a request @@ -935,7 +935,7 @@ def test_binary_request(self): self.assertEqual(response.headers.get("Content-Type"), "image/gif") self.assertEqual(response.content, input_data) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_binary_response(self): """ Binary data is returned correctly @@ -948,7 +948,7 @@ def test_binary_response(self): self.assertEqual(response.headers.get("Content-Type"), "image/gif") self.assertEqual(response.content, expected) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_proxy_response(self): """ Binary data is returned correctly @@ -965,7 +965,7 @@ class TestCDKApiGateway(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_get_with_cdk(self): """ Get Request to a path that was defined as ANY in SAM through Swagger @@ -982,7 +982,7 @@ class TestServerlessApiGateway(StartApiIntegBaseClass): def setUp(self): self.url = "http://127.0.0.1:{}".format(self.port) - @pytest.mark.timeout(timeout=300, method="thread") + @pytest.mark.timeout(timeout=600, method="thread") def test_get_with_serverless(self): """ Get Request to a path that was defined as ANY in SAM through Swagger