[autobackport: sssd-2-11] adding sss_ssh_knownhosts test case#8492
[autobackport: sssd-2-11] adding sss_ssh_knownhosts test case#8492sssd-bot wants to merge 1 commit intoSSSD:sssd-2-11from
Conversation
Reviewed-by: Anuj Borah <aborah@redhat.com> Reviewed-by: Alejandro López <allopez@redhat.com> (cherry picked from commit b4e88e8)
There was a problem hiding this comment.
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.
| 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]}!" |
There was a problem hiding this comment.
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.
| 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]}!" |
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
Original commits
b4e88e8 - adding sss_ssh_knownhosts test case
Backported commits
Original Pull Request Body