summaryrefslogtreecommitdiff
path: root/tests/unittests/config/test_cc_set_passwords.py
diff options
context:
space:
mode:
authorBrett Holman <brett.holman@canonical.com>2023-04-19 16:12:55 -0600
committerGitHub <noreply@github.com>2023-04-19 16:12:55 -0600
commit5942f4023e2581a43f31d547995095ca49954353 (patch)
tree510009a412671c4adb041c05fc803db1ea4e8c22 /tests/unittests/config/test_cc_set_passwords.py
parent9e4cb4f06b2e362889bcbda77ef6fad52afed52b (diff)
downloadcloud-init-git-5942f4023e2581a43f31d547995095ca49954353.tar.gz
[1/2] DHCP: Refactor dhcp client code (#2122)
Move isc-dhclient code to dhcp.py In support of the upcoming deprecation of isc-dhcp-client, this code refactors current dhcp code into classes in dhcp.py. The primary user-visible change should be the addition of the following log: dhcp.py[DEBUG]: DHCP client selected: dhclient This code lays groundwork to enable alternate implementations to live side by side in the codebase to be selected with distro-defined priority fallback. Note that maybe_perform_dhcp_discovery() now selects which dhcp client to call, and then runs the corresponding client's dhcp_discovery() method. Currently only class IscDhclient is implemented, however a yet-to-be-implemented class Dhcpcd exists to test fallback behavior and this will be implemented in part two of this series. Part of this refactor includes shifting dhclient service management from hardcoded calls to the distro-defined manage_service() method in the *BSDs. Future work is required in this area to support multiple clients via select_dhcp_client().
Diffstat (limited to 'tests/unittests/config/test_cc_set_passwords.py')
-rw-r--r--tests/unittests/config/test_cc_set_passwords.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/tests/unittests/config/test_cc_set_passwords.py b/tests/unittests/config/test_cc_set_passwords.py
index f6885b2b..1a9fcd3c 100644
--- a/tests/unittests/config/test_cc_set_passwords.py
+++ b/tests/unittests/config/test_cc_set_passwords.py
@@ -20,8 +20,12 @@ LOG = logging.getLogger(__name__)
SYSTEMD_CHECK_CALL = mock.call(
["systemctl", "show", "--property", "ActiveState", "--value", "ssh"]
)
-SYSTEMD_RESTART_CALL = mock.call(["systemctl", "restart", "ssh"], capture=True)
-SERVICE_RESTART_CALL = mock.call(["service", "ssh", "restart"], capture=True)
+SYSTEMD_RESTART_CALL = mock.call(
+ ["systemctl", "restart", "ssh"], capture=True, rcs=None
+)
+SERVICE_RESTART_CALL = mock.call(
+ ["service", "ssh", "restart"], capture=True, rcs=None
+)
@pytest.fixture(autouse=True)
@@ -46,7 +50,6 @@ class TestHandleSSHPwauth:
(True, True, "activating"),
(True, True, "inactive"),
(True, False, None),
- (False, True, None),
(False, False, None),
),
)
@@ -79,10 +82,6 @@ class TestHandleSSHPwauth:
assert SYSTEMD_RESTART_CALL in m_subp.call_args_list
else:
assert SYSTEMD_RESTART_CALL not in m_subp.call_args_list
- else:
- assert SERVICE_RESTART_CALL in m_subp.call_args_list
- assert SYSTEMD_CHECK_CALL not in m_subp.call_args_list
- assert SYSTEMD_RESTART_CALL not in m_subp.call_args_list
@mock.patch(f"{MODPATH}update_ssh_config", return_value=True)
@mock.patch("cloudinit.distros.subp.subp")
@@ -728,6 +727,3 @@ class TestSetPasswordsSchema:
def test_schema_validation(self, config, expectation):
with expectation:
validate_cloudconfig_schema(config, get_schema(), strict=True)
-
-
-# vi: ts=4 expandtab