|
|
@ -42,12 +42,42 @@ class TestNxosBannerModule(TestNxosModule):
|
|
|
|
def load_fixtures(self, commands=None, device=''):
|
|
|
|
def load_fixtures(self, commands=None, device=''):
|
|
|
|
self.load_config.return_value = dict(diff=None, session='session')
|
|
|
|
self.load_config.return_value = dict(diff=None, session='session')
|
|
|
|
|
|
|
|
|
|
|
|
def test_nxos_banner_create(self):
|
|
|
|
def test_nxos_banner_exec_create(self):
|
|
|
|
set_module_args(dict(banner='exec', text='test\nbanner\nstring'))
|
|
|
|
set_module_args(dict(banner='exec', text='test\nbanner\nstring'))
|
|
|
|
commands = ['banner exec @\ntest\nbanner\nstring\n@']
|
|
|
|
commands = ['banner exec @\ntest\nbanner\nstring\n@']
|
|
|
|
|
|
|
|
self.run_commands.return_value = commands
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
|
|
|
|
|
|
|
|
def test_nxos_banner_remove(self):
|
|
|
|
def test_nxos_banner_exec_remove(self):
|
|
|
|
set_module_args(dict(banner='exec', state='absent'))
|
|
|
|
set_module_args(dict(banner='exec', state='absent'))
|
|
|
|
commands = ['no banner exec']
|
|
|
|
commands = ['no banner exec']
|
|
|
|
|
|
|
|
self.run_commands.return_value = commands
|
|
|
|
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_nxos_banner_exec_fail_create(self):
|
|
|
|
|
|
|
|
set_module_args(dict(banner='exec', text='test\nbanner\nstring'))
|
|
|
|
|
|
|
|
commands = ['banner exec @\ntest\nbanner\nstring\n@']
|
|
|
|
|
|
|
|
err_rsp = ['Invalid command']
|
|
|
|
|
|
|
|
self.run_commands.return_value = err_rsp
|
|
|
|
|
|
|
|
result = self.execute_module(failed=True, changed=True)
|
|
|
|
|
|
|
|
self.assertEqual(result['msg'], 'banner: exec may not be supported on this platform. Possible values are : exec | motd')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_nxos_banner_exec_fail_remove(self):
|
|
|
|
|
|
|
|
set_module_args(dict(banner='exec', state='absent'))
|
|
|
|
|
|
|
|
commands = ['no banner exec']
|
|
|
|
|
|
|
|
err_rsp = ['Invalid command']
|
|
|
|
|
|
|
|
self.run_commands.return_value = err_rsp
|
|
|
|
|
|
|
|
result = self.execute_module(failed=True, changed=True)
|
|
|
|
|
|
|
|
self.assertEqual(result['msg'], 'banner: exec may not be supported on this platform. Possible values are : exec | motd')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_nxos_banner_motd_create(self):
|
|
|
|
|
|
|
|
set_module_args(dict(banner='motd', text='test\nbanner\nstring'))
|
|
|
|
|
|
|
|
commands = ['banner motd @\ntest\nbanner\nstring\n@']
|
|
|
|
|
|
|
|
self.run_commands.return_value = commands
|
|
|
|
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_nxos_banner_motd_remove(self):
|
|
|
|
|
|
|
|
set_module_args(dict(banner='motd', state='absent'))
|
|
|
|
|
|
|
|
commands = ['no banner motd']
|
|
|
|
|
|
|
|
self.run_commands.return_value = commands
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|