From 4e4ce5f9f109026cc0b794b9f7f8d89d30fc5598 Mon Sep 17 00:00:00 2001 From: cm-iwata <38879253+cm-iwata@users.noreply.github.com> Date: Wed, 15 Jul 2020 20:21:11 +0900 Subject: [PATCH] fix API Gateway:create_api_key return wrong status code (#3136) --- moto/apigateway/responses.py | 3 +-- tests/test_apigateway/test_apigateway.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/moto/apigateway/responses.py b/moto/apigateway/responses.py index 65a92276..93ea5d4f 100644 --- a/moto/apigateway/responses.py +++ b/moto/apigateway/responses.py @@ -454,11 +454,10 @@ class APIGatewayResponse(BaseResponse): error.message, error.error_type ), ) - + return 201, {}, json.dumps(apikey_response) elif self.method == "GET": apikeys_response = self.backend.get_apikeys() return 200, {}, json.dumps({"item": apikeys_response}) - return 200, {}, json.dumps(apikey_response) def apikey_individual(self, request, full_url, headers): self.setup_class(request, full_url, headers) diff --git a/tests/test_apigateway/test_apigateway.py b/tests/test_apigateway/test_apigateway.py index 210efd9f..756da76e 100644 --- a/tests/test_apigateway/test_apigateway.py +++ b/tests/test_apigateway/test_apigateway.py @@ -1846,6 +1846,7 @@ def test_create_api_key(): payload = {"value": apikey_value, "name": apikey_name} response = client.create_api_key(**payload) + response["ResponseMetadata"]["HTTPStatusCode"].should.equal(201) response["name"].should.equal(apikey_name) response["value"].should.equal(apikey_value) response["enabled"].should.equal(False)