Skip to content

Commit 93c0c7a

Browse files
Dan Lavunext-actions/backport
authored andcommitted
adding sss_ssh_knownhosts test case
Reviewed-by: Anuj Borah <aborah@redhat.com> Reviewed-by: Alejandro López <allopez@redhat.com> (cherry picked from commit b4e88e8)
1 parent b07baee commit 93c0c7a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/tests/system/tests/test_tools.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,33 @@ def test_tools__sss_cache_expired_does_not_print_unrelated_message(client: Clien
5959
assert (
6060
"No domains configured, fatal error!" not in res.stdout
6161
), "'No domains configured, fatal error!' printed to stdout!"
62+
63+
64+
@pytest.mark.importance("medium")
65+
@pytest.mark.topology(KnownTopology.Client)
66+
@pytest.mark.ticket(gh=7664)
67+
@pytest.mark.parametrize(
68+
"host",
69+
[("sssd.io", True), ("1.1.1.1", True), ("client.test", True), ("asdf.test", False), ("super.bad.hostname", False)],
70+
ids=["sssd.io", "1.1.1.1", "client.test", "asdf.test", "super.bad.hostname"],
71+
)
72+
def test_tools__sss_ssh_knownhosts_resolves_hostnames_and_ips(client: Client, host: tuple[str, bool]):
73+
"""
74+
:title: sss_ssh_knownhosts resolution of hostnames and IP addresses.
75+
:setup:
76+
:steps:
77+
1. Look up parameterized hosts using sss_ssh_knownhosts
78+
:expectedresults:
79+
1. Host is found or not found without errors
80+
:customerscenario: True
81+
"""
82+
result = client.host.conn.run(f"sss_ssh_knownhosts --debug=5 {host[0]}")
83+
assert result is not None, "sss_ssh_knownhosts did not run properly!"
84+
assert result.stderr_lines is not None, "sss_ssh_knownhosts did not print any debug output!"
85+
86+
_search_value = "getaddrinfo() failed (-2): Name or service not known"
87+
88+
if host[1]:
89+
assert not any(_search_value in line for line in result.stderr_lines), f"Should have succeeded for {host[0]}!"
90+
else:
91+
assert any(_search_value in line for line in result.stderr_lines), f"Should have failed for {host[0]}!"

0 commit comments

Comments
 (0)