当前位置: 首页>>代码示例>>Python>>正文


Python SSHSession._transport方法代码示例

本文整理汇总了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)
开发者ID:davidhankins,项目名称:ncclient,代码行数:9,代码来源:test_ssh.py

示例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)
开发者ID:davidhankins,项目名称:ncclient,代码行数:10,代码来源:test_ssh.py

示例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)
开发者ID:davidhankins,项目名称:ncclient,代码行数:11,代码来源:test_ssh.py

示例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'))
开发者ID:davidhankins,项目名称:ncclient,代码行数:11,代码来源:test_ssh.py

示例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)
开发者ID:davidhankins,项目名称:ncclient,代码行数:11,代码来源:test_ssh.py

示例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__())
开发者ID:davidhankins,项目名称:ncclient,代码行数:12,代码来源:test_ssh.py

示例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__())
开发者ID:davidhankins,项目名称:ncclient,代码行数:12,代码来源:test_ssh.py

示例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)
开发者ID:GIC-de,项目名称:ncclient,代码行数:12,代码来源:test_ssh.py

示例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)
开发者ID:davidhankins,项目名称:ncclient,代码行数:8,代码来源:test_ssh.py


注:本文中的ncclient.transport.ssh.SSHSession._transport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。