mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Add missing integration test for eos_user (#25463)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
@@ -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']" }
|
||||
|
||||
2
test/integration/targets/eos_user/defaults/main.yaml
Normal file
2
test/integration/targets/eos_user/defaults/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
2
test/integration/targets/eos_user/meta/main.yaml
Normal file
2
test/integration/targets/eos_user/meta/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_eos_tests
|
||||
15
test/integration/targets/eos_user/tasks/cli.yaml
Normal file
15
test/integration/targets/eos_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
|
||||
15
test/integration/targets/eos_user/tasks/eapi.yaml
Normal file
15
test/integration/targets/eos_user/tasks/eapi.yaml
Normal file
@@ -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
|
||||
3
test/integration/targets/eos_user/tasks/main.yaml
Normal file
3
test/integration/targets/eos_user/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: eapi.yaml, tags: ['eapi'] }
|
||||
43
test/integration/targets/eos_user/tests/cli/basic.yaml
Normal file
43
test/integration/targets/eos_user/tests/cli/basic.yaml
Normal file
@@ -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"]'
|
||||
43
test/integration/targets/eos_user/tests/eapi/basic.yaml
Normal file
43
test/integration/targets/eos_user/tests/eapi/basic.yaml
Normal file
@@ -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"]'
|
||||
Reference in New Issue
Block a user