From f20938788aaa623e1574e7c68128812ca1156152 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 25 Sep 2018 12:09:22 +0100 Subject: [PATCH] fixed nxos_aaa_server_host issue with type 7 encrypt key (#46015) * fixed nxos_aaa_server_host issue with type 7 encrypt and added test cases * added idempotence tests --- .../network/nxos/nxos_aaa_server_host.py | 2 ++ .../tests/common/radius.yaml | 24 +++++++++++++++++++ .../tests/common/tacacs.yaml | 23 ++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py b/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py index 0c1d6bc6f41..c1a84814b6d 100644 --- a/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py +++ b/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py @@ -309,6 +309,8 @@ def main(): delta = proposed else: for key, value in proposed.items(): + if key == 'encrypt_type': + delta[key] = value if value != existing.get(key): if value != 'default' or existing.get(key): delta[key] = value diff --git a/test/integration/targets/nxos_aaa_server_host/tests/common/radius.yaml b/test/integration/targets/nxos_aaa_server_host/tests/common/radius.yaml index c00a43a4b13..1f73efde1b6 100644 --- a/test/integration/targets/nxos_aaa_server_host/tests/common/radius.yaml +++ b/test/integration/targets/nxos_aaa_server_host/tests/common/radius.yaml @@ -130,6 +130,30 @@ - assert: *false + - name: "Configure radius server with new type 7 encryption key" + nxos_aaa_server_host: &configure_radius_new_type7 + server_type: radius + address: 8.8.8.8 + host_timeout: 25 + auth_port: 2083 + acct_port: 2084 + encrypt_type: 7 + key: helloback + provider: "{{ connection }}" + state: present + register: result + + - assert: + that: + - "result.changed == true" + - "'key 7' in result.updates[0]" + + - name: "Check Idempotence" + nxos_aaa_server_host: *configure_radius_new_type7 + register: result + + - assert: *false + - name: "Configure radius server with default key" nxos_aaa_server_host: &configure_radius_defkey server_type: radius diff --git a/test/integration/targets/nxos_aaa_server_host/tests/common/tacacs.yaml b/test/integration/targets/nxos_aaa_server_host/tests/common/tacacs.yaml index c5ca89785a4..d493fe19cab 100644 --- a/test/integration/targets/nxos_aaa_server_host/tests/common/tacacs.yaml +++ b/test/integration/targets/nxos_aaa_server_host/tests/common/tacacs.yaml @@ -133,6 +133,29 @@ - assert: *false + - name: "Configure tacacs server with new type 7 encryption key" + nxos_aaa_server_host: &configure_tacacs_new_type7 + server_type: tacacs + address: 8.8.8.8 + host_timeout: 25 + tacacs_port: 89 + encrypt_type: 7 + key: helloback + provider: "{{ connection }}" + state: present + register: result + + - assert: + that: + - "result.changed == true" + - "'key 7' in result.updates[0]" + + - name: "Check Idempotence" + nxos_aaa_server_host: *configure_tacacs_new_type7 + register: result + + - assert: *false + - name: "Configure tacacs server with default key" nxos_aaa_server_host: &configure_tacacs_defkey server_type: tacacs