Fix password prompt matching (#24081)

* Fix password prompt matching

* Add some tests for check_password_prompt

* Prevent pep8 line ends with a space error
This commit is contained in:
Matt Martz 2017-05-01 10:18:15 -05:00 committed by Brian Coca
commit 040fb4435a
2 changed files with 83 additions and 4 deletions

View file

@ -254,10 +254,8 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
return False
elif isinstance(self._play_context.prompt, string_types):
b_prompt = to_bytes(self._play_context.prompt).strip()
b_lines = b_output.splitlines(True)
if not b_lines:
return False
return b_lines[-1].strip().endswith(b_prompt) or b_lines[0].strip().endswith(b_prompt)
b_lines = b_output.splitlines()
return any(l.strip().startswith(b_prompt) for l in b_lines)
else:
return self._play_context.prompt(b_output)