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


Python Bladerunner.sshc方法代码示例

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

示例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)
开发者ID:Demonware,项目名称:bladerunner,代码行数:17,代码来源:test_base.py

示例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")
开发者ID:Demonware,项目名称:bladerunner,代码行数:22,代码来源:test_base.py


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