class TestClearLinePasswords(unittest.TestCase):
    def setUp(self):
        from unicon.utils import Utils
        self.utils = Utils()

    def test_clear_line_username_password(self):
         md = MockDeviceTcpWrapper(device_os='ios', port=0, state='ts_login', vty=True)
         md.start()
         term_server = "127.0.0.1 " + str(md.ports[0])
         self.utils.clear_line(term_server, 35, 'admin', 'lab', 'cisco')
         md.stop()

    def test_clear_line_enable_password(self):
         md = MockDeviceTcpWrapper(device_os='ios', port=0, state='console_test_enable', vty=True)
         md.start()
         term_server = "127.0.0.1 " + str(md.ports[0])
         self.utils.clear_line(term_server, 35, 'admin', 'lab', 'enpasswd')
         md.stop()
 def test_reload_via_non_console(self):
     c = Connection(hostname='csp-2100',
                     start=['mock_device_cli --os confd --state csp_enable'],
                     os='confd',
                     series='csp',
                     username='******',
                     tacacs_password='******',
                     enable_password ='******',
                     init_config_commands=[])
     c.connect()
     c.settings.RELOAD_WAIT = 1
     r = c.reload()
     from unicon.utils import Utils
     output = Utils().remove_ansi_escape_codes(c.spawn.match.match_output.splitlines()[-1])
     self.assertEqual(output, 'csp-2100#')
Beispiel #3
0
from unicon.eal.helpers import sendline
from unicon.core.errors import UniconAuthenticationError
from unicon.utils import Utils

from unicon.plugins.generic.patterns import GenericPatterns
from unicon.plugins.utils import (
    get_current_credential,
    common_cred_username_handler,
    common_cred_password_handler,
)

from unicon.utils import to_plaintext
from unicon.bases.routers.connection import ENABLE_CRED_NAME

pat = GenericPatterns()
utils = Utils()


#############################################################
#  Callbacks
#############################################################

def connection_refused_handler(spawn):
    """ handles connection refused scenarios
    """
    raise Exception('Connection refused to device %s' % (str(spawn)))


def connection_failure_handler(spawn):
    raise Exception('received disconnect from router %s' % (str(spawn)))
Beispiel #4
0
 def setUp(self):
     from unicon.utils import Utils
     self.utils = Utils()