mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 14:21:26 -07:00
ios_user module - implement sshkey option (#38782)
* ios_user module - add sshkey support * ios_user - Add version_added to sshkey option * ios_user - pep8 indentation fixes in unit tests * ios_user - use b64decode method that works on python 2 and 3
This commit is contained in:
parent
0ca61e9d87
commit
7c318d4e30
6 changed files with 141 additions and 7 deletions
|
@ -57,16 +57,21 @@ class TestIosUserModule(TestIosModule):
|
|||
def test_ios_user_delete(self):
|
||||
set_module_args(dict(name='ansible', state='absent'))
|
||||
result = self.execute_module(changed=True)
|
||||
cmd = {
|
||||
"command": "no username ansible", "answer": "y", "newline": False,
|
||||
"prompt": "This operation will remove all username related configurations with same name",
|
||||
}
|
||||
cmds = [
|
||||
{
|
||||
"command": "no username ansible", "answer": "y", "newline": False,
|
||||
"prompt": "This operation will remove all username related configurations with same name",
|
||||
},
|
||||
'ip ssh pubkey-chain',
|
||||
' no username ansible',
|
||||
' exit'
|
||||
]
|
||||
|
||||
result_cmd = []
|
||||
for i in result['commands']:
|
||||
result_cmd.append(i)
|
||||
|
||||
self.assertEqual(result_cmd, [cmd])
|
||||
self.assertEqual(result_cmd, cmds)
|
||||
|
||||
def test_ios_user_password(self):
|
||||
set_module_args(dict(name='ansible', configured_password='test'))
|
||||
|
@ -114,3 +119,16 @@ class TestIosUserModule(TestIosModule):
|
|||
set_module_args(dict(name='ansible', configured_password='test', update_password='always'))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(result['commands'], ['username ansible secret test'])
|
||||
|
||||
def test_ios_user_set_sshkey(self):
|
||||
set_module_args(dict(name='ansible', sshkey='dGVzdA=='))
|
||||
commands = [
|
||||
'ip ssh pubkey-chain',
|
||||
' no username ansible',
|
||||
' username ansible',
|
||||
' key-hash ssh-rsa 098F6BCD4621D373CADE4E832627B4F6',
|
||||
' exit',
|
||||
' exit'
|
||||
]
|
||||
result = self.execute_module(changed=True, commands=commands)
|
||||
self.assertEqual(result['commands'], commands)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue