8000 fix apigateway patch deployment model (#6699) · localstack/localstack@035a3bb · GitHub
[go: up one dir, main page]

Skip to content

Commit 035a3bb

Browse files
authored
fix apigateway patch deployment model (#6699)
1 parent b6e28e2 commit 035a3bb

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

localstack/services/apigateway/patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def apigateway_models_RestAPI_to_dict(self):
432432

433433
def individual_deployment(self, request, full_url, headers, *args, **kwargs):
434434
result = individual_deployment_orig(self, request, full_url, headers, *args, **kwargs)
435-
if self.method == "PATCH" and len(result) >= 3 and result[2] in ["null", None, str(None)]:
435+
if self.method == "PATCH":
436436
url_path_parts = self.path.split("/")
437437
function_id = url_path_parts[2]
438438
deployment_id = url_path_parts[4]

tests/integration/apigateway_fixtures.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ def create_base_path_mapping(apigateway_client, **kwargs):
124124
def create_rest_api_deployment(apigateway_client, **kwargs):
125125
response = apigateway_client.create_deployment(**kwargs)
126126
assert_response_is_200(response)
127+
return response.get("id"), response.get("createdDate")
128+
129+
130+
def update_rest_api_deployment(apigateway_client, **kwargs):
131+
response = apigateway_client.update_deployment(**kwargs)
132+
assert_response_is_200(response)
133+
return response
127134

128135

129136
def create_cognito_user_pool(cognito_idp, **kwargs):

tests/integration/test_apigateway.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@
4646
_client,
4747
api_invoke_url,
4848
create_rest_api,
49+
create_rest_api_deployment,
4950
create_rest_api_integration,
5051
create_rest_api_integration_response,
5152
create_rest_api_method_response,
5253
create_rest_resource,
5354
create_rest_resource_method,
5455
delete_rest_api,
56+
update_rest_api_deployment,
5557
)
5658
from tests.integration.awslambda.test_lambda_integration import TEST_STAGE_NAME
5759

@@ -294,6 +296,48 @@ def test_api_gateway_sqs_integration(self):
294296
assert 1 == len(messages)
295297
assert test_data == json.loads(base64.b64decode(messages[0]["Body"]))
296298

299+
def test_update_rest_api_deployment(self, apigateway_client):
300+
api_id, _, root = create_rest_api(apigateway_client, name="aws lambda api")
301+
302+
create_rest_resource_method(
303+
apigateway_client,
304+
restApiId=api_id,
305+
resourceId=root,
306+
httpMethod="GET",
307+
authorizationType="none",
308+
)
309+
310+
create_rest_api_integration(
311+
apigateway_client,
312+
restApiId=api_id,
313+
resourceId=root,
314+
httpMethod="GET",
315+
type="HTTP",
316+
uri="http://httpbin.org/robots.txt",
317+
integrationHttpMethod="POST",
318+
)
319+
create_rest_api_integration_response(
320+
apigateway_client,
321+
restApiId=api_id,
322+
resourceId=root,
323+
httpMethod="GET",
324+
statusCode="200",
325+
selectionPattern="foobar",
326+
responseTemplates={},
327+
)
328+
329+
deployment_id, _ = create_rest_api_deployment(
330+
apigateway_client, restApiId=api_id, description="my deployment"
331+
)
332+
patch_operations = [{"op": "replace", "path": "/description", "value": "new-description"}]
333+
deployment = update_rest_api_deployment(
334+
apigateway_client,
335+
restApiId=api_id,
336+
deploymentId=deployment_id,
337+
patchOperations=patch_operations,
338+
)
339+
assert deployment["description"] == "new-description"
340+
297341
def test_api_gateway_lambda_integration(self, apigateway_client, create_lambda_function):
298342
"""
299343
API gateway to lambda integration test returns a response with the same body as the lambda function input.

0 commit comments

Comments
 (0)
0