Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Revert "fix: Crash when using an invalid method in open api" #2021

Merged
merged 1 commit into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions samtranslator/swagger/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,19 +531,6 @@ def set_path_default_authorizer(
if add_default_auth_to_preflight or normalized_method_name != "options":
normalized_method_name = self._normalize_method_name(method_name)
# It is possible that the method could have two definitions in a Fn::If block.

# check for valid methods
if normalized_method_name.upper() not in self._ALL_HTTP_METHODS:
raise InvalidDocumentException(
[
InvalidTemplateException(
"Path '{}' contains method '{}' which is not a supported method {}".format(
path, method_name, self._ALL_HTTP_METHODS
)
)
]
)

for method_definition in self.get_method_contents(self.get_path(path)[normalized_method_name]):

# If no integration given, then we don't need to process this definition (could be AWS::NoValue)
Expand Down
36 changes: 0 additions & 36 deletions tests/swagger/test_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,39 +1468,3 @@ def test_should_include_none_if_default_is_overwritte(self):

self.editor.add_auth_to_method("/cognito", "get", auth, self.api)
self.assertEqual([{"NONE": []}], self.editor.swagger["paths"]["/cognito"]["get"]["security"])


class TestSwaggerEditor_set_path_default_authorizer(TestCase):
def setUp(self):
self.api = api = {
"Auth": {
"Authorizers": {"MyOtherCognitoAuth": {}, "MyCognitoAuth": {}},
"DefaultAuthorizer": "MyCognitoAuth",
}
}
self.editor = SwaggerEditor(
{
"swagger": "2.0",
"paths": {
"/cognito": {
"nonMethod": {
"x-amazon-apigateway-integration": {
"httpMethod": "POST",
"type": "aws_proxy",
"uri": {
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFn.Arn}/invocations"
},
},
"security": [],
"responses": {},
}
}
},
}
)

def test_should_fail_when_path_methods_are_invalid(self):
with self.assertRaises(InvalidDocumentException):
self.editor.set_path_default_authorizer(
"/cognito", "MyCognitoAuth", {"MyOtherCognitoAuth": {}, "MyCognitoAuth": {}}
)
47 changes: 0 additions & 47 deletions tests/translator/input/error_api_with_invalid_path_object.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Resources:
description: Application domain
type: string
required: true
options:
tags:
- InvalidMethodDefinition
get:
x-amazon-apigateway-integration:
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions tests/translator/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ def test_transform_success(self, testcase, partition_with_region):
], # Run all the above tests against each of the list of partitions to test against
)
)
@pytest.mark.slow
@patch(
"samtranslator.plugins.application.serverless_app_plugin.ServerlessAppPlugin._sar_service_call",
mock_sar_service_call,
Expand Down