mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
eos_user fix username param (#28114)
* eos_user fix username param Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add setup eos_user test and rename username for consistency Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update unit test and pep8 fix Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * pep8 fix
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
---
|
||||
- name: Set Up
|
||||
eos_config:
|
||||
lines:
|
||||
- no username ansibletest1
|
||||
- no username ansibletest2
|
||||
- no username ansibletest3
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Create user
|
||||
eos_user:
|
||||
name: netend
|
||||
name: ansibletest1
|
||||
privilege: 15
|
||||
role: network-operator
|
||||
state: present
|
||||
@@ -12,13 +20,13 @@
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username netend role network-operator", "username netend privilege 15"]'
|
||||
- 'result.commands == ["username ansibletest1 role network-operator", "username ansibletest1 privilege 15"]'
|
||||
|
||||
- name: Collection of users
|
||||
eos_user:
|
||||
aggregate:
|
||||
- name: test1
|
||||
- name: test2
|
||||
- name: ansibletest2
|
||||
- name: ansibletest3
|
||||
authorize: yes
|
||||
state: present
|
||||
role: network-operator
|
||||
@@ -28,12 +36,12 @@
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- 'result.commands == ["username test1 role network-operator", "username test2 role network-operator"]'
|
||||
- 'result.commands == ["username ansibletest2 role network-operator", "username ansibletest3 role network-operator"]'
|
||||
|
||||
- name: tearDown
|
||||
eos_config:
|
||||
lines:
|
||||
- no username netend
|
||||
- no username test1
|
||||
- no username test2
|
||||
- no username ansibletest1
|
||||
- no username ansibletest2
|
||||
- no username ansibletest3
|
||||
provider: "{{ cli }}"
|
||||
|
||||
@@ -44,27 +44,27 @@ class TestEosUserModule(TestEosModule):
|
||||
self.load_config.return_value = dict(diff=None, session='session')
|
||||
|
||||
def test_eos_user_create(self):
|
||||
set_module_args(dict(username='test', nopassword=True))
|
||||
set_module_args(dict(name='test', nopassword=True))
|
||||
commands = ['username test nopassword']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eos_user_delete(self):
|
||||
set_module_args(dict(username='ansible', state='absent'))
|
||||
set_module_args(dict(name='ansible', state='absent'))
|
||||
commands = ['no username ansible']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eos_user_password(self):
|
||||
set_module_args(dict(username='ansible', password='test'))
|
||||
set_module_args(dict(name='ansible', password='test'))
|
||||
commands = ['username ansible secret test']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eos_user_privilege(self):
|
||||
set_module_args(dict(username='ansible', privilege=15))
|
||||
set_module_args(dict(name='ansible', privilege=15))
|
||||
commands = ['username ansible privilege 15']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eos_user_privilege_invalid(self):
|
||||
set_module_args(dict(username='ansible', privilege=25))
|
||||
set_module_args(dict(name='ansible', privilege=25))
|
||||
self.execute_module(failed=True)
|
||||
|
||||
def test_eos_user_purge(self):
|
||||
@@ -73,25 +73,25 @@ class TestEosUserModule(TestEosModule):
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eos_user_role(self):
|
||||
set_module_args(dict(username='ansible', role='test'))
|
||||
set_module_args(dict(name='ansible', role='test'))
|
||||
commands = ['username ansible role test']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eos_user_sshkey(self):
|
||||
set_module_args(dict(username='ansible', sshkey='test'))
|
||||
set_module_args(dict(name='ansible', sshkey='test'))
|
||||
commands = ['username ansible sshkey test']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eos_user_update_password_changed(self):
|
||||
set_module_args(dict(username='test', password='test', update_password='on_create'))
|
||||
set_module_args(dict(name='test', password='test', update_password='on_create'))
|
||||
commands = ['username test secret test']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eos_user_update_password_on_create_ok(self):
|
||||
set_module_args(dict(username='ansible', password='test', update_password='on_create'))
|
||||
set_module_args(dict(name='ansible', password='test', update_password='on_create'))
|
||||
self.execute_module()
|
||||
|
||||
def test_eos_user_update_password_always(self):
|
||||
set_module_args(dict(username='ansible', password='test', update_password='always'))
|
||||
set_module_args(dict(name='ansible', password='test', update_password='always'))
|
||||
commands = ['username ansible secret test']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
Reference in New Issue
Block a user