remove deprecated connection password functions (#74155)
* they were moved from connecitons to become plugins * fixed clog, removed sanity ignore * fixed tests to use become functions
This commit is contained in:
parent
45ab6fddf3
commit
b07a78b4ba
5 changed files with 19 additions and 50 deletions
2
changelogs/fragments/remove_connection_become_checks.yml
Normal file
2
changelogs/fragments/remove_connection_become_checks.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
removed_features:
|
||||
- connections, removed password check stubs that had been moved to become plugins.
|
|
@ -229,39 +229,6 @@ class ConnectionBase(AnsiblePlugin):
|
|||
def reset(self):
|
||||
display.warning("Reset is not implemented for this connection")
|
||||
|
||||
# NOTE: these password functions are all become specific, the name is
|
||||
# confusing as it does not handle 'protocol passwords'
|
||||
# DEPRECATED:
|
||||
# These are kept for backwards compatibility
|
||||
# Use the methods provided by the become plugins instead
|
||||
def check_become_success(self, b_output):
|
||||
display.deprecated(
|
||||
"Connection.check_become_success is deprecated, calling code should be using become plugins instead",
|
||||
version="2.12", collection_name='ansible.builtin'
|
||||
)
|
||||
return self.become.check_success(b_output)
|
||||
|
||||
def check_password_prompt(self, b_output):
|
||||
display.deprecated(
|
||||
"Connection.check_password_prompt is deprecated, calling code should be using become plugins instead",
|
||||
version="2.12", collection_name='ansible.builtin'
|
||||
)
|
||||
return self.become.check_password_prompt(b_output)
|
||||
|
||||
def check_incorrect_password(self, b_output):
|
||||
display.deprecated(
|
||||
"Connection.check_incorrect_password is deprecated, calling code should be using become plugins instead",
|
||||
version="2.12", collection_name='ansible.builtin'
|
||||
)
|
||||
return self.become.check_incorrect_password(b_output)
|
||||
|
||||
def check_missing_password(self, b_output):
|
||||
display.deprecated(
|
||||
"Connection.check_missing_password is deprecated, calling code should be using become plugins instead",
|
||||
version="2.12", collection_name='ansible.builtin'
|
||||
)
|
||||
return self.become.check_missing_password(b_output)
|
||||
|
||||
|
||||
class NetworkConnectionBase(ConnectionBase):
|
||||
"""
|
||||
|
|
|
@ -155,7 +155,6 @@ lib/ansible/plugins/action/async_status.py pylint:ansible-deprecated-version
|
|||
lib/ansible/plugins/action/normal.py action-plugin-docs # default action plugin for modules without a dedicated action plugin
|
||||
lib/ansible/plugins/cache/__init__.py pylint:ansible-deprecated-version
|
||||
lib/ansible/plugins/cache/base.py ansible-doc!skip # not a plugin, but a stub for backwards compatibility
|
||||
lib/ansible/plugins/connection/__init__.py pylint:ansible-deprecated-version
|
||||
lib/ansible/plugins/inventory/__init__.py pylint:ansible-deprecated-version
|
||||
lib/ansible/plugins/inventory/script.py pylint:ansible-deprecated-version
|
||||
lib/ansible/plugins/lookup/sequence.py pylint:blacklisted-name
|
||||
|
|
|
@ -160,10 +160,10 @@ debug1: Sending command: /bin/sh -c 'sudo -H -S -p "[sudo via ansible, key=ouzm
|
|||
c.set_become_plugin(become_loader.get('sudo'))
|
||||
c.become.prompt = '[sudo via ansible, key=ouzmdnewuhucvuaabtjmweasarviygqq] password: '
|
||||
|
||||
self.assertTrue(c.check_password_prompt(local))
|
||||
self.assertTrue(c.check_password_prompt(ssh_pipelining_vvvv))
|
||||
self.assertTrue(c.check_password_prompt(ssh_nopipelining_vvvv))
|
||||
self.assertTrue(c.check_password_prompt(ssh_novvvv))
|
||||
self.assertTrue(c.check_password_prompt(dns_issue))
|
||||
self.assertFalse(c.check_password_prompt(nothing))
|
||||
self.assertFalse(c.check_password_prompt(in_front))
|
||||
self.assertTrue(c.become.check_password_prompt(local))
|
||||
self.assertTrue(c.become.check_password_prompt(ssh_pipelining_vvvv))
|
||||
self.assertTrue(c.become.check_password_prompt(ssh_nopipelining_vvvv))
|
||||
self.assertTrue(c.become.check_password_prompt(ssh_novvvv))
|
||||
self.assertTrue(c.become.check_password_prompt(dns_issue))
|
||||
self.assertFalse(c.become.check_password_prompt(nothing))
|
||||
self.assertFalse(c.become.check_password_prompt(in_front))
|
||||
|
|
|
@ -104,10 +104,10 @@ class TestConnectionBaseClass(unittest.TestCase):
|
|||
conn = connection_loader.get('ssh', pc, new_stdin)
|
||||
conn.set_become_plugin(become_loader.get('sudo'))
|
||||
|
||||
conn.check_password_prompt = MagicMock()
|
||||
conn.check_become_success = MagicMock()
|
||||
conn.check_incorrect_password = MagicMock()
|
||||
conn.check_missing_password = MagicMock()
|
||||
conn.become.check_password_prompt = MagicMock()
|
||||
conn.become.check_success = MagicMock()
|
||||
conn.become.check_incorrect_password = MagicMock()
|
||||
conn.become.check_missing_password = MagicMock()
|
||||
|
||||
def _check_password_prompt(line):
|
||||
if b'foo' in line:
|
||||
|
@ -129,11 +129,6 @@ class TestConnectionBaseClass(unittest.TestCase):
|
|||
return True
|
||||
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
|
||||
conn._flags = dict(
|
||||
become_prompt=False,
|
||||
|
@ -143,7 +138,13 @@ class TestConnectionBaseClass(unittest.TestCase):
|
|||
)
|
||||
|
||||
pc.prompt = True
|
||||
|
||||
# override become plugin
|
||||
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):
|
||||
if option == 'become_pass':
|
||||
|
|
Loading…
Reference in a new issue