diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml index 4699403d0d0..83a9b9d07b5 100644 --- a/test/integration/nxos.yaml +++ b/test/integration/nxos.yaml @@ -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']" } diff --git a/test/integration/targets/nxos_user/defaults/main.yaml b/test/integration/targets/nxos_user/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_user/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_user/meta/main.yaml b/test/integration/targets/nxos_user/meta/main.yaml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_user/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_user/tasks/cli.yaml b/test/integration/targets/nxos_user/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_user/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_user/tasks/main.yaml b/test/integration/targets/nxos_user/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_user/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_user/tasks/nxapi.yaml b/test/integration/targets/nxos_user/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_user/tasks/nxapi.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_user/tests/cli/basic.yaml b/test/integration/targets/nxos_user/tests/cli/basic.yaml new file mode 100644 index 00000000000..c2bb3a5fef3 --- /dev/null +++ b/test/integration/targets/nxos_user/tests/cli/basic.yaml @@ -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"]' diff --git a/test/integration/targets/nxos_user/tests/nxapi/basic.yaml b/test/integration/targets/nxos_user/tests/nxapi/basic.yaml new file mode 100644 index 00000000000..5c35c137d5b --- /dev/null +++ b/test/integration/targets/nxos_user/tests/nxapi/basic.yaml @@ -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"]'