1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

htpasswd: add integration tests (#6847)

This commit is contained in:
Alexei Znamensky 2023-07-05 06:07:10 +12:00 committed by GitHub
parent e5dc697887
commit 41e3f4d5fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 112 additions and 0 deletions

View file

@ -0,0 +1,7 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
azp/posix/2
destructive
needs/root

View file

@ -0,0 +1,9 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: remove passlib
ansible.builtin.pip:
name: passlib
state: absent

View file

@ -0,0 +1,7 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
dependencies:
- setup_remote_tmp_dir

View file

@ -0,0 +1,83 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: install passlib
ansible.builtin.pip:
name: passlib
notify: remove passlib
- name: add bob (check mode)
community.general.htpasswd:
path: "{{ htpasswd_path }}"
name: bob
password: c00lbob
check_mode: true
register: add_bob_check
- name: add bob
community.general.htpasswd:
path: "{{ htpasswd_path }}"
name: bob
password: c00lbob
register: add_bob
- name: add bob (idempotency)
community.general.htpasswd:
path: "{{ htpasswd_path }}"
name: bob
password: c00lbob
register: add_bob_idempot
- name: add bob new password
community.general.htpasswd:
path: "{{ htpasswd_path }}"
name: bob
password: SUPERsecret
register: add_bob_newpw
- name: add bob new password (idempotency)
community.general.htpasswd:
path: "{{ htpasswd_path }}"
name: bob
password: SUPERsecret
register: add_bob_newpw_idempot
- name: test add bob assertions
ansible.builtin.assert:
that:
- add_bob_check is changed
- add_bob is changed
- add_bob_idempot is not changed
- add_bob_newpw is changed
- add_bob_newpw_idempot is not changed
- name: remove bob (check mode)
community.general.htpasswd:
path: "{{ htpasswd_path }}"
name: bob
state: absent
check_mode: true
register: del_bob_check
- name: remove bob
community.general.htpasswd:
path: "{{ htpasswd_path }}"
name: bob
state: absent
register: del_bob
- name: remove bob (idempotency)
community.general.htpasswd:
path: "{{ htpasswd_path }}"
name: bob
state: absent
register: del_bob_idempot
- name: test remove bob assertions
ansible.builtin.assert:
that:
- del_bob_check is changed
- del_bob is changed
- del_bob_idempot is not changed

View file

@ -0,0 +1,6 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
htpasswd_path: "{{ remote_tmp_dir }}/dot_htpasswd"