From e464771902c360b3660c0eed00efd8e294a3d1b5 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 Update the docstring of each test. Update the test case method name. Added assertion error messages on failures. Signed-off-by: Madhuri Upadhye --- .../public_keys | 0 ...test_sss_ssh_knownhosts.py => test_ipa.py} | 51 ++++++++++--------- 2 files changed, 26 insertions(+), 25 deletions(-) rename src/tests/system/data/{test_sss_ssh_knownhosts => ipa}/public_keys (100%) rename src/tests/system/tests/{test_sss_ssh_knownhosts.py => test_ipa.py} (61%) diff --git a/src/tests/system/data/test_sss_ssh_knownhosts/public_keys b/src/tests/system/data/ipa/public_keys similarity index 100% rename from src/tests/system/data/test_sss_ssh_knownhosts/public_keys rename to src/tests/system/data/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 61% rename from src/tests/system/tests/test_sss_ssh_knownhosts.py rename to src/tests/system/tests/test_ipa.py index da29e22fe64..8af31f55f39 100644 --- a/src/tests/system/tests/test_sss_ssh_knownhosts.py +++ b/src/tests/system/tests/test_ipa.py @@ -1,7 +1,9 @@ """ sss_ssh_knownhosts 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. """ from __future__ import annotations @@ -33,46 +35,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 +87,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 +117,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!"