diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2018-05-17 11:34:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-17 11:34:13 -0400 |
commit | 677fe1076dce6f4a0d8567dbd8dd4fc8691981f0 (patch) | |
tree | 4fd9c82d8bfe0659c48fa52ddbf03830d9de60e3 /test/integration/targets/user | |
parent | 19356c03e8ac8061e0e96383255190766c1a5a32 (diff) | |
download | ansible-677fe1076dce6f4a0d8567dbd8dd4fc8691981f0.tar.gz |
User unexpire (#39758)
* Allow negative values to expires to unexpire a user
Fixes #20096
(cherry picked from commit 34f8080a19c09cd20ec9c045fca1e37ef74bb1e6)
(cherry picked from commit 54619f70f4b79f121c5062d54e9732d3cbb24377)
(cherry picked from commit 8c2fae27d6e2af810112032bb1dfef5459035b7e)
(cherry picked from commit db1a32f8caa8c8b9f989baa65784d4b2b5cad1f8)
* tweaked and normalized
- also added tests, made checking resilient
Diffstat (limited to 'test/integration/targets/user')
-rw-r--r-- | test/integration/targets/user/tasks/main.yml | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/integration/targets/user/tasks/main.yml b/test/integration/targets/user/tasks/main.yml index c013a1d5b1..ee20aac5be 100644 --- a/test/integration/targets/user/tasks/main.yml +++ b/test/integration/targets/user/tasks/main.yml @@ -246,3 +246,56 @@ - name: Restore original timezone - {{ original_timezone.diff.before.name }} timezone: name: "{{ original_timezone.diff.before.name }}" + + +- name: Unexpire user + user: + name: ansibulluser + state: present + expires: -1 + register: user_test_expires3 + +- name: Verify un expiration date for Linux + block: + - name: LINUX | Get expiration date for ansibulluser + getent: + database: shadow + key: ansibulluser + + - name: LINUX | Ensure proper expiration date was set + assert: + msg: "expiry is supposed to be empty or -1, not {{getent_shadow['ansibulluser'][6]}}" + that: + - not getent_shadow['ansibulluser'][6] or getent_shadow['ansibulluser'][6] < 0 + when: ansible_os_family in ['RedHat', 'Debian', 'Suse'] + +- name: Verify un expiration date for linux/BSD + block: + - name: Unexpire user again to check for change + user: + name: ansibulluser + state: present + expires: -1 + register: user_test_expires4 + + - name: Ensure first expiration reported a change and second did not + assert: + msg: The second run of the expiration removal task reported a change when it should not + that: + - user_test_expires3 is changed + - user_test_expires4 is not changed + when: ansible_os_family in ['RedHat', 'Debian', 'Suse', 'FreeBSD'] + +- name: Verify un expiration date for BSD + block: + - name: BSD | Get expiration date for ansibulluser + shell: 'grep ansibulluser /etc/master.passwd | cut -d: -f 7' + changed_when: no + register: bsd_account_expiration + + - name: BSD | Ensure proper expiration date was set + assert: + msg: "expiry is supposed to be '0', not {{bsd_account_expiration.stdout}}" + that: + - bsd_account_expiration.stdout == '0' + when: ansible_os_family == 'FreeBSD' |