From c27c8e3489c5dc997f38fba17c44af5c432f8716 Mon Sep 17 00:00:00 2001 From: Zac Lovoy Date: Mon, 21 Oct 2024 23:38:29 -0700 Subject: [PATCH] Added idempotent tests to cloudfront_cache_policy and cloudfront_origin_request_policy tests --- .../cloudfront_cache_policy/tasks/main.yml | 24 +++++++++++++++++++ .../tasks/main.yml | 18 ++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml index dcc23f2b2f6..92946f77295 100644 --- a/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_cache_policy/tasks/main.yml @@ -35,6 +35,30 @@ - create_result is not failed - create_result.cache_policy.cache_policy_config.name == "{{ resource_prefix }}-my-cache-policy" + - name: Make sure cache policy creation is idempotent + cloudfront_cache_policy: + name: "{{ resource_prefix }}-my-cache-policy" + comment: Created by Ansible test + default_ttl: 86400 + min_ttl: 1 + max_ttl: 31536000 + parameters_in_cache_key_and_forwarded_to_origin: + enable_accept_encoding_gzip: false + enable_accept_encoding_brotli: false + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + register: idempotent_test_result + + - name: Assert cache policy creation is idempotent + assert: + that: + - idempotent_test_result.changed == False + - name: Update existing policy with more complicated configuration cloudfront_cache_policy: name: "{{ resource_prefix }}-my-cache-policy" diff --git a/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml index e2757fdaec3..bb75775b7b4 100644 --- a/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml +++ b/tests/integration/targets/cloudfront_origin_request_policy/tasks/main.yml @@ -29,6 +29,24 @@ - create_result is not failed - create_result.origin_request_policy.origin_request_policy_config.name == "{{ resource_prefix }}-my-origin-request-policy" + - name: Make sure origin request policy creation is idempotent + cloudfront_origin_request_policy: + name: "{{ resource_prefix }}-my-origin-request-policy" + comment: Created by Ansible test + headers_config: + header_behavior: none + cookies_config: + cookie_behavior: none + query_strings_config: + query_string_behavior: none + state: present + register: idempotent_test_result + + - name: Assert origin request policy creation is idempotent + assert: + that: + - idempotent_test_result.changed == False + - name: Update existing policy with more complicated configuration cloudfront_origin_request_policy: name: "{{ resource_prefix }}-my-origin-request-policy"