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:
Trishna Guha 2017-08-31 15:29:57 -04:00 committed by GitHub
parent cef40cb54a
commit 252efcebf5
3 changed files with 41 additions and 11 deletions

View file

@ -200,6 +200,11 @@ def map_obj_to_commands(updates, module):
else:
add('no username %s nopassword' % want['name'])
if want.get('state') == 'present' and want.get('name'):
value = [want.get('configured_password'), want.get('nopassword'), want.get('sshkey')]
if all(v is None for v in value) is True:
module.fail_json(msg='configured_password, sshkey or nopassword should be provided')
return commands