Skip to content

[autobackport: sssd-2-11] adding sss_ssh_knownhosts test case#8492

Open
sssd-bot wants to merge 1 commit intoSSSD:sssd-2-11from
sssd-bot:SSSD-sssd-backport-pr8448-to-sssd-2-11
Open

[autobackport: sssd-2-11] adding sss_ssh_knownhosts test case#8492
sssd-bot wants to merge 1 commit intoSSSD:sssd-2-11from
sssd-bot:SSSD-sssd-backport-pr8448-to-sssd-2-11

Conversation

@sssd-bot
Copy link
Contributor

@sssd-bot sssd-bot commented Mar 4, 2026

This is an automatic backport of PR#8448 adding sss_ssh_knownhosts test case to branch sssd-2-11, created by @danlavu.

Please make sure this backport is correct.

Note

The commits were cherry-picked without conflicts.

You can push changes to this pull request

git remote add sssd-bot git@github.com:sssd-bot/sssd.git
git fetch sssd-bot refs/heads/SSSD-sssd-backport-pr8448-to-sssd-2-11
git checkout SSSD-sssd-backport-pr8448-to-sssd-2-11
git push sssd-bot SSSD-sssd-backport-pr8448-to-sssd-2-11 --force

Original commits
b4e88e8 - adding sss_ssh_knownhosts test case

Backported commits

  • 93c0c7a - adding sss_ssh_knownhosts test case

Original Pull Request Body

Reviewed-by: Anuj Borah <aborah@redhat.com>
Reviewed-by: Alejandro López <allopez@redhat.com>
(cherry picked from commit b4e88e8)
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 backports a test case for the sss_ssh_knownhosts tool to the sssd-2-11 branch. The new test verifies the tool's ability to resolve hostnames and IP addresses correctly. I have added a review comment to address a potential issue with error handling in the test case.

Comment on lines +89 to +91
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]}!"

Choose a reason for hiding this comment

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

high

The current implementation asserts that the _search_value is present or not present in the stderr_lines. However, it does not check the return code of the sss_ssh_knownhosts command. If the command fails for other reasons (e.g., invalid arguments, sssd not running), the test might pass incorrectly if the expected error message happens to be present. It is recommended to assert the return code to ensure the command behaves as expected.

Consider adding assert result.returncode == 0 when host[1] is True and assert result.returncode != 0 when host[1] is False.

Suggested change
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]}!"
if host[1]:
assert result.returncode == 0, f"Expected return code 0 for {host[0]}, but got {result.returncode}"
assert not any(_search_value in line for line in result.stderr_lines), f"Should have succeeded for {host[0]}!"
else:
assert result.returncode != 0, f"Expected non-zero return code for {host[0]}, but got {result.returncode}"
assert any(_search_value in line for line in result.stderr_lines), f"Should have failed for {host[0]}!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants