mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
iosxr_user refactor for cliconf and netconf (#34892)
* * refactor iosxr_user for cliconf and netconf (cherry picked from commit 5d0994ef598f1601fca00a0c1eff4ebb05ebbf1b) * * Purge and units test changes
This commit is contained in:
parent
db61f8f967
commit
0f692f1fe7
9 changed files with 669 additions and 274 deletions
|
@ -1,4 +1,11 @@
|
|||
---
|
||||
- name: collect all common test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: common_test_cases
|
||||
delegate_to: localhost
|
||||
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
|
@ -6,6 +13,10 @@
|
|||
register: test_cases
|
||||
delegate_to: localhost
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ common_test_cases.files }} + {{ test_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
||||
|
|
33
test/integration/targets/iosxr_user/tasks/netconf.yaml
Normal file
33
test/integration/targets/iosxr_user/tasks/netconf.yaml
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
- name: collect all common test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: common_test_cases
|
||||
delegate_to: localhost
|
||||
|
||||
- name: collect all netconf test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/netconf"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
delegate_to: localhost
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ common_test_cases.files }} + {{ test_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case (connection=local)
|
||||
include: "{{ test_case_to_run }} ansible_connection=local"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
#- name: run test case (connection=netconf)
|
||||
#include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||
#with_items: "{{ test_items }}"
|
||||
#loop_control:
|
||||
# loop_var: test_case_to_run
|
170
test/integration/targets/iosxr_user/tests/netconf/basic.yaml
Normal file
170
test/integration/targets/iosxr_user/tests/netconf/basic.yaml
Normal file
|
@ -0,0 +1,170 @@
|
|||
---
|
||||
- name: Remove users prior to tests
|
||||
iosxr_config:
|
||||
lines:
|
||||
- no username ansible1
|
||||
- no username ansible2
|
||||
- no username ansible3
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Create user (SetUp)
|
||||
iosxr_user:
|
||||
name: ansible1
|
||||
configured_password: password
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"ansible1" in result.xml[0]'
|
||||
- '"secret" in result.xml[0]'
|
||||
|
||||
- name: Create user with update_password always (not idempotent)
|
||||
iosxr_user:
|
||||
name: ansible1
|
||||
configured_password: password
|
||||
update_password: always
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"ansible1" in result.xml[0]'
|
||||
- '"secret" in result.xml[0]'
|
||||
|
||||
- name: Create user again with update_password on_create (idempotent)
|
||||
iosxr_user:
|
||||
name: ansible1
|
||||
configured_password: password
|
||||
update_password: on_create
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.xml | length == 0'
|
||||
|
||||
- name: Modify user group
|
||||
iosxr_user:
|
||||
name: ansible1
|
||||
configured_password: password
|
||||
update_password: on_create
|
||||
group: sysadmin
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"ansible1" in result.xml[0]'
|
||||
- '"sysadmin" in result.xml[0]'
|
||||
|
||||
- name: Modify user group again (idempotent)
|
||||
iosxr_user:
|
||||
name: ansible1
|
||||
configured_password: password
|
||||
update_password: on_create
|
||||
group: sysadmin
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.xml | length == 0'
|
||||
|
||||
- name: Collection of users (SetUp)
|
||||
iosxr_user:
|
||||
aggregate:
|
||||
- name: ansible2
|
||||
- name: ansible3
|
||||
configured_password: password
|
||||
state: present
|
||||
group: sysadmin
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"ansible2" in result.xml[0]'
|
||||
- '"secret" in result.xml[0]'
|
||||
- '"sysadmin" in result.xml[1]'
|
||||
- '"ansible2" in result.xml[0]'
|
||||
- '"secret" in result.xml[0]'
|
||||
- '"sysadmin" in result.xml[1]'
|
||||
|
||||
- name: Add collection of users again with update_password always (not idempotent)
|
||||
iosxr_user:
|
||||
aggregate:
|
||||
- name: ansible2
|
||||
- name: ansible3
|
||||
configured_password: password
|
||||
state: present
|
||||
group: sysadmin
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"ansible2" in result.xml[0]'
|
||||
- '"ansible3" in result.xml[0]'
|
||||
- '"secret" in result.xml[0]'
|
||||
|
||||
- name: Add collection of users again with update_password on_create (idempotent)
|
||||
iosxr_user:
|
||||
aggregate:
|
||||
- name: ansible2
|
||||
- name: ansible3
|
||||
configured_password: password
|
||||
update_password: on_create
|
||||
state: present
|
||||
group: sysadmin
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.xml | length == 0'
|
||||
|
||||
- name: Delete collection of users
|
||||
iosxr_user:
|
||||
aggregate:
|
||||
- name: ansible1
|
||||
- name: ansible2
|
||||
- name: ansible3
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"ansible1" in result.xml[0]'
|
||||
- '"ansible2" in result.xml[0]'
|
||||
- '"ansible3" in result.xml[0]'
|
||||
|
||||
- name: Delete collection of users again (idempotent)
|
||||
iosxr_user:
|
||||
aggregate:
|
||||
- name: ansible1
|
||||
- name: ansible2
|
||||
- name: ansible3
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.xml | length == 0'
|
Loading…
Add table
Add a link
Reference in a new issue