Skip to content

Commit

Permalink
Fix non-interactive sudo test
Browse files Browse the repository at this point in the history
`sudo -nv` can be used to verify whether the sudo command is prepared
to execute commands non-interactively, i.e. it will not ask for a
password.

If the password has already been cached by previous sudo commands, or
sudo is configured to give passwordless access, we can move on.
Otherwise, interactive sudo or lack of sudo access cannot be used to
run tests in an automated fashion.
  • Loading branch information
lunkwill42 committed Sep 20, 2024
1 parent 8735bde commit 9826572
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/integration/pping_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_pping_should_post_event_when_host_is_unreachable(
def get_root_method():
if os.geteuid() == 0:
return []
elif os.system("sudo true") == 0:
elif os.system("sudo -nv") == 0:
return ["sudo", "-E"]
elif os.system("gosu root true") == 0:
return ["gosu", "root"]
Expand Down

0 comments on commit 9826572

Please sign in to comment.