diff --git a/test/integration/eos.yaml b/test/integration/eos.yaml index 46d60ddf20..b1406644e1 100644 --- a/test/integration/eos.yaml +++ b/test/integration/eos.yaml @@ -16,3 +16,4 @@ - { role: eos_eapi, debug: yes, when: "limit_to in ['*', 'eos_eapi']" } - { role: eos_system, debug: yes, when: "limit_to in ['*', 'eos_system']" } - { role: eos_vlan, debug: yes, when: "limit_to in ['*', 'eos_vlan']" } + - { role: eos_user, when: "limit_to in ['*', eos_user']" } diff --git a/test/integration/targets/eos_user/defaults/main.yaml b/test/integration/targets/eos_user/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/eos_user/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/eos_user/meta/main.yaml b/test/integration/targets/eos_user/meta/main.yaml new file mode 100644 index 0000000000..e5c8cd02f0 --- /dev/null +++ b/test/integration/targets/eos_user/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_eos_tests diff --git a/test/integration/targets/eos_user/tasks/cli.yaml b/test/integration/targets/eos_user/tasks/cli.yaml new file mode 100644 index 0000000000..d675462dd0 --- /dev/null +++ b/test/integration/targets/eos_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/eos_user/tasks/eapi.yaml b/test/integration/targets/eos_user/tasks/eapi.yaml new file mode 100644 index 0000000000..068881ab1b --- /dev/null +++ b/test/integration/targets/eos_user/tasks/eapi.yaml @@ -0,0 +1,15 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/eapi" + 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/eos_user/tasks/main.yaml b/test/integration/targets/eos_user/tasks/main.yaml new file mode 100644 index 0000000000..970e74171e --- /dev/null +++ b/test/integration/targets/eos_user/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_user/tests/cli/basic.yaml b/test/integration/targets/eos_user/tests/cli/basic.yaml new file mode 100644 index 0000000000..5d1c636a50 --- /dev/null +++ b/test/integration/targets/eos_user/tests/cli/basic.yaml @@ -0,0 +1,43 @@ +--- +- name: Create user + eos_user: + username: netend + privilege: 15 + role: network-operator + state: present + authorize: yes + provider: "{{ cli }}" + register: result + +- assert: + that: + - 'result.changed == true' + - 'result.commands == ["username netend role network-operator", "username netend privilege 15"]' + +- name: Collection of users + eos_user: + users: + - username: test1 + - username: test2 + authorize: yes + state: present + role: 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 + eos_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/eos_user/tests/eapi/basic.yaml b/test/integration/targets/eos_user/tests/eapi/basic.yaml new file mode 100644 index 0000000000..f25956aa33 --- /dev/null +++ b/test/integration/targets/eos_user/tests/eapi/basic.yaml @@ -0,0 +1,43 @@ +--- +- name: Create user + eos_user: + username: netend + privilege: 15 + role: network-operator + state: present + authorize: yes + provider: "{{ eapi }}" + register: result + +- assert: + that: + - 'result.changed == true' + - 'result.commands == ["username netend role network-operator", "username netend privilege 15"]' + +- name: Collection of users + eos_user: + users: + - username: test1 + - username: test2 + authorize: yes + state: present + role: network-admin + provider: "{{ eapi }}" + register: result + +- assert: + that: + - 'result.changed == true' + - 'result.commands == ["username test1 role network-admin", "username test2 role network-admin"]' + +- name: tearDown + eos_user: + purge: yes + authorize: yes + provider: "{{ eapi }}" + register: result + +- assert: + that: + - 'result.changed == true' + - 'result.commands == ["no username netend", "no username test1", "no username test2"]'