本文整理汇总了Python中ncclient.transport.ssh.SSHSession._transport方法的典型用法代码示例。如果您正苦于以下问题:Python SSHSession._transport方法的具体用法?Python SSHSession._transport怎么用?Python SSHSession._transport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ncclient.transport.ssh.SSHSession
的用法示例。
在下文中一共展示了SSHSession._transport方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_auth_exception
# 需要导入模块: from ncclient.transport.ssh import SSHSession [as 别名]
# 或者: from ncclient.transport.ssh.SSHSession import _transport [as 别名]
def test_auth_exception(self, mock_auth_password):
mock_auth_password.side_effect = Exception
device_handler = JunosDeviceHandler({'name': 'junos'})
obj = SSHSession(device_handler)
obj._transport = paramiko.Transport(MagicMock())
self.assertRaises(AuthenticationError,
obj._auth, 'user', 'password', [], False, True)
示例2: test_auth_keyfiles_exception
# 需要导入模块: from ncclient.transport.ssh import SSHSession [as 别名]
# 或者: from ncclient.transport.ssh.SSHSession import _transport [as 别名]
def test_auth_keyfiles_exception(self, mock_get_key, mock_auth_public_key):
key = paramiko.PKey()
mock_get_key.side_effect = paramiko.ssh_exception.PasswordRequiredException
device_handler = JunosDeviceHandler({'name': 'junos'})
obj = SSHSession(device_handler)
obj._transport = paramiko.Transport(MagicMock())
self.assertRaises(AuthenticationError,
obj._auth,'user', None, ["key_file_name"], False, True)
示例3: test_close
# 需要导入模块: from ncclient.transport.ssh import SSHSession [as 别名]
# 或者: from ncclient.transport.ssh.SSHSession import _transport [as 别名]
def test_close(self, mock_close):
device_handler = JunosDeviceHandler({'name': 'junos'})
obj = SSHSession(device_handler)
obj._transport = paramiko.Transport(MagicMock())
obj._transport.active = True
obj._connected = True
obj.close()
mock_close.assert_called_once_with()
self.assertFalse(obj._connected)
示例4: test_auth_password
# 需要导入模块: from ncclient.transport.ssh import SSHSession [as 别名]
# 或者: from ncclient.transport.ssh.SSHSession import _transport [as 别名]
def test_auth_password(self, mock_auth_password):
device_handler = JunosDeviceHandler({'name': 'junos'})
obj = SSHSession(device_handler)
obj._transport = paramiko.Transport(MagicMock())
obj._auth('user', 'password', [], False, True)
self.assertEqual(
mock_auth_password.call_args_list[0][0],
('user',
'password'))
示例5: test_auth_agent_exception
# 需要导入模块: from ncclient.transport.ssh import SSHSession [as 别名]
# 或者: from ncclient.transport.ssh.SSHSession import _transport [as 别名]
def test_auth_agent_exception(self, mock_get_key, mock_auth_public_key):
key = paramiko.PKey()
mock_get_key.return_value = [key]
mock_auth_public_key.side_effect = paramiko.ssh_exception.AuthenticationException
device_handler = JunosDeviceHandler({'name': 'junos'})
obj = SSHSession(device_handler)
obj._transport = paramiko.Transport(MagicMock())
self.assertRaises(AuthenticationError,
obj._auth,'user', None, [], True, False)
示例6: test_auth_keyfiles
# 需要导入模块: from ncclient.transport.ssh import SSHSession [as 别名]
# 或者: from ncclient.transport.ssh.SSHSession import _transport [as 别名]
def test_auth_keyfiles(self, mock_get_key, mock_auth_public_key):
key = paramiko.PKey()
mock_get_key.return_value = key
device_handler = JunosDeviceHandler({'name': 'junos'})
obj = SSHSession(device_handler)
obj._transport = paramiko.Transport(MagicMock())
obj._auth('user', 'password', ["key_file_name"], False, True)
self.assertEqual(
(mock_auth_public_key.call_args_list[0][0][1]).__repr__(),
key.__repr__())
示例7: test_auth_agent
# 需要导入模块: from ncclient.transport.ssh import SSHSession [as 别名]
# 或者: from ncclient.transport.ssh.SSHSession import _transport [as 别名]
def test_auth_agent(self, mock_get_key, mock_auth_public_key):
key = paramiko.PKey(msg="hello")
mock_get_key.return_value = [key]
device_handler = JunosDeviceHandler({'name': 'junos'})
obj = SSHSession(device_handler)
obj._transport = paramiko.Transport(MagicMock())
obj._auth('user', 'password', [], True, True)
self.assertEqual(
(mock_auth_public_key.call_args_list[0][0][1]).__repr__(),
key.__repr__())
示例8: test_auth_default_keyfiles_exception
# 需要导入模块: from ncclient.transport.ssh import SSHSession [as 别名]
# 或者: from ncclient.transport.ssh.SSHSession import _transport [as 别名]
def test_auth_default_keyfiles_exception(self, mock_get_key,
mock_auth_public_key, mock_is_file):
key = paramiko.PKey()
mock_is_file.return_value = True
mock_get_key.side_effect = paramiko.ssh_exception.PasswordRequiredException
device_handler = JunosDeviceHandler({'name': 'junos'})
obj = SSHSession(device_handler)
obj._transport = paramiko.Transport(None)
self.assertRaises(AuthenticationError,
obj._auth,'user', None, [], False, True)
示例9: test_auth_no_methods_exception
# 需要导入模块: from ncclient.transport.ssh import SSHSession [as 别名]
# 或者: from ncclient.transport.ssh.SSHSession import _transport [as 别名]
def test_auth_no_methods_exception(self):
device_handler = JunosDeviceHandler({'name': 'junos'})
obj = SSHSession(device_handler)
obj._transport = paramiko.Transport(MagicMock())
self.assertRaises(AuthenticationError,
obj._auth,'user', None, [], False, False)