Idempotent behaviour in ios_user integration test (#25774)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
parent
98269888a9
commit
41f6f8f410
1 changed files with 44 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: Create user
|
||||
- name: Create user (SetUp)
|
||||
ios_user:
|
||||
name: netend
|
||||
name: ansibletest1
|
||||
privilege: 15
|
||||
role: network-operator
|
||||
state: present
|
||||
|
@ -12,13 +12,13 @@
|
|||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username netend view network-operator", "username netend privilege 15"]'
|
||||
- 'result.commands == ["username ansibletest1 view network-operator", "username ansibletest1 privilege 15"]'
|
||||
|
||||
- name: Collection of users
|
||||
- name: Collection of users (SetUp)
|
||||
ios_user:
|
||||
users:
|
||||
- name: test1
|
||||
- name: test2
|
||||
- name: ansibletest2
|
||||
- name: ansibletest3
|
||||
authorize: yes
|
||||
state: present
|
||||
view: network-admin
|
||||
|
@ -28,11 +28,46 @@
|
|||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username test1 view network-admin", "username test2 view network-admin"]'
|
||||
- 'result.commands == ["username ansibletest2 view network-admin", "username ansibletest3 view network-admin"]'
|
||||
|
||||
- name: Add user again (Idempotent)
|
||||
ios_user:
|
||||
name: ansibletest1
|
||||
privilege: 15
|
||||
role: network-operator
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.commands | length == 0'
|
||||
|
||||
- name: Add collection of users again (Idempotent)
|
||||
ios_user:
|
||||
users:
|
||||
- name: anisbletest2
|
||||
- name: ansibletest3
|
||||
authorize: yes
|
||||
state: present
|
||||
view: network-admin
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
- 'result.commands | length == 0'
|
||||
|
||||
- name: tearDown
|
||||
ios_user:
|
||||
purge: yes
|
||||
users:
|
||||
- name: ansibletest1
|
||||
- name: ansibletest2
|
||||
- name: ansibletest3
|
||||
state: absent
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
@ -40,4 +75,4 @@
|
|||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["no username netend", "no username test1", "no username test2"]'
|
||||
- 'result.commands == ["no username ansibletest1", "no username ansibletest2", "no username ansibletest3"]'
|
||||
|
|
Loading…
Reference in a new issue