From 67c2afcae769beb0dc21f2373d201efe764d4476 Mon Sep 17 00:00:00 2001 From: abikouo Date: Mon, 22 Mar 2021 16:10:05 +0100 Subject: [PATCH 1/3] test --- plugins/modules/cloudfront_distribution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/cloudfront_distribution.py b/plugins/modules/cloudfront_distribution.py index a48f687a890..e62fc89bfa4 100644 --- a/plugins/modules/cloudfront_distribution.py +++ b/plugins/modules/cloudfront_distribution.py @@ -1975,7 +1975,7 @@ def validate_restrictions(self, config, restrictions, purge_restrictions=False): def validate_distribution_config_parameters(self, config, default_root_object, ipv6_enabled, http_version, web_acl_id): try: config['default_root_object'] = default_root_object or config.get('default_root_object', '') - config['is_i_p_v_6_enabled'] = ipv6_enabled or config.get('i_p_v_6_enabled', self.__default_ipv6_enabled) + config['is_i_p_v6_enabled'] = ipv6_enabled if ipv6_enabled is not None else config.get('is_i_p_v6_enabled', self.__default_ipv6_enabled) if http_version is not None or config.get('http_version'): self.validate_attribute_with_allowed_values(http_version, 'http_version', self.__valid_http_versions) config['http_version'] = http_version or config.get('http_version') @@ -2056,7 +2056,7 @@ def validate_distribution_from_aliases_caller_reference(self, distribution_id, a if caller_reference is not None: return self.validate_distribution_from_caller_reference(caller_reference) else: - if aliases: + if aliases and distribution_id is None: distribution_id = self.validate_distribution_id_from_alias(aliases) if distribution_id: return self.__cloudfront_facts_mgr.get_distribution(distribution_id) From 4b520fbb8fcb1ac4d991f26242a8b10ff043ab75 Mon Sep 17 00:00:00 2001 From: aubin Date: Wed, 14 Apr 2021 18:09:23 +0200 Subject: [PATCH 2/3] integrated tests : ipv6_enabled for cloudfront_distribution --- .../cloudfront_distribution/tasks/main.yml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/integration/targets/cloudfront_distribution/tasks/main.yml b/tests/integration/targets/cloudfront_distribution/tasks/main.yml index 62c141cd039..82c5a23d075 100644 --- a/tests/integration/targets/cloudfront_distribution/tasks/main.yml +++ b/tests/integration/targets/cloudfront_distribution/tasks/main.yml @@ -25,6 +25,67 @@ - set_fact: distribution_id: '{{ cf_distribution.id }}' + - name: ensure that default value of ipv6_enabled + assert: + that: + - cf_distribution.changed + - not cf_distribution.is_ipv6_enabled + + - name: Update the distribution with tags + cloudfront_distribution: + state: present + distribution_id: "{{ distribution_id }}" + tags: + property: ansible + register: cf_update_tags + + - name: ensure the 'ipv6_enabled' value has not changed + assert: + that: + - cf_update_tags.changed + - not cf_update_tags.is_ipv6_enabled + + - name: Update the distribution ipv6_enabled set to true + cloudfront_distribution: + state: present + distribution_id: "{{ distribution_id }}" + ipv6_enabled: True + register: cf_update_ipv6 + + - name: ensure the 'ipv6_enabled' value has changed (new value is true) + assert: + that: + - cf_update_ipv6.changed + - cf_update_ipv6.is_ipv6_enabled + + - name: Update the distribution with tags + cloudfront_distribution: + state: present + distribution_id: "{{ distribution_id }}" + tags: + test: integration + register: cf_update_tags + + - name: ensure the 'ipv6_enabled' value has not changed (value remains true) + assert: + that: + - cf_update_tags.changed + - cf_update_tags.is_ipv6_enabled + + - name: Test idempotency updating cloudfront_distribution with same value of ipv6_enabled + cloudfront_distribution: + state: present + distribution_id: "{{ distribution_id }}" + ipv6_enabled: True + register: cf_update_ipv6 + + - name: ensure the 'ipv6_enabled' value has changed (new value is true) + assert: + that: + # FixMe : idempotency issues + # - not cf_update_ipv6.changed + - cf_update_ipv6.is_ipv6_enabled + - name: re-run cloudfront distribution with same defaults cloudfront_distribution: distribution_id: "{{ distribution_id }}" From 80d28cdb79ccb270a672a56ff8d84bbb70172eeb Mon Sep 17 00:00:00 2001 From: abikouo <79859644+abikouo@users.noreply.github.com> Date: Thu, 15 Apr 2021 10:39:18 +0200 Subject: [PATCH 3/3] Update main.yml --- .../integration/targets/cloudfront_distribution/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/cloudfront_distribution/tasks/main.yml b/tests/integration/targets/cloudfront_distribution/tasks/main.yml index 82c5a23d075..dff726c4791 100644 --- a/tests/integration/targets/cloudfront_distribution/tasks/main.yml +++ b/tests/integration/targets/cloudfront_distribution/tasks/main.yml @@ -25,7 +25,7 @@ - set_fact: distribution_id: '{{ cf_distribution.id }}' - - name: ensure that default value of ipv6_enabled + - name: ensure that default value of 'ipv6_enabled' is 'false' assert: that: - cf_distribution.changed