Cloudfront - add missing fields (#4792)
This commit is contained in:
parent
05f5bbc568
commit
38ad5193d4
@ -100,6 +100,8 @@ class Origin:
|
||||
class DistributionConfig:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
self.aliases = config.get("Aliases", {}).get("Items", {}).get("CNAME", [])
|
||||
self.comment = config.get("Comment", "")
|
||||
self.default_cache_behavior = DefaultCacheBehaviour(
|
||||
config["DefaultCacheBehavior"]
|
||||
)
|
||||
@ -145,7 +147,6 @@ class Distribution(BaseModel):
|
||||
self.distribution_config = DistributionConfig(config)
|
||||
self.active_trusted_signers = ActiveTrustedSigners()
|
||||
self.active_trusted_key_groups = ActiveTrustedKeyGroups()
|
||||
self.aliases = []
|
||||
self.origin_groups = []
|
||||
self.alias_icp_recordals = []
|
||||
self.last_modified_time = "2021-11-27T10:34:26.802Z"
|
||||
|
@ -381,7 +381,7 @@ DIST_CONFIG_TEMPLATE = """
|
||||
</Items>
|
||||
{% endif %}
|
||||
</CustomErrorResponses>
|
||||
<Comment>{{ CommentType }}</Comment>
|
||||
<Comment>{{ distribution.distribution_config.comment }}</Comment>
|
||||
<Logging>
|
||||
<Enabled>{{ distribution.distribution_config.logging.enabled }}</Enabled>
|
||||
<IncludeCookies>{{ distribution.distribution_config.logging.include_cookies }}</IncludeCookies>
|
||||
|
@ -121,7 +121,9 @@ def test_create_distribution_s3_minimum():
|
||||
|
||||
config.should.have.key("CacheBehaviors").equals({"Quantity": 0})
|
||||
config.should.have.key("CustomErrorResponses").equals({"Quantity": 0})
|
||||
config.should.have.key("Comment").equals("")
|
||||
config.should.have.key("Comment").equals(
|
||||
"an optional comment that's not actually optional"
|
||||
)
|
||||
|
||||
config.should.have.key("Logging")
|
||||
logging = config["Logging"]
|
||||
@ -149,6 +151,21 @@ def test_create_distribution_s3_minimum():
|
||||
restriction.should.have.key("Quantity").equals(0)
|
||||
|
||||
|
||||
@mock_cloudfront
|
||||
def test_create_distribution_with_additional_fields():
|
||||
client = boto3.client("cloudfront", region_name="us-west-1")
|
||||
|
||||
config = example_distribution_config("ref")
|
||||
config["Aliases"] = {"Quantity": 2, "Items": ["alias1", "alias2"]}
|
||||
resp = client.create_distribution(DistributionConfig=config)
|
||||
distribution = resp["Distribution"]
|
||||
distribution.should.have.key("DistributionConfig")
|
||||
config = distribution["DistributionConfig"]
|
||||
config.should.have.key("Aliases").equals(
|
||||
{"Items": ["alias1", "alias2"], "Quantity": 2}
|
||||
)
|
||||
|
||||
|
||||
@mock_cloudfront
|
||||
def test_create_distribution_returns_etag():
|
||||
client = boto3.client("cloudfront", region_name="us-east-1")
|
||||
|
Loading…
Reference in New Issue
Block a user