Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Jan 31, 2023
1 parent c2c321c commit 3a38adb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
- include_tasks: 'basic.yml'
# Permissions missing
#- include_tasks: 'rotation.yml'
- include_tasks: 'replication.yml'
# Multi-Region CI not supported (yet)
#- include_tasks: 'replication.yml'
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@
- result.changed
- result.arn is not none
- result.name is not none
- result.replication_status[0]["region"] == 'us-east-2'
- result.replication_status[1]["region"] == 'us-west-2'
- result.replication_status[1]["kms_key_id"] == 'alias/aws/secretsmanager'
- result.secret.replication_status[0]["region"] == 'us-east-2'
- result.secret.replication_status[1]["region"] == 'us-west-2'
- result.secret.replication_status[1]["kms_key_id"] == 'alias/aws/secretsmanager'
- result.tags is not none
- result.version_ids_to_stages is not none

- name: no changes to secret
aws_secret:
name: "{{ secret_name }}"
state: present
secret_type: 'string'
secret: "{{ super_secret_string }}"
replica:
- region: 'us-east-2'
Expand All @@ -49,19 +48,22 @@
aws_secret:
name: "{{ secret_name }}"
description: 'this is a change to remove replication'
secret: "{{ super_secret_string }}"
state: present
replica: []
register: result

- name: assert that replica was removed
assert:
that:
- not result.failed
- result.replication_status is none
- '"replication_status" not in result.secret'

- name: add region replica to an existing secret
aws_secret:
name: "{{ secret_name }}"
description: 'this is a change add replication'
secret: "{{ super_secret_string }}"
state: present
replica:
- region: 'us-east-2'
Expand All @@ -73,15 +75,14 @@
assert:
that:
- not result.failed
- result.replication_status[0]["region"] == 'us-east-2'
- result.replication_status[1]["region"] == 'us-west-2'
- result.replication_status[1]["kms_key_id"] == 'alias/aws/secretsmanager'
- result.secret.replication_status[0]["region"] == 'us-east-2'
- result.secret.replication_status[1]["region"] == 'us-west-2'
- result.secret.replication_status[1]["kms_key_id"] == 'alias/aws/secretsmanager'

- name: change replica regions
aws_secret:
name: "{{ secret_name }}"
state: present
secret_type: 'string'
secret: "{{ super_secret_string }}"
replica:
- region: 'us-east-2'
Expand All @@ -93,17 +94,19 @@
assert:
that:
- not result.failed
- result.replication_status[0]["region"] == 'us-east-2'
- result.replication_status[1]["region"] == 'eu-central-1'
- result.replication_status[1]["kms_key_id"] == 'alias/aws/secretsmanager'
- result.secret.replication_status[0]["region"] == 'us-east-2'
- result.secret.replication_status[1]["region"] == 'eu-central-1'
- result.secret.replication_status[1]["kms_key_id"] == 'alias/aws/secretsmanager'

always:
- name: remove region replica
aws_secret:
name: "{{ secret_name }}"
description: 'this is a change to remove replication'
state: present
secret: "{{ super_secret_string }}"
register: result
ignore_errors: yes

- name: remove secret
aws_secret:
Expand Down

0 comments on commit 3a38adb

Please sign in to comment.