Update ImplementationCoverage for APIGateway (#3733)

This commit is contained in:
Bert Blommers 2021-02-26 18:48:05 +00:00 committed by GitHub
parent 62f5adddc4
commit 6da8dc0aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 16 deletions

View File

@ -257,9 +257,9 @@
## apigateway
<details>
<summary>34% implemented</summary>
<summary>38% implemented</summary>
- [ ] create_api_key
- [X] create_api_key
- [X] create_authorizer
- [ ] create_base_path_mapping
- [X] create_deployment
@ -274,7 +274,7 @@
- [X] create_usage_plan
- [X] create_usage_plan_key
- [ ] create_vpc_link
- [ ] delete_api_key
- [X] delete_api_key
- [X] delete_authorizer
- [ ] delete_base_path_mapping
- [ ] delete_client_certificate
@ -299,8 +299,8 @@
- [ ] flush_stage_cache
- [ ] generate_client_certificate
- [ ] get_account
- [ ] get_api_key
- [ ] get_api_keys
- [X] get_api_key
- [X] get_api_keys
- [X] get_authorizer
- [X] get_authorizers
- [ ] get_base_path_mapping

View File

@ -1155,18 +1155,18 @@ class APIGatewayBackend(BaseBackend):
api = self.get_rest_api(function_id)
return api.delete_deployment(deployment_id)
def create_apikey(self, payload):
def create_api_key(self, payload):
if payload.get("value") is not None:
if len(payload.get("value", [])) < 20:
raise ApiKeyValueMinLength()
for api_key in self.get_apikeys(include_values=True):
for api_key in self.get_api_keys(include_values=True):
if api_key.get("value") == payload["value"]:
raise ApiKeyAlreadyExists()
key = ApiKey(**payload)
self.keys[key["id"]] = key
return key
def get_apikeys(self, include_values=False):
def get_api_keys(self, include_values=False):
api_keys = list(self.keys.values())
if not include_values:
@ -1179,7 +1179,7 @@ class APIGatewayBackend(BaseBackend):
return api_keys
def get_apikey(self, api_key_id, include_value=False):
def get_api_key(self, api_key_id, include_value=False):
api_key = self.keys[api_key_id]
if not include_value:
@ -1189,11 +1189,11 @@ class APIGatewayBackend(BaseBackend):
return api_key
def update_apikey(self, api_key_id, patch_operations):
def update_api_key(self, api_key_id, patch_operations):
key = self.keys[api_key_id]
return key.update_operations(patch_operations)
def delete_apikey(self, api_key_id):
def delete_api_key(self, api_key_id):
self.keys.pop(api_key_id)
return {}

View File

@ -429,7 +429,7 @@ class APIGatewayResponse(BaseResponse):
if self.method == "POST":
try:
apikey_response = self.backend.create_apikey(json.loads(self.body))
apikey_response = self.backend.create_api_key(json.loads(self.body))
except ApiKeyAlreadyExists as error:
return (
error.code,
@ -451,7 +451,7 @@ class APIGatewayResponse(BaseResponse):
elif self.method == "GET":
include_values = self._get_bool_param("includeValues")
apikeys_response = self.backend.get_apikeys(include_values=include_values)
apikeys_response = self.backend.get_api_keys(include_values=include_values)
return 200, {}, json.dumps({"item": apikeys_response})
def apikey_individual(self, request, full_url, headers):
@ -463,14 +463,14 @@ class APIGatewayResponse(BaseResponse):
status_code = 200
if self.method == "GET":
include_value = self._get_bool_param("includeValue")
apikey_response = self.backend.get_apikey(
apikey_response = self.backend.get_api_key(
apikey, include_value=include_value
)
elif self.method == "PATCH":
patch_operations = self._get_param("patchOperations")
apikey_response = self.backend.update_apikey(apikey, patch_operations)
apikey_response = self.backend.update_api_key(apikey, patch_operations)
elif self.method == "DELETE":
apikey_response = self.backend.delete_apikey(apikey)
apikey_response = self.backend.delete_api_key(apikey)
status_code = 202
return status_code, {}, json.dumps(apikey_response)