Skip to content

Commit

Permalink
ansible-collections#1573 add additional integration test when tags pa…
Browse files Browse the repository at this point in the history
…rameter is not supplied
  • Loading branch information
mikehas committed Oct 27, 2022
1 parent 0c6162e commit 696559f
Showing 1 changed file with 79 additions and 1 deletion.
80 changes: 79 additions & 1 deletion tests/integration/targets/ssm_parameter/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,84 @@
with_items:
- '{{ simple_tag_param_name }}'

# ============================================================
# Test tags - No tags parameter (purge_tags=true) case # should be no change

- name: No tags parameter (purge_tags=true) - Create parameter
aws_ssm_parameter_store:
name: '{{ simple_tag_param_name }}'
description: '{{ simple_tag_param_description }}'
value: '{{ simple_tag_param_value }}'
tags: '{{ simple_tags_orig }}'
register: result

- name: No tags parameter (purge_tags=true) - Change tag (CHECK)
aws_ssm_parameter_store:
name: '{{ simple_tag_param_name }}'
description: '{{ simple_tag_param_updated_description }}'
register: result
check_mode: True
- assert:
that:
- result is changed

- name: No tags parameter (purge_tags=true) - Change tag
aws_ssm_parameter_store:
name: '{{ simple_tag_param_name }}'
description: '{{ simple_tag_param_updated_description }}'
register: result

- name: No tags parameter (purge_tags=true) - Ensure expected tags_dict is correct
assert:
that:
- >
result.parameter_metadata.tags_dict['{{ item.key }}']
== simple_tags_orig['{{ item.key }}']
loop: >
{{ simple_tags_orig | dict2items }}
loop_control:
extended: true

- name: No tags parameter (purge_tags=true) - Ensure no missing or additional tags
assert:
that:
- >
result.parameter_metadata.tags_dict | length
== {{ simple_tags_orig | dict2items }} | length
- name: No tags parameter (purge_tags=true) - Lookup a tagged parameter
set_fact:
lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}"
- assert:
that:
- result is changed
- lookup_value == simple_tag_param_value
- '"parameter_metadata" in result'
- '"data_type" in result.parameter_metadata'
- '"description" in result.parameter_metadata'
- '"last_modified_date" in result.parameter_metadata'
- '"last_modified_user" in result.parameter_metadata'
- '"name" in result.parameter_metadata'
- '"policies" in result.parameter_metadata'
- '"tier" in result.parameter_metadata'
- '"type" in result.parameter_metadata'
- '"version" in result.parameter_metadata'
- '"tags" in result.parameter_metadata'
- result.parameter_metadata.data_type == 'text'
- result.parameter_metadata.description == simple_tag_param_updated_description
- result.parameter_metadata.name == simple_tag_param_name
- result.parameter_metadata.policies | length == 0
- result.parameter_metadata.tier == 'Standard'
- result.parameter_metadata.type == 'String'

- name: No tags parameter (purge_tags=true) - Delete parameter
aws_ssm_parameter_store:
name: "{{item}}"
state: absent
ignore_errors: true
with_items:
- '{{ simple_tag_param_name }}'

always:
# ============================================================
- name: Delete remaining key/value pairs in aws parameter store
Expand All @@ -1492,4 +1570,4 @@
ignore_errors: True
with_items:
- '{{ simple_name }}'
- '{{ simple_tag_param_name }}'
- '{{ simple_tag_param_name }}'

0 comments on commit 696559f

Please sign in to comment.