|
|
@ -104,10 +104,10 @@ class TestConnectionBaseClass(unittest.TestCase):
|
|
|
|
conn = connection_loader.get('ssh', pc, new_stdin)
|
|
|
|
conn = connection_loader.get('ssh', pc, new_stdin)
|
|
|
|
conn.set_become_plugin(become_loader.get('sudo'))
|
|
|
|
conn.set_become_plugin(become_loader.get('sudo'))
|
|
|
|
|
|
|
|
|
|
|
|
conn.check_password_prompt = MagicMock()
|
|
|
|
conn.become.check_password_prompt = MagicMock()
|
|
|
|
conn.check_become_success = MagicMock()
|
|
|
|
conn.become.check_success = MagicMock()
|
|
|
|
conn.check_incorrect_password = MagicMock()
|
|
|
|
conn.become.check_incorrect_password = MagicMock()
|
|
|
|
conn.check_missing_password = MagicMock()
|
|
|
|
conn.become.check_missing_password = MagicMock()
|
|
|
|
|
|
|
|
|
|
|
|
def _check_password_prompt(line):
|
|
|
|
def _check_password_prompt(line):
|
|
|
|
if b'foo' in line:
|
|
|
|
if b'foo' in line:
|
|
|
@ -129,11 +129,6 @@ class TestConnectionBaseClass(unittest.TestCase):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
conn.become.check_password_prompt = MagicMock(side_effect=_check_password_prompt)
|
|
|
|
|
|
|
|
conn.become.check_become_success = MagicMock(side_effect=_check_become_success)
|
|
|
|
|
|
|
|
conn.become.check_incorrect_password = MagicMock(side_effect=_check_incorrect_password)
|
|
|
|
|
|
|
|
conn.become.check_missing_password = MagicMock(side_effect=_check_missing_password)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# test examining output for prompt
|
|
|
|
# test examining output for prompt
|
|
|
|
conn._flags = dict(
|
|
|
|
conn._flags = dict(
|
|
|
|
become_prompt=False,
|
|
|
|
become_prompt=False,
|
|
|
@ -143,7 +138,13 @@ class TestConnectionBaseClass(unittest.TestCase):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
pc.prompt = True
|
|
|
|
pc.prompt = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# override become plugin
|
|
|
|
conn.become.prompt = True
|
|
|
|
conn.become.prompt = True
|
|
|
|
|
|
|
|
conn.become.check_password_prompt = MagicMock(side_effect=_check_password_prompt)
|
|
|
|
|
|
|
|
conn.become.check_success = MagicMock(side_effect=_check_become_success)
|
|
|
|
|
|
|
|
conn.become.check_incorrect_password = MagicMock(side_effect=_check_incorrect_password)
|
|
|
|
|
|
|
|
conn.become.check_missing_password = MagicMock(side_effect=_check_missing_password)
|
|
|
|
|
|
|
|
|
|
|
|
def get_option(option):
|
|
|
|
def get_option(option):
|
|
|
|
if option == 'become_pass':
|
|
|
|
if option == 'become_pass':
|
|
|
|