mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add integration test for nxos_user (#25464)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
parent
b1b68840be
commit
36082e32b4
8 changed files with 135 additions and 0 deletions
|
@ -18,3 +18,4 @@
|
|||
- { role: nxos_mtu, when: "limit_to in ['*', 'nxos_mtu']" }
|
||||
- { role: nxos_system, when: "limit_to in ['*', 'nxos_system']" }
|
||||
- { role: nxos_interface, when: "limit_to in ['*', 'nxos_interface']" }
|
||||
- { role: nxos_user, when: "limit_to in ['*', 'nxos_user']" }
|
||||
|
|
2
test/integration/targets/nxos_user/defaults/main.yaml
Normal file
2
test/integration/targets/nxos_user/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
2
test/integration/targets/nxos_user/meta/main.yaml
Normal file
2
test/integration/targets/nxos_user/meta/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nxos_tests
|
15
test/integration/targets/nxos_user/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_user/tasks/cli.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
3
test/integration/targets/nxos_user/tasks/main.yaml
Normal file
3
test/integration/targets/nxos_user/tasks/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
28
test/integration/targets/nxos_user/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_user/tasks/nxapi.yaml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- name: collect all nxapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/nxapi"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: enable nxapi
|
||||
nxos_config:
|
||||
lines:
|
||||
- feature nxapi
|
||||
- nxapi http port 80
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: disable nxapi
|
||||
nxos_config:
|
||||
lines:
|
||||
- no feature nxapi
|
||||
provider: "{{ cli }}"
|
42
test/integration/targets/nxos_user/tests/cli/basic.yaml
Normal file
42
test/integration/targets/nxos_user/tests/cli/basic.yaml
Normal file
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
- name: Create user
|
||||
nxos_user:
|
||||
name: netend
|
||||
roles: network-operator
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username netend role network-operator"]'
|
||||
|
||||
- name: Collection of users
|
||||
nxos_user:
|
||||
users:
|
||||
- name: test1
|
||||
- name: test2
|
||||
authorize: yes
|
||||
state: present
|
||||
roles: network-admin
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username test1 role network-admin", "username test2 role network-admin"]'
|
||||
|
||||
- name: tearDown
|
||||
nxos_user:
|
||||
purge: yes
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["no username netend", "no username test1", "no username test2"]'
|
42
test/integration/targets/nxos_user/tests/nxapi/basic.yaml
Normal file
42
test/integration/targets/nxos_user/tests/nxapi/basic.yaml
Normal file
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
- name: Create user
|
||||
nxos_user:
|
||||
name: netend
|
||||
roles: network-operator
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username netend role network-operator"]'
|
||||
|
||||
- name: Collection of users
|
||||
nxos_user:
|
||||
users:
|
||||
- name: test1
|
||||
- name: test2
|
||||
authorize: yes
|
||||
state: present
|
||||
roles: network-admin
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username test1 role network-admin", "username test2 role network-admin"]'
|
||||
|
||||
- name: tearDown
|
||||
nxos_user:
|
||||
purge: yes
|
||||
authorize: yes
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["no username netend", "no username test1", "no username test2"]'
|
Loading…
Reference in a new issue