From 76e3baa72d1e627e31771eb83d080ce6f0d3b3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=91=D0=B0=D0=BA=D0=B0=D0=BD=D0=BE=D0=B2=D1=81=D0=BA=D0=B8?= =?UTF-8?q?=D0=B9?= Date: Tue, 17 Sep 2024 17:26:35 +0300 Subject: [PATCH] Update integration tests --- .../targets/authorized_key/defaults/main.yml | 2 ++ .../authorized_key/tasks/check_path.yml | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/integration/targets/authorized_key/tasks/check_path.yml diff --git a/tests/integration/targets/authorized_key/defaults/main.yml b/tests/integration/targets/authorized_key/defaults/main.yml index 1b60f8c..7ec99ca 100644 --- a/tests/integration/targets/authorized_key/defaults/main.yml +++ b/tests/integration/targets/authorized_key/defaults/main.yml @@ -35,3 +35,5 @@ multiple_keys_comments: | ssh-rsa DATA_BASIC 1@testing # I like adding comments yo-dude-this-is-not-a-key INVALID_DATA 2@testing ecdsa-sha2-nistp521 ECDSA_DATA 4@testing + +key_path: /tmp/id_rsa.pub diff --git a/tests/integration/targets/authorized_key/tasks/check_path.yml b/tests/integration/targets/authorized_key/tasks/check_path.yml new file mode 100644 index 0000000..7f1133b --- /dev/null +++ b/tests/integration/targets/authorized_key/tasks/check_path.yml @@ -0,0 +1,31 @@ +--- +- name: Create key file for test + ansible.builtin.copy: + dest: "{{ key_path }}" + content: "{{ rsa_key_basic }}" + +- name: Add key using path + ansible.posix.authorized_key: + user: root + key: "{{ key_path }}" + state: present + path: "{{ output_dir | expanduser }}/authorized_keys" + register: result + +- name: Assert that the key was added + ansible.builtin.assert: + that: + - result.changed == true + +- name: Add key using path again + ansible.posix.authorized_key: + user: root + key: "{{ key_path }}" + state: present + path: "{{ output_dir | expanduser }}/authorized_keys" + register: result + +- name: Assert that no changes were applied + ansible.builtin.assert: + that: + - result.changed == false