Skip to content

Commit 1e86a59

Browse files
authored
Revert "fix: Crash when using an invalid method in open api (#2001)"
This reverts commit d57b132.
1 parent d57b9ca commit 1e86a59

File tree

6 files changed

+2
-100
lines changed

6 files changed

+2
-100
lines changed

samtranslator/swagger/swagger.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -531,19 +531,6 @@ def set_path_default_authorizer(
531531
if add_default_auth_to_preflight or normalized_method_name != "options":
532532
normalized_method_name = self._normalize_method_name(method_name)
533533
# It is possible that the method could have two definitions in a Fn::If block.
534-
535-
# check for valid methods
536-
if normalized_method_name.upper() not in self._ALL_HTTP_METHODS:
537-
raise InvalidDocumentException(
538-
[
539-
InvalidTemplateException(
540-
"Path '{}' contains method '{}' which is not a supported method {}".format(
541-
path, method_name, self._ALL_HTTP_METHODS
542-
)
543-
)
544-
]
545-
)
546-
547534
for method_definition in self.get_method_contents(self.get_path(path)[normalized_method_name]):
548535

549536
# If no integration given, then we don't need to process this definition (could be AWS::NoValue)

tests/swagger/test_swagger.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,39 +1468,3 @@ def test_should_include_none_if_default_is_overwritte(self):
14681468

14691469
self.editor.add_auth_to_method("/cognito", "get", auth, self.api)
14701470
self.assertEqual([{"NONE": []}], self.editor.swagger["paths"]["/cognito"]["get"]["security"])
1471-
1472-
1473-
class TestSwaggerEditor_set_path_default_authorizer(TestCase):
1474-
def setUp(self):
1475-
self.api = api = {
1476-
"Auth": {
1477-
"Authorizers": {"MyOtherCognitoAuth": {}, "MyCognitoAuth": {}},
1478-
"DefaultAuthorizer": "MyCognitoAuth",
1479-
}
1480-
}
1481-
self.editor = SwaggerEditor(
1482-
{
1483-
"swagger": "2.0",
1484-
"paths": {
1485-
"/cognito": {
1486-
"nonMethod": {
1487-
"x-amazon-apigateway-integration": {
1488-
"httpMethod": "POST",
1489-
"type": "aws_proxy",
1490-
"uri": {
1491-
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFn.Arn}/invocations"
1492-
},
1493-
},
1494-
"security": [],
1495-
"responses": {},
1496-
}
1497-
}
1498-
},
1499-
}
1500-
)
1501-
1502-
def test_should_fail_when_path_methods_are_invalid(self):
1503-
with self.assertRaises(InvalidDocumentException):
1504-
self.editor.set_path_default_authorizer(
1505-
"/cognito", "MyCognitoAuth", {"MyOtherCognitoAuth": {}, "MyCognitoAuth": {}}
1506-
)

tests/translator/input/error_api_with_invalid_path_object.yaml

Lines changed: 0 additions & 47 deletions
This file was deleted.

tests/translator/input/error_invalid_method_definition.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Resources:
4242
description: Application domain
4343
type: string
4444
required: true
45-
options:
45+
tags:
4646
- InvalidMethodDefinition
4747
get:
4848
x-amazon-apigateway-integration:

tests/translator/output/error_api_with_invalid_path_object.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/translator/test_translator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ def test_transform_success(self, testcase, partition_with_region):
498498
], # Run all the above tests against each of the list of partitions to test against
499499
)
500500
)
501+
@pytest.mark.slow
501502
@patch(
502503
"samtranslator.plugins.application.serverless_app_plugin.ServerlessAppPlugin._sar_service_call",
503504
mock_sar_service_call,

0 commit comments

Comments
 (0)