diff options
author | Thomas Sjögren <konstruktoid@users.noreply.github.com> | 2024-06-21 20:31:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-21 20:31:31 +0200 |
commit | f7dee8aaf8eaf7bce41b206ce58296043afee0cf (patch) | |
tree | eea6bf2e232708ccfe64131d0ab5aedaa1b70bea /test/integration | |
parent | ansible-test - Replace FreeBSD 14.0 with 14.1 (#83477) (diff) | |
download | ansible-f7dee8aaf8eaf7bce41b206ce58296043afee0cf.tar.xz ansible-f7dee8aaf8eaf7bce41b206ce58296043afee0cf.zip |
add support for inactive option (#83355)
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Diffstat (limited to 'test/integration')
-rw-r--r-- | test/integration/targets/user/tasks/main.yml | 1 | ||||
-rw-r--r-- | test/integration/targets/user/tasks/test_inactive_new_account.yml | 74 |
2 files changed, 75 insertions, 0 deletions
diff --git a/test/integration/targets/user/tasks/main.yml b/test/integration/targets/user/tasks/main.yml index be4c4d6fdc..aefd359ff5 100644 --- a/test/integration/targets/user/tasks/main.yml +++ b/test/integration/targets/user/tasks/main.yml @@ -42,3 +42,4 @@ when: not (ansible_distribution == 'openSUSE Leap' and ansible_distribution_version is version('15.4', '>=')) - import_tasks: test_umask.yml when: ansible_facts.system == 'Linux' +- import_tasks: test_inactive_new_account.yml diff --git a/test/integration/targets/user/tasks/test_inactive_new_account.yml b/test/integration/targets/user/tasks/test_inactive_new_account.yml new file mode 100644 index 0000000000..984ac9d3b7 --- /dev/null +++ b/test/integration/targets/user/tasks/test_inactive_new_account.yml @@ -0,0 +1,74 @@ +# Test inactive setting when creating a new account +- name: Remove ansibulluser + user: + name: ansibulluser + state: absent + +- name: Create user account with inactive set to 15 + user: + name: ansibulluser + state: present + password_expire_account_disable: 15 + +- name: Verify inactive setting for Linux + when: ansible_facts.os_family in ['RedHat', 'Debian', 'Suse'] + block: + - name: LINUX | Get inactive value for ansibulluser + getent: + database: shadow + key: ansibulluser + + - name: LINUX | Ensure inactive is set to 15 + assert: + msg: "expiry is supposed to be empty or 15, not {{ getent_shadow['ansibulluser'][7] }}" + that: + - not getent_shadow['ansibulluser'][7] or getent_shadow['ansibulluser'][7] | int != 15 + +- name: Verify inactive setting for BSD + when: ansible_facts.system in ['NetBSD','OpenBSD'] + block: + - name: BSD | Get inactive value for ansibulluser + getent: + database: shadow + key: ansibulluser + + - name: BSD | Ensure inactive is set to 15 + assert: + msg: "expiry is supposed to be empty or 15, not {{ getent_shadow['ansibulluser'][7] }}" + that: + - not getent_shadow['ansibulluser'][7] or getent_shadow['ansibulluser'][7] | int != 15 + +- name: Update user account with inactive set to 10 + user: + name: ansibulluser + state: present + password_expire_account_disable: 10 + register: return_user_information + +- name: Verify updated inactive setting for Linux + when: ansible_facts.os_family in ['RedHat', 'Debian', 'Suse'] + block: + - name: LINUX | Get inactive value for ansibulluser + getent: + database: shadow + key: ansibulluser + + - name: LINUX | Ensure inactive is set to 10 + assert: + msg: "expiry is supposed to be empty or 10, not {{ getent_shadow['ansibulluser'][7] }}" + that: + - not getent_shadow['ansibulluser'][7] or getent_shadow['ansibulluser'][7] | int != 10 + +- name: Verify updated inactive setting for BSD + when: ansible_facts.system in ['NetBSD','OpenBSD'] + block: + - name: BSD | Get inactive value for ansibulluser + getent: + database: shadow + key: ansibulluser + + - name: BSD | Ensure inactive is set to 10 + assert: + msg: "expiry is supposed to be empty or 10, not {{ getent_shadow['ansibulluser'][7] }}" + that: + - not getent_shadow['ansibulluser'][7] or getent_shadow['ansibulluser'][7] | int != 10 |