From f35280b76478343bd05e3f33dc63cb69cdc2defd Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 18 Dec 2023 11:21:21 +0000 Subject: [PATCH] test(ssh): add json storage reading tests --- tests/test_ssh.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_ssh.py b/tests/test_ssh.py index 6cb255d..5c3414b 100644 --- a/tests/test_ssh.py +++ b/tests/test_ssh.py @@ -57,6 +57,31 @@ def get_raw_json_ssh_setting(setting: str): return (data.get("ssh") or {}).get(setting) +def test_read_json(possibly_undefined_ssh_settings): + with ReadUserData() as data: + if "ssh" not in data.keys(): + assert get_ssh_settings().enable is not None + assert get_ssh_settings().passwordAuthentication is not None + + # TODO: Is it really a good idea to have password ssh enabled by default? + assert get_ssh_settings().enable is True + assert get_ssh_settings().passwordAuthentication is True + return + + if "enable" not in data["ssh"].keys(): + assert get_ssh_settings().enable is True + else: + assert get_ssh_settings().enable == data["ssh"]["enable"] + + if "passwordAuthentication" not in data["ssh"].keys(): + assert get_ssh_settings().passwordAuthentication is True + else: + assert ( + get_ssh_settings().passwordAuthentication + == data["ssh"]["passwordAuthentication"] + ) + + def test_enabling_disabling_writes_json( possibly_undefined_ssh_settings, ssh_enable_spectrum, password_auth_spectrum ):