basic implementation of update rest api (#3951)
* basic implementation of update rest api * basic implementation of update rest api * basic implementation of update rest api * review comments from bblommers Co-authored-by: rajinder saini <rajinder.saini@c02vt5k2htd6.corp.climate.com>
This commit is contained in:
parent
290f6585c2
commit
fbbc8fc472
4 changed files with 148 additions and 29 deletions
|
|
@ -31,13 +31,71 @@ def test_create_and_get_rest_api():
|
|||
"id": api_id,
|
||||
"name": "my_api",
|
||||
"description": "this is my api",
|
||||
"version": "V1",
|
||||
"binaryMediaTypes": [],
|
||||
"apiKeySource": "HEADER",
|
||||
"endpointConfiguration": {"types": ["EDGE"]},
|
||||
"tags": {},
|
||||
"disableExecuteApiEndpoint": False,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
def test_upate_rest_api():
|
||||
client = boto3.client("apigateway", region_name="us-west-2")
|
||||
response = client.create_rest_api(name="my_api", description="this is my api")
|
||||
api_id = response["id"]
|
||||
patchOperations = [
|
||||
{"op": "replace", "path": "/name", "value": "new-name"},
|
||||
{"op": "replace", "path": "/description", "value": "new-description"},
|
||||
{"op": "replace", "path": "/apiKeySource", "value": "AUTHORIZER"},
|
||||
{"op": "replace", "path": "/binaryMediaTypes", "value": "image/jpeg"},
|
||||
{"op": "replace", "path": "/disableExecuteApiEndpoint", "value": "True"},
|
||||
]
|
||||
|
||||
response = client.update_rest_api(restApiId=api_id, patchOperations=patchOperations)
|
||||
response.pop("ResponseMetadata")
|
||||
response.pop("createdDate")
|
||||
response.pop("binaryMediaTypes")
|
||||
response.should.equal(
|
||||
{
|
||||
"id": api_id,
|
||||
"name": "new-name",
|
||||
"version": "V1",
|
||||
"description": "new-description",
|
||||
"apiKeySource": "AUTHORIZER",
|
||||
"endpointConfiguration": {"types": ["EDGE"]},
|
||||
"tags": {},
|
||||
"disableExecuteApiEndpoint": True,
|
||||
}
|
||||
)
|
||||
# should fail with wrong apikeysoruce
|
||||
patchOperations = [
|
||||
{"op": "replace", "path": "/apiKeySource", "value": "Wrong-value-AUTHORIZER"}
|
||||
]
|
||||
with pytest.raises(ClientError) as ex:
|
||||
response = client.update_rest_api(
|
||||
restApiId=api_id, patchOperations=patchOperations
|
||||
)
|
||||
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"1 validation error detected: Value 'Wrong-value-AUTHORIZER' at 'createRestApiInput.apiKeySource' failed to satisfy constraint: Member must satisfy enum value set: [AUTHORIZER, HEADER]"
|
||||
)
|
||||
ex.value.response["Error"]["Code"].should.equal("ValidationException")
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
def test_upate_rest_api_invalid_api_id():
|
||||
client = boto3.client("apigateway", region_name="us-west-2")
|
||||
patchOperations = [
|
||||
{"op": "replace", "path": "/apiKeySource", "value": "AUTHORIZER"}
|
||||
]
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.update_rest_api(restApiId="api_id", patchOperations=patchOperations)
|
||||
ex.value.response["Error"]["Code"].should.equal("NotFoundException")
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
def test_list_and_delete_apis():
|
||||
client = boto3.client("apigateway", region_name="us-west-2")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue