mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
parent
8e0b89bdbf
commit
7eab802669
2 changed files with 7 additions and 6 deletions
|
@ -610,6 +610,7 @@ class Connection(ConnectionBase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
poll = p.poll()
|
||||||
events = selector.select(timeout)
|
events = selector.select(timeout)
|
||||||
|
|
||||||
# We pay attention to timeouts only while negotiating a prompt.
|
# We pay attention to timeouts only while negotiating a prompt.
|
||||||
|
@ -619,7 +620,7 @@ class Connection(ConnectionBase):
|
||||||
if state <= states.index('awaiting_escalation'):
|
if state <= states.index('awaiting_escalation'):
|
||||||
# If the process has already exited, then it's not really a
|
# If the process has already exited, then it's not really a
|
||||||
# timeout; we'll let the normal error handling deal with it.
|
# timeout; we'll let the normal error handling deal with it.
|
||||||
if p.poll() is not None:
|
if poll is not None:
|
||||||
break
|
break
|
||||||
self._terminate_process(p)
|
self._terminate_process(p)
|
||||||
raise AnsibleError('Timeout (%ds) waiting for privilege escalation prompt: %s' % (timeout, to_native(b_stdout)))
|
raise AnsibleError('Timeout (%ds) waiting for privilege escalation prompt: %s' % (timeout, to_native(b_stdout)))
|
||||||
|
@ -721,7 +722,7 @@ class Connection(ConnectionBase):
|
||||||
# Now we're awaiting_exit: has the child process exited? If it has,
|
# Now we're awaiting_exit: has the child process exited? If it has,
|
||||||
# and we've read all available output from it, we're done.
|
# and we've read all available output from it, we're done.
|
||||||
|
|
||||||
if p.poll() is not None:
|
if poll is not None:
|
||||||
if not selector.get_map() or not events:
|
if not selector.get_map() or not events:
|
||||||
break
|
break
|
||||||
# We should not see further writes to the stdout/stderr file
|
# We should not see further writes to the stdout/stderr file
|
||||||
|
|
|
@ -415,7 +415,7 @@ class TestSSHConnectionRun(object):
|
||||||
self.conn._flags['become_success'] = True
|
self.conn._flags['become_success'] = True
|
||||||
return (b'', b'')
|
return (b'', b'')
|
||||||
|
|
||||||
def test_pasword_with_prompt(self):
|
def test_password_with_prompt(self):
|
||||||
# test with password prompting enabled
|
# test with password prompting enabled
|
||||||
self.pc.password = None
|
self.pc.password = None
|
||||||
self.pc.prompt = b'Password:'
|
self.pc.prompt = b'Password:'
|
||||||
|
@ -440,7 +440,7 @@ class TestSSHConnectionRun(object):
|
||||||
assert self.conn._send_initial_data.call_count == 1
|
assert self.conn._send_initial_data.call_count == 1
|
||||||
assert self.conn._send_initial_data.call_args[0][1] == 'this is input data'
|
assert self.conn._send_initial_data.call_args[0][1] == 'this is input data'
|
||||||
|
|
||||||
def test_pasword_with_become(self):
|
def test_password_with_become(self):
|
||||||
# test with some become settings
|
# test with some become settings
|
||||||
self.pc.prompt = b'Password:'
|
self.pc.prompt = b'Password:'
|
||||||
self.pc.become = True
|
self.pc.become = True
|
||||||
|
@ -550,8 +550,8 @@ class TestSSHConnectionRetries(object):
|
||||||
|
|
||||||
monkeypatch.setattr('time.sleep', lambda x: None)
|
monkeypatch.setattr('time.sleep', lambda x: None)
|
||||||
|
|
||||||
self.mock_popen_res.stdout.read.side_effect = [b""] * 11
|
self.mock_popen_res.stdout.read.side_effect = [b""] * 10
|
||||||
self.mock_popen_res.stderr.read.side_effect = [b""] * 11
|
self.mock_popen_res.stderr.read.side_effect = [b""] * 10
|
||||||
type(self.mock_popen_res).returncode = PropertyMock(side_effect=[255] * 30)
|
type(self.mock_popen_res).returncode = PropertyMock(side_effect=[255] * 30)
|
||||||
|
|
||||||
self.mock_selector.select.side_effect = [
|
self.mock_selector.select.side_effect = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue