本文整理汇总了Python中bladerunner.Bladerunner.login方法的典型用法代码示例。如果您正苦于以下问题:Python Bladerunner.login方法的具体用法?Python Bladerunner.login怎么用?Python Bladerunner.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bladerunner.Bladerunner
的用法示例。
在下文中一共展示了Bladerunner.login方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_login_fail_guess
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import login [as 别名]
def test_login_fail_guess(pexpect_exceptions):
"""When sending a password fails try to guess the shell prompt."""
runner = Bladerunner()
sshc = Mock()
sshc.expect = Mock(side_effect=pexpect_exceptions("fake explosion"))
with patch.object(runner, "_try_for_unmatched_prompt") as p_try_for:
runner.login(sshc, "passwerd", 1)
sshc.sendline.assert_called_once_with("passwerd")
p_try_for.assert_called_once_with(
sshc,
sshc.before,
"login",
_from_login=True,
)
示例2: test_login_send_password
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import login [as 别名]
def test_login_send_password():
"""Ensure then calls when logging in properly with a passwd prompt."""
runner = Bladerunner()
sshc = Mock()
sshc.expect = Mock(return_value=22)
assert runner.login(sshc, "mock word", 1) == (sshc, 1)
sshc.sendline.assert_called_once_with("mock word")
示例3: test_login_new_host
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import login [as 别名]
def test_login_new_host():
"""The first passwd prompt is a match for a new ssh key identity."""
runner = Bladerunner()
sshc = Mock()
sshc.expect = Mock(side_effect=iter([2, 22])) # passwd, then shell
assert runner.login(sshc, "fake", 0) == (sshc, 1)
assert sshc.sendline.mock_calls == [call("yes"), call("fake")]
示例4: test_login_unexpected_prompt
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import login [as 别名]
def test_login_unexpected_prompt():
"""We received a password prompt when no password is in use."""
runner = Bladerunner()
sshc = Mock()
with patch.object(runner, "send_interrupt") as p_interrupt:
assert runner.login(sshc, None, 1) == (None, -2)
p_interrupt.assert_called_once_with(sshc)
示例5: test_login_passwd_fail
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import login [as 别名]
def test_login_passwd_fail():
"""Ensure the calls when receiving another passwd prompt after sending."""
runner = Bladerunner()
sshc = Mock()
sshc.expect = Mock(return_value=1)
with patch.object(runner, "send_interrupt") as p_interrupt:
assert runner.login(sshc, "fakepasswd", 1) == (sshc, -5)
sshc.sendline.assert_called_once_with("fakepasswd")
p_interrupt.assert_called_once_with(sshc)
示例6: test_login_new_host_failures
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import login [as 别名]
def test_login_new_host_failures(pexpect_exceptions):
"""Catch the pexpect EOF and TIMEOUT exceptions after accepting the key."""
runner = Bladerunner()
sshc = Mock()
sshc.expect = Mock(side_effect=pexpect_exceptions("fake exception"))
with patch.object(runner, "send_interrupt") as p_interrupt:
assert runner.login(sshc, "hunter12", 0) == (None, -1)
sshc.sendline.assert_called_once_with("yes")
p_interrupt.assert_called_once_with(sshc)
示例7: test_login_unused_password
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import login [as 别名]
def test_login_unused_password():
"""We logged in but did not send a password (unexpected key auth)."""
runner = Bladerunner()
sshc = Mock()
assert runner.login(sshc, "no passwd sent", 9000) == (sshc, 1)