Update integration tests

This commit is contained in:
Александр Бакановский 2024-09-17 17:26:35 +03:00
parent 1ec0718e7b
commit 76e3baa72d
No known key found for this signature in database
GPG key ID: 42D02B7FCCCE0BC8
2 changed files with 33 additions and 0 deletions

View file

@ -35,3 +35,5 @@ multiple_keys_comments: |
ssh-rsa DATA_BASIC 1@testing ssh-rsa DATA_BASIC 1@testing
# I like adding comments yo-dude-this-is-not-a-key INVALID_DATA 2@testing # I like adding comments yo-dude-this-is-not-a-key INVALID_DATA 2@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
key_path: /tmp/id_rsa.pub

View file

@ -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