本文整理汇总了Python中bladerunner.Bladerunner.sshc方法的典型用法代码示例。如果您正苦于以下问题:Python Bladerunner.sshc方法的具体用法?Python Bladerunner.sshc怎么用?Python Bladerunner.sshc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bladerunner.Bladerunner
的用法示例。
在下文中一共展示了Bladerunner.sshc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_connect_from_jb_denied
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import sshc [as 别名]
def test_connect_from_jb_denied():
"""Ensure we look through the before text for 'Permission denied's."""
runner = Bladerunner({"jump_host": "mocked"})
runner.sshc = Mock()
runner.sshc.before.find = Mock(return_value=1)
with patch.object(base, "can_resolve", return_value=True):
with patch.object(runner, "send_interrupt") as p_interrupt:
ret = runner.connect("home", "self", "hunter22", 443)
if sys.version_info > (3,):
expected_call = bytes("Permission denied", "utf-8")
else:
expected_call = "Permission denied"
runner.sshc.before.find.assert_called_once_with(expected_call)
runner.sshc.sendline.assert_called_once_with("ssh -p 443 -t [email protected]")
runner.sshc.expect.assert_called_once_with(
runner.options["passwd_prompts"] +
runner.options["shell_prompts"] +
runner.options["extra_prompts"],
runner.options["timeout"],
)
p_interrupt.assert_called_once_with(runner.sshc)
assert ret == (None, -4)
示例2: test_connect_from_jb_failures
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import sshc [as 别名]
def test_connect_from_jb_failures(pexpect_exceptions):
"""Test the pexpect excpetions are caught from inside a jumpbox."""
runner = Bladerunner({"jump_host": "notreal"})
runner.sshc = Mock()
runner.sshc.expect = Mock(side_effect=pexpect_exceptions("fake error"))
runner.sshc.before = Mock(return_value="things")
with patch.object(base, "can_resolve", return_value=True):
with patch.object(runner, "send_interrupt") as p_interrupt:
ret = runner.connect("place", "frank", "hunter63", 101)
runner.sshc.sendline.assert_called_once_with("ssh -p 101 -t [email protected]")
p_interrupt.assert_called_once_with(runner.sshc)
assert ret == (None, -1)
示例3: test_connect_from_jumpbox
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import sshc [as 别名]
def test_connect_from_jumpbox():
"""Test the calls through connect for a succesful login from a jumpbox."""
runner = Bladerunner({"jump_host": "faked"})
runner.sshc = Mock()
runner.sshc.before.find = Mock(return_value=-1) # permission not denied
runner.sshc.expect = Mock(return_value="fake")
with patch.object(base, "can_resolve", return_value=True):
with patch.object(runner, "_multipass") as p_multipass:
runner.connect("where", "johnny", "hunter13", 43)
runner.sshc.sendline.assert_called_once_with("ssh -p 43 -t [email protected]")
runner.sshc.expect.assert_called_once_with(
runner.options["passwd_prompts"] +
runner.options["shell_prompts"] +
runner.options["extra_prompts"],
runner.options["timeout"],
)
p_multipass.assert_called_once_with(runner.sshc, "hunter13", "fake")