From 9826572cbc4ecc11d3520533f6b7a63504bb29ce Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Tue, 6 Jun 2023 10:22:17 +0200 Subject: [PATCH] Fix non-interactive sudo test `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. --- tests/integration/pping_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/pping_test.py b/tests/integration/pping_test.py index 56295d91a1..6fb4181621 100644 --- a/tests/integration/pping_test.py +++ b/tests/integration/pping_test.py @@ -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"]