From 216231770e33f9ffd6875941b4cd26e5600c4f4f Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye Date: Thu, 4 Jul 2024 16:27:09 +0530 Subject: [PATCH] Test: housekeeping: test_sss_ssh_knownhosts.py => test_ipa.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the docstring of each test. Update the test case method name. Added assertion error messages on failures. Signed-off-by: Madhuri Upadhye Reviewed-by: Dan Lavu Reviewed-by: Jakub Vávra --- .../public_keys | 0 ...test_sss_ssh_knownhosts.py => test_ipa.py} | 54 ++++++++++--------- 2 files changed, 28 insertions(+), 26 deletions(-) rename src/tests/system/data/{test_sss_ssh_knownhosts => test_ipa}/public_keys (100%) rename src/tests/system/tests/{test_sss_ssh_knownhosts.py => test_ipa.py} (59%) diff --git a/src/tests/system/data/test_sss_ssh_knownhosts/public_keys b/src/tests/system/data/test_ipa/public_keys similarity index 100% rename from src/tests/system/data/test_sss_ssh_knownhosts/public_keys rename to src/tests/system/data/test_ipa/public_keys diff --git a/src/tests/system/tests/test_sss_ssh_knownhosts.py b/src/tests/system/tests/test_ipa.py similarity index 59% rename from src/tests/system/tests/test_sss_ssh_knownhosts.py rename to src/tests/system/tests/test_ipa.py index da29e22fe64..6da55b7d250 100644 --- a/src/tests/system/tests/test_sss_ssh_knownhosts.py +++ b/src/tests/system/tests/test_ipa.py @@ -1,7 +1,10 @@ """ -sss_ssh_knownhosts tests. +IPA SSH Public Host Keys Tests. -:requirement: Support 'KnownHostsCommand' and deprecate 'sss_ssh_knownhostsproxy' +:requirement: IPA: hostpublickeys + +sss_ssh_knownhosts acquires SSH public keys for host and outputs them in OpenSSH known_hosts key format. +Support for 'KnownHostsCommand' and deprecate 'sss_ssh_knownhostsproxy' """ from __future__ import annotations @@ -33,46 +36,45 @@ def public_keys(moduledatadir: str) -> list[str]: @pytest.mark.ticket(gh=5518) @pytest.mark.importance("low") @pytest.mark.topology(KnownTopology.IPA) -def test_sss_ssh_knownhosts__by_name(client: Client, ipa: IPA, public_keys: list[str]): +def test_ipa__hostpublickeys_by_name(client: Client, ipa: IPA, public_keys: list[str]): """ :title: sss_ssh_knownhosts returns public keys by name :setup: - 1. Create IPA host "ssh.ipa.test", public keys and IP resolvable via DNS - 2. Enable ssh responder + 1. Create host with SSH key + 2. Configure SSSD with SSH responder 3. Start SSSD :steps: - 1. Run "sss_ssh_knownhosts ssh.ipa.test" + 1. Lookup SSH key :expectedresults: 1. All public keys were printed :customerscenario: False """ hostname = f"ssh.{ipa.domain}" ip = "10.255.251.10" - ipa.host_account(hostname).add(ip=ip, sshpubkey=public_keys) + ipa.host_account(hostname).add(ip=ip, sshpubkey=public_keys) client.sssd.enable_responder("ssh") client.sssd.start() result = client.sss_ssh_knownhosts(hostname) - assert result.rc == 0 - assert len(public_keys) == len(result.stdout_lines) + assert result.rc == 0, "Did not get OpenSSH known hosts public keys!" + assert len(public_keys) == len(result.stdout_lines), "Did not get expected number of public keys!" for key in public_keys: - assert f"{hostname} {key}" in result.stdout_lines + assert f"{hostname} {key}" in result.stdout_lines, "Did not get expected public keys!" @pytest.mark.ticket(gh=5518) @pytest.mark.importance("low") @pytest.mark.topology(KnownTopology.IPA) -def test_sss_ssh_knownhosts__by_shortname(client: Client, ipa: IPA, public_keys: list[str]): +def test_ipa__hostpublickeys_by_shortname(client: Client, ipa: IPA, public_keys: list[str]): """ :title: sss_ssh_knownhosts returns public keys by short name using the search domain :setup: - 1. Create IPA host "ssh.ipa.test", public keys and IP resolvable via DNS - 2. Add "search ipa.test" to /etc/resolv.conf - 3. Enable ssh responder - 4. Start SSSD + 1. Create host with SSH key and add "search ipa.test" to /etc/resolv.conf + 2. Configure SSSD with SSH responder + 3. Start SSSD :steps: - 1. Run "sss_ssh_knownhosts ssh" + 1. Lookup SSH key by running "sss_ssh_knownhosts ssh" :expectedresults: 1. All public keys were printed :customerscenario: False @@ -86,24 +88,24 @@ def test_sss_ssh_knownhosts__by_shortname(client: Client, ipa: IPA, public_keys: client.sssd.start() result = client.sss_ssh_knownhosts("ssh") - assert result.rc == 0 - assert len(public_keys) == len(result.stdout_lines) + assert result.rc == 0, "Did not get OpenSSH known hosts public keys!" + assert len(public_keys) == len(result.stdout_lines), "Did not get expected number of public keys!" for key in public_keys: - assert f"ssh {key}" in result.stdout_lines + assert f"ssh {key}" in result.stdout_lines, "Did not get expected public keys!" @pytest.mark.ticket(gh=5518) @pytest.mark.importance("low") @pytest.mark.topology(KnownTopology.IPA) -def test_sss_ssh_knownhosts__by_ip(client: Client, ipa: IPA, public_keys: list[str]): +def test_ipa__hostpublickeys_by_ip(client: Client, ipa: IPA, public_keys: list[str]): """ :title: sss_ssh_knownhosts returns public keys by IP :setup: - 1. Create IPA host "ssh.ipa.test", public keys and IP resolvable via DNS - 2. Enable ssh responder + 1. Create host with SSH key + 2. Configure SSSD with SSH responder 3. Start SSSD :steps: - 1. Run "sss_ssh_knownhosts $ip" + 1. Lookup SSH key by running "sss_ssh_knownhosts $ip" :expectedresults: 1. All public keys were printed :customerscenario: False @@ -116,7 +118,7 @@ def test_sss_ssh_knownhosts__by_ip(client: Client, ipa: IPA, public_keys: list[s client.sssd.start() result = client.sss_ssh_knownhosts(ip) - assert result.rc == 0 - assert len(public_keys) == len(result.stdout_lines) + assert result.rc == 0, "Did not get OpenSSH known hosts public keys!" + assert len(public_keys) == len(result.stdout_lines), "Did not get expected number of public keys!" for key in public_keys: - assert f"{ip} {key}" in result.stdout_lines + assert f"{ip} {key}" in result.stdout_lines, "Did not get expected public keys!"