Merge pull request #2748 from jrbeilke/feature-apigw-apikeyrequired
Feature: API Gateway default value for apiKeyRequired on methods
This commit is contained in:
commit
9cf6123669
3 changed files with 60 additions and 7 deletions
|
|
@ -286,6 +286,41 @@ def test_create_method():
|
|||
{
|
||||
"httpMethod": "GET",
|
||||
"authorizationType": "none",
|
||||
"apiKeyRequired": False,
|
||||
"ResponseMetadata": {"HTTPStatusCode": 200},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@mock_apigateway
|
||||
def test_create_method_apikeyrequired():
|
||||
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"]
|
||||
|
||||
resources = client.get_resources(restApiId=api_id)
|
||||
root_id = [resource for resource in resources["items"] if resource["path"] == "/"][
|
||||
0
|
||||
]["id"]
|
||||
|
||||
client.put_method(
|
||||
restApiId=api_id,
|
||||
resourceId=root_id,
|
||||
httpMethod="GET",
|
||||
authorizationType="none",
|
||||
apiKeyRequired=True,
|
||||
)
|
||||
|
||||
response = client.get_method(restApiId=api_id, resourceId=root_id, httpMethod="GET")
|
||||
|
||||
# this is hard to match against, so remove it
|
||||
response["ResponseMetadata"].pop("HTTPHeaders", None)
|
||||
response["ResponseMetadata"].pop("RetryAttempts", None)
|
||||
response.should.equal(
|
||||
{
|
||||
"httpMethod": "GET",
|
||||
"authorizationType": "none",
|
||||
"apiKeyRequired": True,
|
||||
"ResponseMetadata": {"HTTPStatusCode": 200},
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue