]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add CI test validating the new varlink interface and more 35074/head
authorLennart Poettering <lennart@poettering.net>
Wed, 6 Nov 2024 22:47:37 +0000 (23:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 2 Jan 2025 15:39:33 +0000 (16:39 +0100)
test/units/TEST-74-AUX-UTILS.ask-password.sh [new file with mode: 0755]

diff --git a/test/units/TEST-74-AUX-UTILS.ask-password.sh b/test/units/TEST-74-AUX-UTILS.ask-password.sh
new file mode 100755 (executable)
index 0000000..1ae1df1
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -eux
+set -o pipefail
+
+# shellcheck source=test/units/util.sh
+. "$(dirname "$0")"/util.sh
+
+at_exit() {
+    set +e
+    systemctl stop waldo-ask-pw-agent.service
+}
+
+trap at_exit EXIT
+
+systemd-ask-password --help
+systemd-tty-ask-password-agent --list
+
+varlinkctl introspect /run/systemd/io.systemd.AskPassword
+
+# Spawn an agent that always replies all ask password requests with "waldo"
+systemd-run -u waldo-ask-pw-agent.service -p Environment=SYSTEMD_ASK_PASSWORD_AGENT_PASSWORD=waldo -p Type=notify /usr/bin/systemd-tty-ask-password-agent --watch --console=/dev/console
+assert_eq "$(systemd-ask-password --no-tty)" "waldo"
+assert_eq "$(varlinkctl call /usr/bin/systemd-ask-password io.systemd.AskPassword.Ask '{"message":"foobar"}' | jq '.passwords[0]')" "\"waldo\""