From 1c8f3cfe9db0c14464afddcefc2c8f7227aa61c7 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 3 Jun 2025 14:42:06 +0200 Subject: [PATCH] test: update ssh_key force tests --- .../targets/setup_ssh_keypair/tasks/main.yml | 10 ++-- .../targets/ssh_key/tasks/test.yml | 50 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/integration/targets/setup_ssh_keypair/tasks/main.yml b/tests/integration/targets/setup_ssh_keypair/tasks/main.yml index bb0751c..ff20b31 100644 --- a/tests/integration/targets/setup_ssh_keypair/tasks/main.yml +++ b/tests/integration/targets/setup_ssh_keypair/tasks/main.yml @@ -18,14 +18,14 @@ force: true register: test_ssh_keypair -- name: Create temporary file for test_ssh_keypair_2 +- name: Create temporary file for test_ssh_keypair2 ansible.builtin.tempfile: path: ~/tmp suffix: "{{ hcloud_ssh_key_name }}" - register: _tmp_ssh_key_file_2 + register: _tmp_ssh_key_file2 -- name: Create test_ssh_keypair_2 +- name: Create test_ssh_keypair2 community.crypto.openssh_keypair: - path: "{{ _tmp_ssh_key_file_2.path }}" + path: "{{ _tmp_ssh_key_file2.path }}" force: true - register: test_ssh_keypair_2 + register: test_ssh_keypair2 diff --git a/tests/integration/targets/ssh_key/tasks/test.yml b/tests/integration/targets/ssh_key/tasks/test.yml index bc73799..983bb5f 100644 --- a/tests/integration/targets/ssh_key/tasks/test.yml +++ b/tests/integration/targets/ssh_key/tasks/test.yml @@ -49,17 +49,6 @@ that: - result is not changed -- name: test create ssh key idempotence with force - hetzner.hcloud.ssh_key: - name: "{{ hcloud_ssh_key_name }}" - public_key: "{{ test_ssh_keypair.public_key }}" - force: true - register: result -- name: verify create ssh key idempotence with force - assert: - that: - - result is not changed - - name: test update ssh key with check mode hetzner.hcloud.ssh_key: id: "{{ ssh_key.hcloud_ssh_key.id }}" @@ -147,34 +136,45 @@ - result is failed - result.failure.code == "uniqueness_error" -- name: test force update ssh key with new public key with check mode +- name: test update public key warning hetzner.hcloud.ssh_key: - name: "{{ hcloud_ssh_key_name }}-other-name" - public_key: "{{ test_ssh_keypair_2.public_key }}" + name: "{{ hcloud_ssh_key_name }}" + public_key: "{{ test_ssh_keypair2.public_key }}" + register: result +- name: verify update public key warning + assert: + that: + - result is not changed + - result.hcloud_ssh_key.name == hcloud_ssh_key_name + - result.hcloud_ssh_key.public_key == test_ssh_keypair.public_key + +- name: test update public key with force + hetzner.hcloud.ssh_key: + name: "{{ hcloud_ssh_key_name }}" + public_key: "{{ test_ssh_keypair2.public_key }}" force: true register: result - check_mode: true -- name: verify force update ssh key with new public key with check mode +- name: verify update public key with force assert: that: - result is changed + - result.hcloud_ssh_key.name == hcloud_ssh_key_name + - result.hcloud_ssh_key.public_key == test_ssh_keypair2.public_key -- name: test force update ssh key with new public key +- name: test update public key with force idempotence hetzner.hcloud.ssh_key: - name: "{{ hcloud_ssh_key_name }}-other-name" - public_key: "{{ test_ssh_keypair_2.public_key }}" + name: "{{ hcloud_ssh_key_name }}" + public_key: "{{ test_ssh_keypair2.public_key }}" force: true - register: ssh_key -- name: verify force update ssh key with new public key + register: result +- name: verify update public key with force idempotence assert: that: - - ssh_key is changed - - ssh_key.hcloud_ssh_key.name == "{{ hcloud_ssh_key_name }}-other-name" - - ssh_key.hcloud_ssh_key.public_key == test_ssh_keypair_2.public_key + - result is not changed - name: test delete ssh key hetzner.hcloud.ssh_key: - id: "{{ ssh_key.hcloud_ssh_key.id }}" + name: "{{ hcloud_ssh_key_name }}" state: absent register: result - name: verify absent ssh_key