Skip to content

adding sss_ssh_knownhosts test case#8448

Open
danlavu wants to merge 1 commit intoSSSD:masterfrom
danlavu:tests-sss_ssh_knownhosts
Open

adding sss_ssh_knownhosts test case#8448
danlavu wants to merge 1 commit intoSSSD:masterfrom
danlavu:tests-sss_ssh_knownhosts

Conversation

@danlavu
Copy link

@danlavu danlavu commented Feb 13, 2026

No description provided.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new test case for sss_ssh_knownhosts to verify hostname and IP address resolution. My review found a critical bug in the test's assertion logic, an incorrect type hint, and a misleading test ID. These issues could cause the test to behave incorrectly or be difficult to debug, and I have provided suggestions to fix them.

assert result is not None, f"sss_ssh_knownhosts did not run properly!"
assert isinstance(result, list), f"Expected output to be a list of lines, got {type(result)} instead!"
if host[1] == 0:
assert any("0x0040" not in line for line in result), f"{host[0]} should have been found but was not!"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The assertion logic to check for a successfully found host is incorrect. any("0x0040" not in line for line in result) will pass if any line in the output doesn't contain "0x0040", even if an error line with "0x0040" exists. This can cause the test to pass when it should fail. The logic should be inverted to ensure no line contains the error code.

Suggested change
assert any("0x0040" not in line for line in result), f"{host[0]} should have been found but was not!"
assert not any("0x0040" in line for line in result), f"{host[0]} should have been found but was not!"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug level 0x0040 is used by several messages which may indicated an error but not the error you are looking for. Maybe you should look for the "Name or service not known" string instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The messages are in two different outputs, stdout and stderr. We can assert by that, take a look.

The test is passing.

============================= test session starts ==============================
collecting ... 

Selected tests will use the following hosts:
  client: client.test
  kdc: kdc.test

collected 6 items

tests/test_tools.py::test_tools__sss_cache_expired_does_not_print_unrelated_message (client) 
tests/test_tools.py::test_tools__sss_ssh_knownhosts_resolves_hostnames_and_ips[client.io] (client) 
tests/test_tools.py::test_tools__sss_ssh_knownhosts_resolves_hostnames_and_ips[1.1.1.1] (client) 
tests/test_tools.py::test_tools__sss_ssh_knownhosts_resolves_hostnames_and_ips[client.test] (client) 
tests/test_tools.py::test_tools__sss_ssh_knownhosts_resolves_hostnames_and_ips[asdf.test] (client) 
tests/test_tools.py::test_tools__sss_ssh_knownhosts_resolves_hostnames_and_ips[super.bad.hostname] (client) 

============================== 6 passed in 12.81s ==============================
PASSED [ 16%]PASSED [ 33%]PASSED [ 50%]PASSED [ 66%]PASSED [ 83%]PASSED [100%]
Process finished with exit code 0

assert result is not None, f"sss_ssh_knownhosts did not run properly!"
assert isinstance(result, list), f"Expected output to be a list of lines, got {type(result)} instead!"
if host[1] == 0:
assert any("0x0040" not in line for line in result), f"{host[0]} should have been found but was not!"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug level 0x0040 is used by several messages which may indicated an error but not the error you are looking for. Maybe you should look for the "Name or service not known" string instead.

@danlavu danlavu force-pushed the tests-sss_ssh_knownhosts branch 2 times, most recently from 479a3fa to a84b507 Compare February 13, 2026 16:15
@danlavu danlavu force-pushed the tests-sss_ssh_knownhosts branch 2 times, most recently from 9f3cce3 to 73e24a5 Compare February 13, 2026 21:47
Copy link
Contributor

@aplopez aplopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@danlavu danlavu force-pushed the tests-sss_ssh_knownhosts branch from 73e24a5 to 212c9fb Compare February 24, 2026 01:45
Reviewed-by: Anuj Borah <aborah@redhat.com>
Reviewed-by: Alejandro López <allopez@redhat.com>
@sssd-bot
Copy link
Contributor

The pull request was accepted by @aplopez with the following PR CI status:


🟢 CodeQL (success)
🟢 osh-diff-scan:fedora-rawhide-x86_64:upstream (success)
🟢 rpm-build:centos-stream-10-x86_64:upstream (success)
🟢 rpm-build:fedora-42-x86_64:upstream (success)
🟢 rpm-build:fedora-43-x86_64:upstream (success)
🟢 rpm-build:fedora-44-x86_64:upstream (success)
🟢 rpm-build:fedora-rawhide-x86_64:upstream (success)
🟢 Analyze (target) / cppcheck (success)
🟢 ci / intgcheck (centos-10) (success)
🟢 ci / intgcheck (fedora-42) (success)
🟢 ci / intgcheck (fedora-43) (success)
🟢 ci / intgcheck (fedora-44) (success)
🟢 ci / intgcheck (fedora-45) (success)
🟢 ci / prepare (success)
🟢 ci / system (centos-10) (success)
🟢 ci / system (fedora-42) (success)
🟢 ci / system (fedora-43) (success)
🟢 ci / system (fedora-44) (success)
🟢 ci / system (fedora-45) (success)
➖ Coverity scan / coverity (skipped)
🟢 Static code analysis / codeql (success)
🟢 Static code analysis / pre-commit (success)
🟢 Static code analysis / python-system-tests (success)


There are unsuccessful or unfinished checks. Make sure that the failures are not related to this pull request before merging.

@sssd-bot sssd-bot force-pushed the tests-sss_ssh_knownhosts branch from 212c9fb to 3e19e0d Compare February 24, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants