Skip to content

Commit

Permalink
Release/v1.39.0 (#2165)
Browse files Browse the repository at this point in the history
* Release/v1.39.0 (#2141)

* chore: don't install integration tests (#1964)

* Remove unnecessary use of comprehension (#1805)

* fix: Grammatical error in README.md (#1965)

* fix: Added SAR Support Check (#1972)

* Added SAR Support Check

* Added docstring and Removed Instance Initialization for Class Method

* update pyyaml version to get the security update (#1974)

* fix the request parameter parsing, the value can contain dots (#1975)

* fix the request parameter parsing, the value can contain dots

* fix the unit test for python 2.7

* use built in split, instead of concatenating the string

* Documentation: fix incorrect header (#1979)

Fixed the incorrectly formatted header for HTTP API section

* fix: mutable default values in method definitions (#1997)

* fix: remove explicit logging level set in single module (#1998)

* fix: Fail when Intrinsics are in SourceVPC list instead of IntrinsicsSourceVPC (#1999)

* feat: Adding support for metric publishing. (#2062)

* Adding support for metric publishing, manually tested and tests pending.

* Adding make action for running test with html coverage.

* Adding unit tests for metrics.

* Writing integration tests for metrics publishing.

* Black reformatting

* Fixing unit test.

* Addressing PR comments.

* Clearing __init__py from test module.

* Updating documentation for publish method.

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Update AppConfig boto3 client config to shorten timeout (#2070)

* Update AppConfig boto3 client config to shorten timeout

* Update timeout config of AppConfig boto3 client

* feat: Add ValidateBody/ValidateParameters attribute to API models (#2026)

* Added validators to the swagger definitions when a model is required

* Remove approach of trying an extra field for validators

* WIP - tests deps not working

* Finished and fixed all tests to make pr command was complaining. Fixed case where a validator could have a / only and changed it to translate as 'root'

* py2.7 complaint

* Fix py2.7 order of validators on output folder

* WIP - adding validator fields

* Set another strategy to set the validators without affect existent clients with model required

* Set another strategy to set the validators without affect existent clients with model required

* Remove mistaken file pushed

* Remove mistaken file pushed

* Partial coments fixes

* Implemented case where we can set a only limited combinations on the specs

* Fix case test when multiple path are using same validator

* Added openapi3 specific tests

* Added openapi3 specific tests

* Fix requested changes from review: Renamed from ValidateRequest -> ValidateParameters also renamed everything from validator_request. Moved validators names according with the comum use.

* new approach to not cause KeyErrors

* Setting validator to the only given method not all methods on the path

* removed extra space on comment - lint

* Normalized method name path that comes from the template

Co-authored-by: Rondineli Gomes de Araujo <rgomesdearaujo@rgomesdearaujo-mbp.ad.shuttercorp.net>
Co-authored-by: Rondineli <rondineli.gomes.araujo@gmail.com>
Co-authored-by: Rondineli <rgomesdearaujo@yahoo.com.br>

* fix: fail with invalid resource, when RetentionPolicy has unresolved intrinsic value (#2074)

* fix: fail with invalid resource, when RetentionPolicy has unresolved intrinsic value

* make black

* remove extra formatting

* add test case for !ref

* test: Migration of combination integration tests (#1970)

* fix: Compare integration tests results using hash of file content instead of image compare (#2086)

* change yaml.load to yaml.safe_load for the security best practice

* use yaml_parse for consistant style

* remove pillow library for image comparing, use hash instead

* make it compatible with py2

* Remove logging of SAR service call response (#2064)

* Test CloudWatchEvent Properties With Intrinsic Functions (#2090)

* Add headers whenever cors is set

* Add cw event success cases

* Replace GetAtt with condition

* Cleanup test yaml

* Cleanup test yaml

* Remove files

* Add intrinsic to pattern field

* Fix wrong files committed

* test: Added intrinsic tests for Function SNS Event (#2101)

* fix: Validate Trigger field and test Cognito properties with intrinsic functions (#2092)

* Add headers whenever cors is set

* Fix Cognito trigger validation

* Make templates deployable

* Removed trigger value validation

* Fix Python2 string matching test issue

* Use PropertyType mechanism to exclude intrinsics

* Remove unused import

* feat(Intrinsic Tests): Added Tests for Kinesis Event Source with Intrinsics (#2103)

* Added Tests for Kinesis EventSource with Intrinsics

* Fixed Formatting with Black

* fix: Don't attempt to refetch a swagger method object by its name as we already have it (#2031)

* Fix a bad logic where a hash key is modified then refetched which results in KeyError

* add unit tests and update other instance of same usage on line 534

* fix: Fix the same code in open_api.py

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <grmathie@amazon.com>

* test: Adding intrinsic tests for Function S3 Event (#2100)

* fix(bug): Check if Identity.ReauthorizeEvery equals zero (#2105)

* Revert "Revert "Issue 1508 remove check requiring identity ... (#1577)" (#2038)"

This reverts commit ed3c283.

* Update implementation to support intrinsics/ add more tests to validate changes

* Fixing hashes for py2

* Run make black

* Handle pr feedback

* Add another unit tests to cover the original issue

Co-authored-by: Jacob Fuss <jfuss@users.noreply.github.com>

* chore: Update PR Checklist to include writing intrinsic tests (#2106)

* Update PR Checklist to include writing intrinsic tests

* Handle pr feedback

Co-authored-by: Jacob Fuss <jfuss@users.noreply.github.com>

* Delete .travis.yml (#2102)

* fix: Correct grammar in the waiting for changeset message (#2027)

* chore: bump version to 1.39.0 (#2128)

Co-authored-by: Chih-Hsuan Yen <yan12125@gmail.com>
Co-authored-by: Harsh Mishra <erbeusgriffincasper@gmail.com>
Co-authored-by: Pranav <54665036+Pranav016@users.noreply.github.com>
Co-authored-by: Cosh_ <CoshUS@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Ben <freiberg.ben@gmail.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Jacob Fuss <32497805+jfuss@users.noreply.github.com>
Co-authored-by: Tarun <c2tarun@users.noreply.github.com>
Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Co-authored-by: Rondineli <Rondineli@users.noreply.github.com>
Co-authored-by: Rondineli Gomes de Araujo <rgomesdearaujo@rgomesdearaujo-mbp.ad.shuttercorp.net>
Co-authored-by: Rondineli <rondineli.gomes.araujo@gmail.com>
Co-authored-by: Rondineli <rgomesdearaujo@yahoo.com.br>
Co-authored-by: mingkun2020 <68391979+mingkun2020@users.noreply.github.com>
Co-authored-by: Daniel Mil <84205762+mildaniel@users.noreply.github.com>
Co-authored-by: Ahmed Elbayaa <72949274+elbayaaa@users.noreply.github.com>
Co-authored-by: Jacob Fuss <jfuss@users.noreply.github.com>
Co-authored-by: Ichinose Shogo <shogo82148@gmail.com>
Co-authored-by: Ryan Parman <ryan@ryanparman.com>

* feat: ARM support (#2163)

* feat: ARM architecture support for Function and Layer

* Add docs/tests for Globals Architectures (#85)

Co-authored-by: Renato Valenzuela <37676028+valerena@users.noreply.github.com>

Co-authored-by: Chih-Hsuan Yen <yan12125@gmail.com>
Co-authored-by: Harsh Mishra <erbeusgriffincasper@gmail.com>
Co-authored-by: Pranav <54665036+Pranav016@users.noreply.github.com>
Co-authored-by: Cosh_ <CoshUS@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Ben <freiberg.ben@gmail.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Jacob Fuss <32497805+jfuss@users.noreply.github.com>
Co-authored-by: Tarun <c2tarun@users.noreply.github.com>
Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Co-authored-by: Rondineli <Rondineli@users.noreply.github.com>
Co-authored-by: Rondineli Gomes de Araujo <rgomesdearaujo@rgomesdearaujo-mbp.ad.shuttercorp.net>
Co-authored-by: Rondineli <rondineli.gomes.araujo@gmail.com>
Co-authored-by: Rondineli <rgomesdearaujo@yahoo.com.br>
Co-authored-by: mingkun2020 <68391979+mingkun2020@users.noreply.github.com>
Co-authored-by: Daniel Mil <84205762+mildaniel@users.noreply.github.com>
Co-authored-by: Ahmed Elbayaa <72949274+elbayaaa@users.noreply.github.com>
Co-authored-by: Jacob Fuss <jfuss@users.noreply.github.com>
Co-authored-by: Ichinose Shogo <shogo82148@gmail.com>
Co-authored-by: Ryan Parman <ryan@ryanparman.com>
Co-authored-by: Renato Valenzuela <37676028+valerena@users.noreply.github.com>
  • Loading branch information
23 people authored Sep 29, 2021
1 parent 4ef6093 commit 5d60204
Show file tree
Hide file tree
Showing 366 changed files with 19,420 additions and 1,289 deletions.
5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

*Checklist:*

- [ ] Write/update tests
- [ ] Add/update tests using:
- [ ] Correct values
- [ ] Bad/wrong values (None, empty, wrong type, length, etc.)
- [ ] [Intrinsic Functions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html)
- [ ] `make pr` passes
- [ ] Update documentation
- [ ] Verify transformed template deploys and application functions as expected
Expand Down
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ init:
test:
pytest --cov samtranslator --cov-report term-missing --cov-fail-under 95 tests/*

test-cov-report:
pytest --cov samtranslator --cov-report term-missing --cov-report html --cov-fail-under 95 tests/*

integ-test:
pytest --no-cov integration/*

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ environment that lets you locally build, test, debug, and deploy applications de

## What is this Github repository? 💻

This GitHub repository contains the SAM Specification, the Python code that translates SAM templates into AWS CloudFormation stacks and lots of examples applications.
This GitHub repository contains the SAM Specification, the Python code that translates SAM templates into AWS CloudFormation stacks and lots of example applications.
In the words of SAM developers:

> SAM Translator is the Python code that deploys SAM templates via AWS CloudFormation. Source code is high quality (95% unit test coverage),
Expand Down
1 change: 1 addition & 0 deletions docs/globals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Currently, the following resources and properties are being supported:
PermissionsBoundary:
ReservedConcurrentExecutions:
EventInvokeConfig:
Architectures:
Api:
# Properties of AWS::Serverless::Api
Expand Down
2 changes: 1 addition & 1 deletion docs/internals/generated_resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ AWS::Lambda::Permission MyFunction\ **ThumbnailApi**\ Permission\ **P
NOTE: ``ServerlessRestApi*`` resources are generated one per stack.

HTTP API
^^^
^^^^
This is called an "Implicit HTTP API". There can be many functions in the template that define these APIs. Behind the
scenes, SAM will collect all implicit HTTP APIs from all Functions in the template, generate an OpenApi doc, and create an
implicit ``AWS::Serverless::HttpApi`` using this OpenApi. This API defaults to a StageName called "$default" that cannot be
Expand Down
Empty file.
181 changes: 181 additions & 0 deletions integration/combination/test_api_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import hashlib

try:
from pathlib import Path
except ImportError:
from pathlib2 import Path

import requests
from parameterized import parameterized

from integration.helpers.base_test import BaseTest


class TestApiSettings(BaseTest):
def test_method_settings(self):
self.create_and_verify_stack("combination/api_with_method_settings")

rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi")
apigw_client = self.client_provider.api_client
response = apigw_client.get_stage(restApiId=rest_api_id, stageName="Prod")

wildcard_path = "*/*"

method_settings = response["methodSettings"]
self.assertTrue(wildcard_path in method_settings, "MethodSettings for the wildcard path must be present")

wildcard_path_setting = method_settings[wildcard_path]

self.assertTrue(wildcard_path_setting["metricsEnabled"], "Metrics must be enabled")
self.assertTrue(wildcard_path_setting["dataTraceEnabled"], "DataTrace must be enabled")
self.assertEqual(wildcard_path_setting["loggingLevel"], "INFO", "LoggingLevel must be INFO")

@parameterized.expand(
[
"combination/api_with_binary_media_types",
"combination/api_with_binary_media_types_with_definition_body",
]
)
def test_binary_media_types(self, file_name):
self.create_and_verify_stack(file_name, self.get_default_test_template_parameters())

rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi")
apigw_client = self.client_provider.api_client

response = apigw_client.get_rest_api(restApiId=rest_api_id)
self.assertEqual(set(response["binaryMediaTypes"]), {"image/jpg", "image/png", "image/gif"})

@parameterized.expand(
[
"combination/api_with_request_models",
"combination/api_with_request_models_openapi",
]
)
def test_request_models(self, file_name):
self.create_and_verify_stack(file_name)

rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi")
apigw_client = self.client_provider.api_client

response = apigw_client.get_models(restApiId=rest_api_id)
request_models = response["items"]

self.assertEqual(request_models[0]["name"], "user")
self.assertEqual(
request_models[0]["schema"],
'{\n "type" : "object",\n'
+ ' "properties" : {\n "username" : {\n "type" : "string"\n }\n'
+ " }\n}",
)

def test_request_parameters_open_api(self):
self.create_and_verify_stack("combination/api_with_request_parameters_openapi")

rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi")
apigw_client = self.client_provider.api_client

# Test if the request parameters got set on the method
resources_response = apigw_client.get_resources(restApiId=rest_api_id)
resources = resources_response["items"]

resource = get_resource_by_path(resources, "/one")
method = apigw_client.get_method(restApiId=rest_api_id, resourceId=resource["id"], httpMethod="GET")
expected = {"method.request.querystring.type": True}
self.assertEqual(expected, method["requestParameters"])

# Test that the method settings got applied on the method
stage_response = apigw_client.get_stage(restApiId=rest_api_id, stageName="Prod")
method_settings = stage_response["methodSettings"]

path = "one/GET"
self.assertTrue(path in method_settings, "MethodSettings for the path must be present")

path_settings = method_settings[path]
self.assertEqual(path_settings["cacheTtlInSeconds"], 15)
self.assertTrue(path_settings["cachingEnabled"], "Caching must be enabled")

def test_binary_media_types_with_definition_body_openapi(self):
parameters = self.get_default_test_template_parameters()
binary_media = {
"ParameterKey": "BinaryMediaCodeKey",
"ParameterValue": "binary-media.zip",
"UsePreviousValue": False,
"ResolvedValue": "string",
}
parameters.append(binary_media)

self.create_and_verify_stack("combination/api_with_binary_media_types_with_definition_body_openapi", parameters)

rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi")
apigw_client = self.client_provider.api_client

response = apigw_client.get_rest_api(restApiId=rest_api_id)
self.assertEqual(
set(response["binaryMediaTypes"]), {"image/jpg", "image/png", "image/gif", "application/octet-stream"}
)
base_url = self.get_stack_output("ApiUrl")["OutputValue"]
self.verify_binary_media_request(base_url + "none", 200)

@parameterized.expand(
[
"combination/api_with_endpoint_configuration",
"combination/api_with_endpoint_configuration_dict",
]
)
def test_end_point_configuration(self, file_name):
self.create_and_verify_stack(file_name, self.get_default_test_template_parameters())

rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi")
apigw_client = self.client_provider.api_client

response = apigw_client.get_rest_api(restApiId=rest_api_id)
endpoint_config = response["endpointConfiguration"]
self.assertEqual(endpoint_config["types"], ["REGIONAL"])

def test_implicit_api_settings(self):
self.create_and_verify_stack("combination/implicit_api_with_settings")

rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi")
apigw_client = self.client_provider.api_client

response = apigw_client.get_stage(restApiId=rest_api_id, stageName="Prod")

wildcard_path = "*/*"

method_settings = response["methodSettings"]
self.assertTrue(wildcard_path in method_settings, "MethodSettings for the wildcard path must be present")

wildcard_path_setting = method_settings[wildcard_path]

self.assertTrue(wildcard_path_setting["metricsEnabled"], "Metrics must be enabled")
self.assertTrue(wildcard_path_setting["dataTraceEnabled"], "DataTrace must be enabled")
self.assertEqual(wildcard_path_setting["loggingLevel"], "INFO", "LoggingLevel must be INFO")

response = apigw_client.get_rest_api(restApiId=rest_api_id)
endpoint_config = response["endpointConfiguration"]
self.assertEqual(endpoint_config["types"], ["REGIONAL"])
self.assertEqual(set(response["binaryMediaTypes"]), {"image/jpg", "image/png"})

def verify_binary_media_request(self, url, expected_status_code):
headers = {"accept": "image/png"}
response = requests.get(url, headers=headers)

status = response.status_code
expected_file_path = str(Path(self.code_dir, "AWS_logo_RGB.png"))

with open(expected_file_path, mode="rb") as file:
expected_file_content = file.read()
expected_hash = hashlib.sha1(expected_file_content).hexdigest()

if 200 <= status <= 299:
actual_hash = hashlib.sha1(response.content).hexdigest()
self.assertEqual(expected_hash, actual_hash)

self.assertEqual(status, expected_status_code, " must return HTTP " + str(expected_status_code))


def get_resource_by_path(resources, path):
for resource in resources:
if resource["path"] == path:
return resource
return None
Loading

0 comments on commit 5d60204

Please sign in to comment.