mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-19 15:39:10 -07:00
module should fail if eos_user is added without configured_password or nopassword or sshkey (#28780)
* 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>
This commit is contained in:
parent
cef40cb54a
commit
252efcebf5
3 changed files with 41 additions and 11 deletions
|
@ -13,6 +13,7 @@
|
|||
privilege: 15
|
||||
role: network-operator
|
||||
state: present
|
||||
configured_password: test1
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
@ -20,13 +21,16 @@
|
|||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username ansibletest1 role network-operator", "username ansibletest1 privilege 15"]'
|
||||
- '"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
|
||||
- name: ansibletest3
|
||||
- { name: ansibletest2, configured_password: test2 }
|
||||
- { name: ansibletest3, configured_password: test3 }
|
||||
authorize: yes
|
||||
state: present
|
||||
role: network-operator
|
||||
|
@ -36,7 +40,28 @@
|
|||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username ansibletest2 role network-operator", "username ansibletest3 role network-operator"]'
|
||||
- '"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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue