Skip to content

Commit

Permalink
terraform packaging test with private api gateway resource and min co…
Browse files Browse the repository at this point in the history
…mpression size
  • Loading branch information
kapilt committed Aug 1, 2019
1 parent 77d4840 commit 6cf5a54
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chalice/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def _generate_restapi(self, resource, template):
template['resource'][
'aws_api_gateway_rest_api'][
resource.resource_name][
'minimum_compression_size'] = (
'minimum_compression_size'] = int(
resource.minimum_compression)

template['resource'].setdefault('aws_api_gateway_stage', {})[
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/deploy/test_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,7 @@ def foo():
}


def test_can_custom_resource_policy_with_cfn(sample_app):
swagger_gen = CFNSwaggerGenerator()
def test_can_custom_resource_policy(sample_app, swagger_gen):
rest_api = RestAPI(
resource_name='dev',
swagger_doc={},
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ def generate_template(self, config, chalice_stage_name):
'info': {'title': 'some-app'},
'x-amazon-apigateway-binary-media-types': []
}
if (isinstance(r, models.RestAPI) and
config.api_gateway_endpoint_type == 'PRIVATE'):
r.swagger_doc['x-amazon-apigateway-policy'] = (
r.policy.document)

# Same for iam policies on roles
elif isinstance(r, models.FileBasedIAMPolicy):
r.document = self.EmptyPolicy
Expand Down Expand Up @@ -236,6 +241,9 @@ def test_can_generate_scheduled_event(self):
def test_can_generate_rest_api(self, sample_app_with_auth):
config = Config.create(chalice_app=sample_app_with_auth,
project_dir='.',
minimum_compression_size=8192,
api_gateway_endpoint_type='PRIVATE',
api_gateway_endpoint_vpce='vpce-abc123',
app_name='sample_app',
api_gateway_stage='api')
template = self.generate_template(config, 'dev')
Expand All @@ -251,6 +259,13 @@ def test_can_generate_rest_api(self, sample_app_with_auth):
'${aws_api_gateway_rest_api.rest_api.execution_arn}/*/*/*')
}
assert resources['aws_api_gateway_rest_api']
assert resources['aws_api_gateway_rest_api'][
'rest_api']['policy']
assert resources['aws_api_gateway_rest_api'][
'rest_api']['minimum_compression_size'] == 8192
assert resources['aws_api_gateway_rest_api'][
'rest_api']['endpoint_configuration'] == {'types': ['PRIVATE']}

# We should also create the auth lambda function.
assert 'myauth' in resources['aws_lambda_function']

Expand Down

0 comments on commit 6cf5a54

Please sign in to comment.