diff options
Diffstat (limited to 'test/integration/targets/hcloud_ssh_key_info')
4 files changed, 77 insertions, 0 deletions
diff --git a/test/integration/targets/hcloud_ssh_key_info/aliases b/test/integration/targets/hcloud_ssh_key_info/aliases new file mode 100644 index 0000000000..18dc30b6c3 --- /dev/null +++ b/test/integration/targets/hcloud_ssh_key_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/test/integration/targets/hcloud_ssh_key_info/defaults/main.yml b/test/integration/targets/hcloud_ssh_key_info/defaults/main.yml new file mode 100644 index 0000000000..06c1471ad3 --- /dev/null +++ b/test/integration/targets/hcloud_ssh_key_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +hcloud_prefix: "tests" +hcloud_ssh_key_name: "{{hcloud_prefix}}-ssh_key_facts" diff --git a/test/integration/targets/hcloud_ssh_key_info/meta/main.yml b/test/integration/targets/hcloud_ssh_key_info/meta/main.yml new file mode 100644 index 0000000000..7e4c5b7eb4 --- /dev/null +++ b/test/integration/targets/hcloud_ssh_key_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_sshkey diff --git a/test/integration/targets/hcloud_ssh_key_info/tasks/main.yml b/test/integration/targets/hcloud_ssh_key_info/tasks/main.yml new file mode 100644 index 0000000000..87cbd26264 --- /dev/null +++ b/test/integration/targets/hcloud_ssh_key_info/tasks/main.yml @@ -0,0 +1,68 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- + +- name: setup ensure ssh key is absent + hcloud_ssh_key: + name: "{{ hcloud_ssh_key_name }}" + state: absent + register: result + +- name: setup test ssh_key + hcloud_ssh_key: + name: "{{hcloud_ssh_key_name}}" + public_key: "{{ key_material }}" + labels: + key: value + register: result +- name: verify create test ssh_key + assert: + that: + - result is changed + - result.hcloud_ssh_key.public_key == "{{ key_material }}" + +- name: test gather hcloud ssh key infos in check mode + hcloud_ssh_key_info: + register: hcloud_ssh_key + check_mode: yes +- name: verify test gather hcloud ssh key infos in check mode + assert: + that: + - hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1 + +- name: test gather hcloud ssh key infos + hcloud_ssh_key_info: + register: hcloud_ssh_key + check_mode: yes +- name: verify test gather hcloud ssh key infos + assert: + that: + - hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1 + +- name: test gather hcloud ssh key infos with correct label selector + hcloud_ssh_key_info: + label_selector: "key=value" + register: hcloud_ssh_key +- name: verify test gather hcloud ssh key infos with correct label selector + assert: + that: + - hcloud_ssh_key.hcloud_ssh_key_info|selectattr('name','equalto','{{ hcloud_ssh_key_name }}') | list | count == 1 + +- name: test gather hcloud ssh key infos with wrong label selector + hcloud_ssh_key_info: + label_selector: "key!=value" + register: hcloud_ssh_key +- name: verify test gather hcloud ssh key infos with wrong label selector + assert: + that: + - hcloud_ssh_key.hcloud_ssh_key_info | list | count == 0 + +- name: cleanup + hcloud_ssh_key: + name: "{{hcloud_ssh_key_name}}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is success |