From 3e19e0d33bca77017ff453240abcdebac2e0de46 Mon Sep 17 00:00:00 2001 From: Dan Lavu Date: Fri, 13 Feb 2026 06:32:15 -0500 Subject: [PATCH] adding sss_ssh_knownhosts test case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Anuj Borah Reviewed-by: Alejandro López --- src/tests/system/tests/test_tools.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/tests/system/tests/test_tools.py b/src/tests/system/tests/test_tools.py index 05620e3255e..405e10f72d1 100644 --- a/src/tests/system/tests/test_tools.py +++ b/src/tests/system/tests/test_tools.py @@ -59,3 +59,33 @@ def test_tools__sss_cache_expired_does_not_print_unrelated_message(client: Clien assert ( "No domains configured, fatal error!" not in res.stdout ), "'No domains configured, fatal error!' printed to stdout!" + + +@pytest.mark.importance("medium") +@pytest.mark.topology(KnownTopology.Client) +@pytest.mark.ticket(gh=7664) +@pytest.mark.parametrize( + "host", + [("sssd.io", True), ("1.1.1.1", True), ("client.test", True), ("asdf.test", False), ("super.bad.hostname", False)], + ids=["sssd.io", "1.1.1.1", "client.test", "asdf.test", "super.bad.hostname"], +) +def test_tools__sss_ssh_knownhosts_resolves_hostnames_and_ips(client: Client, host: tuple[str, bool]): + """ + :title: sss_ssh_knownhosts resolution of hostnames and IP addresses. + :setup: + :steps: + 1. Look up parameterized hosts using sss_ssh_knownhosts + :expectedresults: + 1. Host is found or not found without errors + :customerscenario: True + """ + result = client.host.conn.run(f"sss_ssh_knownhosts --debug=5 {host[0]}") + assert result is not None, "sss_ssh_knownhosts did not run properly!" + assert result.stderr_lines is not None, "sss_ssh_knownhosts did not print any debug output!" + + _search_value = "getaddrinfo() failed (-2): Name or service not known" + + if host[1]: + assert not any(_search_value in line for line in result.stderr_lines), f"Should have succeeded for {host[0]}!" + else: + assert any(_search_value in line for line in result.stderr_lines), f"Should have failed for {host[0]}!"