1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/ios_user/tests/cli/basic.yaml
Nilashish Chakraborty baae7fa9ba
Fix ios_user not able to handle certain scenario (#47656)
* added support for users with password(not secret) configs

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* Added example

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* Fix typo

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* Fix pep8

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* Add integration tests

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
2018-10-31 16:51:46 +05:30

114 lines
2.6 KiB
YAML

---
- name: tear down old users if they exist (Setup)
ios_user:
aggregate:
- name: ansibletest1
- name: ansibletest2
- name: ansibletest3
- name: ansibletest4
- name: ansibletest5
state: absent
provider: "{{ cli }}"
- name: Create user (SetUp)
ios_user:
name: ansibletest1
privilege: 15
role: network-operator
state: present
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- 'result.commands == ["username ansibletest1 view network-operator", "username ansibletest1 privilege 15"]'
- name: Collection of users (SetUp)
ios_user:
aggregate:
- name: ansibletest2
- name: ansibletest3
provider: "{{ cli }}"
state: present
view: network-admin
register: result
- assert:
that:
- 'result.changed == true'
- '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
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == false'
- 'result.commands | length == 0'
- name: Add collection of users again (Idempotent)
ios_user:
aggregate:
- name: ansibletest2
- name: ansibletest3
provider: "{{ cli }}"
state: present
view: network-admin
register: result
- assert:
that:
- 'result.changed == false'
- 'result.commands | length == 0'
- name: Create user with password_type (password)
ios_user:
name: ansibleuser4
password_type: password
configured_password: testpass
state: present
register: result
- assert:
that:
- 'result.changed == true'
- "'username ansibleuser4 password' in result.commands[0]"
- name: Create user with password_type (secret)
ios_user:
name: ansibleuser5
password_type: secret
configured_password: testpass
state: present
register: result
- assert:
that:
- 'result.changed == true'
- "'username ansibleuser5 secret' in result.commands[0]"
- name: tearDown
ios_user:
aggregate:
- name: ansibletest1
- name: ansibletest2
- name: ansibletest3
- name: ansibletest4
- name: ansibletest5
state: absent
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"no username ansibletest1" in result.commands[0]["command"]'
- '"no username ansibletest2" in result.commands[1]["command"]'
- '"no username ansibletest3" in result.commands[2]["command"]'