mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
252efcebf5
* module should fail if eos_user is added without configured_password or nopassword or sshkey Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * fix eos_user unit test Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * fix eos_user integration test Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
72 lines
1.8 KiB
YAML
72 lines
1.8 KiB
YAML
---
|
|
- name: Set Up
|
|
eos_config:
|
|
lines:
|
|
- no username ansibletest1
|
|
- no username ansibletest2
|
|
- no username ansibletest3
|
|
provider: "{{ cli }}"
|
|
|
|
- name: Create user
|
|
eos_user:
|
|
name: ansibletest1
|
|
privilege: 15
|
|
role: network-operator
|
|
state: present
|
|
configured_password: test1
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"username" in result.commands[0]'
|
|
- '"role network-operator" in result.commands[0]'
|
|
- '"privilege 15" in result.commands[1]'
|
|
- '"secret" in result.commands[2]'
|
|
|
|
- name: Collection of users
|
|
eos_user:
|
|
aggregate:
|
|
- { name: ansibletest2, configured_password: test2 }
|
|
- { name: ansibletest3, configured_password: test3 }
|
|
authorize: yes
|
|
state: present
|
|
role: network-operator
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"username" in result.commands[0]'
|
|
- '"role network-operator" in result.commands[0]'
|
|
- '"secret" in result.commands[1]'
|
|
- '"username" in result.commands[2]'
|
|
- '"role network-operator" in result.commands[2]'
|
|
- '"secret" in result.commands[3]'
|
|
|
|
- name: Add user without password or nopassword arg(Should fail)
|
|
eos_user:
|
|
name: faileduser1
|
|
privilege: 15
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
ignore_errors: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == false'
|
|
- 'result.failed == true'
|
|
- 'result.msg == "configured_password, sshkey or nopassword should be provided"'
|
|
|
|
- name: tearDown
|
|
eos_config:
|
|
lines:
|
|
- no username ansibletest1
|
|
- no username ansibletest2
|
|
- no username ansibletest3
|
|
provider: "{{ cli }}"
|