Add integration test for nxos_user (#25464)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2017-06-08 13:32:49 +05:30 committed by GitHub
parent b1b68840be
commit 36082e32b4
8 changed files with 135 additions and 0 deletions

View file

@ -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']" }

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

View 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

View file

@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }

View 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 }}"

View 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"]'

View 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"]'