Fix: Api-Gateway ApiKeyAlreadyExists headers change. (#3162)
* Fix: Api-Gateway ApiKeyAlreadyExists headers change. * Added test for non decorator * Fixed cli errors * Fix:fixed build errors * Fix: assert only in case of non server mode Co-authored-by: usmankb <usman@krazybee.com>
This commit is contained in:
parent
0a89f9d1df
commit
bcf61d0b09
@ -449,7 +449,7 @@ class APIGatewayResponse(BaseResponse):
|
|||||||
except ApiKeyAlreadyExists as error:
|
except ApiKeyAlreadyExists as error:
|
||||||
return (
|
return (
|
||||||
error.code,
|
error.code,
|
||||||
self.headers,
|
{},
|
||||||
'{{"message":"{0}","code":"{1}"}}'.format(
|
'{{"message":"{0}","code":"{1}"}}'.format(
|
||||||
error.message, error.error_type
|
error.message, error.error_type
|
||||||
),
|
),
|
||||||
|
@ -1858,6 +1858,23 @@ def test_create_api_key():
|
|||||||
client.create_api_key.when.called_with(**payload).should.throw(ClientError)
|
client.create_api_key.when.called_with(**payload).should.throw(ClientError)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_apigateway
|
||||||
|
def test_create_api_headers():
|
||||||
|
region_name = "us-west-2"
|
||||||
|
client = boto3.client("apigateway", region_name=region_name)
|
||||||
|
|
||||||
|
apikey_value = "12345"
|
||||||
|
apikey_name = "TESTKEY1"
|
||||||
|
payload = {"value": apikey_value, "name": apikey_name}
|
||||||
|
|
||||||
|
client.create_api_key(**payload)
|
||||||
|
with assert_raises(ClientError) as ex:
|
||||||
|
client.create_api_key(**payload)
|
||||||
|
ex.exception.response["Error"]["Code"].should.equal("ConflictException")
|
||||||
|
if not settings.TEST_SERVER_MODE:
|
||||||
|
ex.exception.response["ResponseMetadata"]["HTTPHeaders"].should.equal({})
|
||||||
|
|
||||||
|
|
||||||
@mock_apigateway
|
@mock_apigateway
|
||||||
def test_api_keys():
|
def test_api_keys():
|
||||||
region_name = "us-west-2"
|
region_name = "us-west-2"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user