Add missing integration test for eos_user (#25463)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2017-06-08 12:28:29 +05:30 committed by GitHub
parent 20bddde669
commit b1b68840be
8 changed files with 124 additions and 0 deletions

View file

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

View file

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

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_eos_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,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

View file

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

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

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