Update connection plugins to use correct, non-deprecated, methods (#52038)
* Update connection plugins to use correct, non-deprecated, methods * Update tests to reflect calling become plugins
This commit is contained in:
parent
d033884465
commit
c55317a2bd
4 changed files with 12 additions and 12 deletions
|
@ -92,7 +92,7 @@ class Connection(ConnectionBase):
|
|||
|
||||
become_output = b''
|
||||
try:
|
||||
while not self.check_become_success(become_output) and not self.check_password_prompt(become_output):
|
||||
while not self.become.check_success(become_output) and not self.become.check_password_prompt(become_output):
|
||||
events = selector.select(self._play_context.timeout)
|
||||
if not events:
|
||||
stdout, stderr = p.communicate()
|
||||
|
@ -111,7 +111,7 @@ class Connection(ConnectionBase):
|
|||
finally:
|
||||
selector.close()
|
||||
|
||||
if not self.check_become_success(become_output):
|
||||
if not self.become.check_success(become_output):
|
||||
p.stdin.write(to_bytes(self._play_context.become_pass, errors='surrogate_or_strict') + b'\n')
|
||||
fcntl.fcntl(p.stdout, fcntl.F_SETFL, fcntl.fcntl(p.stdout, fcntl.F_GETFL) & ~os.O_NONBLOCK)
|
||||
fcntl.fcntl(p.stderr, fcntl.F_SETFL, fcntl.fcntl(p.stderr, fcntl.F_GETFL) & ~os.O_NONBLOCK)
|
||||
|
|
|
@ -434,10 +434,10 @@ class Connection(ConnectionBase):
|
|||
# need to check every line because we might get lectured
|
||||
# and we might get the middle of a line in a chunk
|
||||
for l in become_output.splitlines(True):
|
||||
if self.check_become_success(l):
|
||||
if self.become.check_success(l):
|
||||
become_sucess = True
|
||||
break
|
||||
elif self.check_password_prompt(l):
|
||||
elif self.become.check_password_prompt(l):
|
||||
passprompt = True
|
||||
break
|
||||
|
||||
|
|
|
@ -707,18 +707,18 @@ class Connection(ConnectionBase):
|
|||
suppress_output = False
|
||||
|
||||
# display.debug("Examining line (source=%s, state=%s): '%s'" % (source, state, display_line))
|
||||
if self.become.expect_prompt() and self.check_password_prompt(b_line):
|
||||
if self.become.expect_prompt() and self.become.check_password_prompt(b_line):
|
||||
display.debug("become_prompt: (source=%s, state=%s): '%s'" % (source, state, display_line))
|
||||
self._flags['become_prompt'] = True
|
||||
suppress_output = True
|
||||
elif self.become.success and self.check_become_success(b_line):
|
||||
elif self.become.success and self.become.check_success(b_line):
|
||||
display.debug("become_success: (source=%s, state=%s): '%s'" % (source, state, display_line))
|
||||
self._flags['become_success'] = True
|
||||
suppress_output = True
|
||||
elif sudoable and self.check_incorrect_password(b_line):
|
||||
elif sudoable and self.become.check_incorrect_password(b_line):
|
||||
display.debug("become_error: (source=%s, state=%s): '%s'" % (source, state, display_line))
|
||||
self._flags['become_error'] = True
|
||||
elif sudoable and self.check_missing_password(b_line):
|
||||
elif sudoable and self.become.check_missing_password(b_line):
|
||||
display.debug("become_nopasswd_error: (source=%s, state=%s): '%s'" % (source, state, display_line))
|
||||
self._flags['become_nopasswd_error'] = True
|
||||
|
||||
|
|
|
@ -120,10 +120,10 @@ class TestConnectionBaseClass(unittest.TestCase):
|
|||
return True
|
||||
return False
|
||||
|
||||
conn.check_password_prompt.side_effect = _check_password_prompt
|
||||
conn.check_become_success.side_effect = _check_become_success
|
||||
conn.check_incorrect_password.side_effect = _check_incorrect_password
|
||||
conn.check_missing_password.side_effect = _check_missing_password
|
||||
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
|
||||
conn._flags = dict(
|
||||
|
|
Loading…
Reference in a new issue