From 9eef9a37027231a9b2fabc0f69008ab57e2a3a32 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Wed, 30 Jan 2019 01:49:33 +0100 Subject: [PATCH] aci_aaa_user: Fix an issue with clear_password_history (#51459) --- .../modules/network/aci/aci_aaa_user.py | 2 +- .../targets/aci_aaa_user/tasks/main.yml | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/aci/aci_aaa_user.py b/lib/ansible/modules/network/aci/aci_aaa_user.py index 0ddb54304fe..38381745d19 100644 --- a/lib/ansible/modules/network/aci/aci_aaa_user.py +++ b/lib/ansible/modules/network/aci/aci_aaa_user.py @@ -298,7 +298,7 @@ def main(): aaa_password_lifetime = module.params['aaa_password_lifetime'] aaa_password_update_required = aci.boolean(module.params['aaa_password_update_required']) aaa_user = module.params['aaa_user'] - clear_password_history = module.params['clear_password_history'] + clear_password_history = aci.boolean(module.params['clear_password_history'], 'yes', 'no') description = module.params['description'] email = module.params['email'] enabled = aci.boolean(module.params['enabled'], 'active', 'inactive') diff --git a/test/integration/targets/aci_aaa_user/tasks/main.yml b/test/integration/targets/aci_aaa_user/tasks/main.yml index 46b2af238ef..2202cb8b702 100644 --- a/test/integration/targets/aci_aaa_user/tasks/main.yml +++ b/test/integration/targets/aci_aaa_user/tasks/main.yml @@ -115,6 +115,44 @@ - nm_modify_user_again.current.0.aaaUser.attributes.descr == 'Ansible test user for integration tests' +# CLEAR PASSWORD HISTORY +- name: Clear password history (check_mode) + aci_aaa_user: &clear_password_history + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + aaa_user: ansible + clear_password_history: yes + check_mode: yes + register: cm_clear_password_history + +- name: Clear password history (normal mode) + aci_aaa_user: *clear_password_history + register: nm_clear_password_history + +- name: Clear password history (check mode) + aci_aaa_user: *clear_password_history + check_mode: yes + register: cm_clear_password_history_again + +- name: Clear password history (normal mode) + aci_aaa_user: *clear_password_history + register: nm_clear_password_history_again + +- name: Verify clear password history + assert: + that: + # NOTE: Clearing password history is a changing action, everytime + - cm_clear_password_history is changed + - nm_clear_password_history is changed + - cm_clear_password_history_again is changed + - nm_clear_password_history_again is changed + + # QUERY ALL USERS - name: Query all users (check_mode) aci_aaa_user: &user_query