From 182cbb2026f4d4f93ac1840ce58a43df5c621ea8 Mon Sep 17 00:00:00 2001 From: Oliver Calder Date: Fri, 1 May 2026 16:52:20 -0500 Subject: [PATCH 1/7] tests: add audio-record prompting integration tests Signed-off-by: Oliver Calder --- .../audio_record_single.json | 84 +++++++++++++++++++ .../audio_record_single.sh | 79 +++++++++++++++++ .../audio_record_timespan_allow.json | 40 +++++++++ .../audio_record_timespan_allow.sh | 82 ++++++++++++++++++ .../audio_record_timespan_deny.json | 40 +++++++++ .../audio_record_timespan_deny.sh | 82 ++++++++++++++++++ .../prompt-requester/bin/cat | 3 + .../prompt-requester/bin/wait-for | 14 ++++ .../prompt-requester/meta/snap.yaml | 13 +++ .../task.yaml | 15 +++- 10 files changed, 451 insertions(+), 1 deletion(-) create mode 100644 tests/main/apparmor-prompting-integration-tests/audio_record_single.json create mode 100644 tests/main/apparmor-prompting-integration-tests/audio_record_single.sh create mode 100644 tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.json create mode 100644 tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh create mode 100644 tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.json create mode 100644 tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh create mode 100755 tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/cat create mode 100755 tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/wait-for create mode 100644 tests/main/apparmor-prompting-integration-tests/prompt-requester/meta/snap.yaml diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_single.json b/tests/main/apparmor-prompting-integration-tests/audio_record_single.json new file mode 100644 index 00000000000..5749673d5ec --- /dev/null +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_single.json @@ -0,0 +1,84 @@ +{ + "version": 1, + "prompt-filter": { + "snap": "prompt-requester", + "interface": "audio-record" + }, + "prompts": [ + { + "prompt-filter": { + "interface": "audio-record", + "constraints": { + "requested-permissions": [ "access" ] + } + }, + "reply": { + "action": "allow", + "lifespan": "single", + "constraints": { + "permissions": [ "access" ] + } + } + }, + { + "prompt-filter": { + "interface": "audio-record", + "constraints": { + "requested-permissions": [ "access" ] + } + }, + "reply": { + "action": "deny", + "lifespan": "single", + "constraints": { + "permissions": [ "access" ] + } + } + }, + { + "prompt-filter": { + "interface": "audio-record", + "constraints": { + "requested-permissions": [ "access" ] + } + }, + "reply": { + "action": "deny", + "lifespan": "single", + "constraints": { + "permissions": [ "access" ] + } + } + }, + { + "prompt-filter": { + "interface": "audio-record", + "constraints": { + "requested-permissions": [ "access" ] + } + }, + "reply": { + "action": "allow", + "lifespan": "single", + "constraints": { + "permissions": [ "access" ] + } + } + }, + { + "prompt-filter": { + "interface": "audio-record", + "constraints": { + "requested-permissions": [ "access" ] + } + }, + "reply": { + "action": "allow", + "lifespan": "single", + "constraints": { + "permissions": [ "access" ] + } + } + } + ] +} diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh new file mode 100644 index 00000000000..57b5d65cd6f --- /dev/null +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh @@ -0,0 +1,79 @@ +#!/usr/bin/sh + +# A test of allow once for the audio-record interface. + +TEST_DIR="$1" +TIMEOUT="$2" +if [ -z "$TIMEOUT" ] ; then + TIMEOUT=10 +fi + +SNAP_HOME="$HOME/snap/prompt-requester/current" + +# The audio-record interface doesn't use a target file to trigger a prompt. +# Instead, we use a file to tell the snap to finish running. We need a snap +# running under a cgroup in order for the "ask" request to be handled correctly. +TARGET_FILE="$SNAP_HOME/finish" +rm -f "$TARGET_FILE" + +# Start the snap running in the background so "ask" can use its PID to look up +# its cgroup, and from that derive the snap name. +prompt-requester.wait-for "$TARGET_FILE" & +WAITER_SHELL_PID="$!" + +# Background PID will be of the /snap/bin command, not the internal script, so +# need to get the real PID. The snap will write its own PID to +# $SNAP_HOME/running.pid +for i in $(seq 10) ; do + if [ -f "$SNAP_HOME/running.pid" ] ; then + break + fi + sleep 1 +done +test -f "$SNAP_HOME/running.pid" +WAITER_SNAP_PID="$(cat "$SNAP_HOME/running.pid")" + +# Actually trigger the request by querying the API +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "allow"' + +# Trigger a second request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "deny"' + +# Trigger a third request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "deny"' + +# Trigger a fourth request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "allow"' + +# Trigger a fifth request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "allow"' + +# Tell the waiter to stop waiting +touch "$TARGET_FILE" +wait "$WAITER_SHELL_PID" + +# Wait for the client to write its result and exit +timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" + +CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" + +if [ "$CLIENT_OUTPUT" != "success" ] ; then + echo "test failed" + echo "output='$CLIENT_OUTPUT'" + exit 1 +fi diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.json b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.json new file mode 100644 index 00000000000..15a6d90a8e7 --- /dev/null +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.json @@ -0,0 +1,40 @@ +{ + "version": 1, + "prompt-filter": { + "snap": "prompt-requester", + "interface": "audio-record" + }, + "prompts": [ + { + "prompt-filter": { + "interface": "audio-record", + "constraints": { + "requested-permissions": [ "access" ] + } + }, + "reply": { + "action": "allow", + "lifespan": "timespan", + "duration": "10s", + "constraints": { + "permissions": [ "access" ] + } + } + }, + { + "prompt-filter": { + "interface": "audio-record", + "constraints": { + "requested-permissions": [ "access" ] + } + }, + "reply": { + "action": "deny", + "lifespan": "single", + "constraints": { + "permissions": [ "access" ] + } + } + } + ] +} diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh new file mode 100644 index 00000000000..8fe5f6a211c --- /dev/null +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh @@ -0,0 +1,82 @@ +#!/usr/bin/sh + +# A test of allow with timespan for the audio-record interface. + +TEST_DIR="$1" +TIMEOUT="$2" +if [ -z "$TIMEOUT" ] ; then + TIMEOUT=10 +fi + +SNAP_HOME="$HOME/snap/prompt-requester/current" + +# The audio-record interface doesn't use a target file to trigger a prompt. +# Instead, we use a file to tell the snap to finish running. We need a snap +# running under a cgroup in order for the "ask" request to be handled correctly. +TARGET_FILE="$SNAP_HOME/finish" +rm -f "$TARGET_FILE" + +# Start the snap running in the background so "ask" can use its PID to look up +# its cgroup, and from that derive the snap name. +prompt-requester.wait-for "$TARGET_FILE" & +WAITER_SHELL_PID="$!" + +# Background PID will be of the /snap/bin command, not the internal script, so +# need to get the real PID. The snap will write its own PID to +# $SNAP_HOME/running.pid +for i in $(seq 10) ; do + if [ -f "$SNAP_HOME/running.pid" ] ; then + break + fi + sleep 1 +done +test -f "$SNAP_HOME/running.pid" +WAITER_SNAP_PID="$(cat "$SNAP_HOME/running.pid")" + +# Actually trigger the request by querying the API +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "allow"' + +# Trigger a second request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "allow"' + +# Trigger a third request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "allow"' + +# Trigger a fourth request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "allow"' + +echo "Wait for the rule to expire" +sleep 10 + +# Trigger a fifth request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "deny"' + +# Tell the waiter to stop waiting +touch "$TARGET_FILE" +wait "$WAITER_SHELL_PID" + +# Wait for the client to write its result and exit +timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" + +CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" + +if [ "$CLIENT_OUTPUT" != "success" ] ; then + echo "test failed" + echo "output='$CLIENT_OUTPUT'" + exit 1 +fi diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.json b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.json new file mode 100644 index 00000000000..b3c61a9cb1c --- /dev/null +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.json @@ -0,0 +1,40 @@ +{ + "version": 1, + "prompt-filter": { + "snap": "prompt-requester", + "interface": "audio-record" + }, + "prompts": [ + { + "prompt-filter": { + "interface": "audio-record", + "constraints": { + "requested-permissions": [ "access" ] + } + }, + "reply": { + "action": "deny", + "lifespan": "timespan", + "duration": "10s", + "constraints": { + "permissions": [ "access" ] + } + } + }, + { + "prompt-filter": { + "interface": "audio-record", + "constraints": { + "requested-permissions": [ "access" ] + } + }, + "reply": { + "action": "allow", + "lifespan": "single", + "constraints": { + "permissions": [ "access" ] + } + } + } + ] +} diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh new file mode 100644 index 00000000000..b90f179f22b --- /dev/null +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh @@ -0,0 +1,82 @@ +#!/usr/bin/sh + +# A test of deny with timespan for the audio-record interface. + +TEST_DIR="$1" +TIMEOUT="$2" +if [ -z "$TIMEOUT" ] ; then + TIMEOUT=10 +fi + +SNAP_HOME="$HOME/snap/prompt-requester/current" + +# The audio-record interface doesn't use a target file to trigger a prompt. +# Instead, we use a file to tell the snap to finish running. We need a snap +# running under a cgroup in order for the "ask" request to be handled correctly. +TARGET_FILE="$SNAP_HOME/finish" +rm -f "$TARGET_FILE" + +# Start the snap running in the background so "ask" can use its PID to look up +# its cgroup, and from that derive the snap name. +prompt-requester.wait-for "$TARGET_FILE" & +WAITER_SHELL_PID="$!" + +# Background PID will be of the /snap/bin command, not the internal script, so +# need to get the real PID. The snap will write its own PID to +# $SNAP_HOME/running.pid +for i in $(seq 10) ; do + if [ -f "$SNAP_HOME/running.pid" ] ; then + break + fi + sleep 1 +done +test -f "$SNAP_HOME/running.pid" +WAITER_SNAP_PID="$(cat "$SNAP_HOME/running.pid")" + +# Actually trigger the request by querying the API +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "deny"' + +# Trigger a second request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "deny"' + +# Trigger a third request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "deny"' + +# Trigger a fourth request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "deny"' + +echo "Wait for the rule to expire" +sleep 10 + +# Trigger a fifth request +ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" +RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" +echo "$RESULT" | MATCH '"status-code": 200' +echo "$RESULT" | MATCH '"outcome": "allow"' + +# Tell the waiter to stop waiting +touch "$TARGET_FILE" +wait "$WAITER_SHELL_PID" + +# Wait for the client to write its result and exit +timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" + +CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" + +if [ "$CLIENT_OUTPUT" != "success" ] ; then + echo "test failed" + echo "output='$CLIENT_OUTPUT'" + exit 1 +fi diff --git a/tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/cat b/tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/cat new file mode 100755 index 00000000000..57644f3dab1 --- /dev/null +++ b/tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/cat @@ -0,0 +1,3 @@ +#!/bin/sh + +exec /bin/cat "$@" diff --git a/tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/wait-for b/tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/wait-for new file mode 100755 index 00000000000..fc456436ec1 --- /dev/null +++ b/tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/wait-for @@ -0,0 +1,14 @@ +#!/bin/sh -e + +# Write the PID to $HOME/running.pid +echo "$$" > "$HOME/running.pid" + +# Wait until file exists, else give up after a timeout +#shellcheck disable=SC2034 +for i in $(seq 1 100) ; do + if [ -e "$1" ] ; then + exit 0 + fi + sleep 1 +done +exit 1 diff --git a/tests/main/apparmor-prompting-integration-tests/prompt-requester/meta/snap.yaml b/tests/main/apparmor-prompting-integration-tests/prompt-requester/meta/snap.yaml new file mode 100644 index 00000000000..d97df2bf593 --- /dev/null +++ b/tests/main/apparmor-prompting-integration-tests/prompt-requester/meta/snap.yaml @@ -0,0 +1,13 @@ +name: prompt-requester +version: 1 +base: core24 +apps: + cat: + command: bin/cat + plugs: + - home + - camera + wait-for: + command: bin/wait-for + plugs: + - audio-record diff --git a/tests/main/apparmor-prompting-integration-tests/task.yaml b/tests/main/apparmor-prompting-integration-tests/task.yaml index 28bedd9d18e..ba76c8313f0 100644 --- a/tests/main/apparmor-prompting-integration-tests/task.yaml +++ b/tests/main/apparmor-prompting-integration-tests/task.yaml @@ -14,6 +14,9 @@ systems: - ubuntu-2* environment: + VARIANT/audio_record_single: audio_record_single + VARIANT/audio_record_timespan_allow: audio_record_timespan_allow + VARIANT/audio_record_timespan_deny: audio_record_timespan_deny VARIANT/create_multiple_actioned_by_other_pid_always_allow: create_multiple_actioned_by_other_pid_always_allow VARIANT/create_multiple_actioned_by_other_pid_always_deny: create_multiple_actioned_by_other_pid_always_deny VARIANT/create_multiple_allow: create_multiple_allow @@ -73,6 +76,13 @@ prepare: | fi fi + if [[ "$VARIANT" =~ "audio_record" ]] ; then + "$TESTSTOOLS"/snaps-state install-local prompt-requester + snap connect "prompt-requester:audio-record" + # TODO: probably cleaner to use prompt-requester.cat for all tests + # instead of using `snap run --shell prompting-client.scripted` + fi + tests.session prepare -u test tests.cleanup defer tests.session restore -u test tests.session -u test exec sh -c 'mkdir -p "/home/test/integration-tests"' @@ -82,6 +92,9 @@ prepare: | restore: | snap set system experimental.apparmor-prompting=false + echo "Remove any listener ID, request mappings, prompts, and rules" + rm -rf /{run,var/lib}/snapd/interfaces-requests + debug: | uname -a if [ -f using-temporal-script ] ; then @@ -151,7 +164,7 @@ execute: | fi echo "Run the test script as the test user" - if ! tests.session -u test exec sh -x "${TEST_DIR}/${VARIANT}.sh" "$TEST_DIR" "$TIMEOUT"; then + if ! tests.session -u test exec sh -xe "${TEST_DIR}/${VARIANT}.sh" "$TEST_DIR" "$TIMEOUT"; then # Test script exited early with error, so the prompting client may still # be running, waiting for further requests, so it should be killed. pkill -f "prompting-client-scripted.*${TEST_DIR}" From a44b90a766a5cd6581570d02ae5285cf7b3ee0a7 Mon Sep 17 00:00:00 2001 From: Oliver Calder Date: Mon, 4 May 2026 22:12:34 -0500 Subject: [PATCH 2/7] tests: place prompt-requester test snap in tests/lib/snaps Signed-off-by: Oliver Calder --- .../snaps}/prompt-requester/bin/cat | 0 .../snaps}/prompt-requester/bin/wait-for | 4 ++++ .../snaps}/prompt-requester/meta/snap.yaml | 0 .../prompt-requester/bin/cat | 3 --- .../prompt-requester/meta/snap.yaml | 7 ------- .../prompt-requester/bin/cat | 3 --- .../prompt-requester/bin/wait-for | 14 -------------- .../prompt-requester/meta/snap.yaml | 13 ------------- 8 files changed, 4 insertions(+), 40 deletions(-) rename tests/{main/apparmor-prompting-integration-tests => lib/snaps}/prompt-requester/bin/cat (100%) rename tests/{main/apparmor-prompting-integration-tests => lib/snaps}/prompt-requester/bin/wait-for (56%) rename tests/{main/apparmor-prompting-integration-tests => lib/snaps}/prompt-requester/meta/snap.yaml (100%) delete mode 100755 tests/main/apparmor-prompting-prompt-restoration/prompt-requester/bin/cat delete mode 100644 tests/main/apparmor-prompting-prompt-restoration/prompt-requester/meta/snap.yaml delete mode 100755 tests/main/apparmor-prompting-smoke/prompt-requester/bin/cat delete mode 100755 tests/main/apparmor-prompting-smoke/prompt-requester/bin/wait-for delete mode 100644 tests/main/apparmor-prompting-smoke/prompt-requester/meta/snap.yaml diff --git a/tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/cat b/tests/lib/snaps/prompt-requester/bin/cat similarity index 100% rename from tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/cat rename to tests/lib/snaps/prompt-requester/bin/cat diff --git a/tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/wait-for b/tests/lib/snaps/prompt-requester/bin/wait-for similarity index 56% rename from tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/wait-for rename to tests/lib/snaps/prompt-requester/bin/wait-for index fc456436ec1..a71d92d8d24 100755 --- a/tests/main/apparmor-prompting-integration-tests/prompt-requester/bin/wait-for +++ b/tests/lib/snaps/prompt-requester/bin/wait-for @@ -7,8 +7,12 @@ echo "$$" > "$HOME/running.pid" #shellcheck disable=SC2034 for i in $(seq 1 100) ; do if [ -e "$1" ] ; then + # Clean up the PID file so another test doesn't mistake it for theirs + rm -f "$HOME/running.pid" exit 0 fi sleep 1 done +# Clean up the PID file so another test doesn't mistake it for theirs +rm -f "$HOME/running.pid" exit 1 diff --git a/tests/main/apparmor-prompting-integration-tests/prompt-requester/meta/snap.yaml b/tests/lib/snaps/prompt-requester/meta/snap.yaml similarity index 100% rename from tests/main/apparmor-prompting-integration-tests/prompt-requester/meta/snap.yaml rename to tests/lib/snaps/prompt-requester/meta/snap.yaml diff --git a/tests/main/apparmor-prompting-prompt-restoration/prompt-requester/bin/cat b/tests/main/apparmor-prompting-prompt-restoration/prompt-requester/bin/cat deleted file mode 100755 index 57644f3dab1..00000000000 --- a/tests/main/apparmor-prompting-prompt-restoration/prompt-requester/bin/cat +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec /bin/cat "$@" diff --git a/tests/main/apparmor-prompting-prompt-restoration/prompt-requester/meta/snap.yaml b/tests/main/apparmor-prompting-prompt-restoration/prompt-requester/meta/snap.yaml deleted file mode 100644 index 6942d414e5f..00000000000 --- a/tests/main/apparmor-prompting-prompt-restoration/prompt-requester/meta/snap.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: prompt-requester -version: 1 -base: core18 -apps: - cat: - command: bin/cat - plugs: [home] diff --git a/tests/main/apparmor-prompting-smoke/prompt-requester/bin/cat b/tests/main/apparmor-prompting-smoke/prompt-requester/bin/cat deleted file mode 100755 index 57644f3dab1..00000000000 --- a/tests/main/apparmor-prompting-smoke/prompt-requester/bin/cat +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec /bin/cat "$@" diff --git a/tests/main/apparmor-prompting-smoke/prompt-requester/bin/wait-for b/tests/main/apparmor-prompting-smoke/prompt-requester/bin/wait-for deleted file mode 100755 index fc456436ec1..00000000000 --- a/tests/main/apparmor-prompting-smoke/prompt-requester/bin/wait-for +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -e - -# Write the PID to $HOME/running.pid -echo "$$" > "$HOME/running.pid" - -# Wait until file exists, else give up after a timeout -#shellcheck disable=SC2034 -for i in $(seq 1 100) ; do - if [ -e "$1" ] ; then - exit 0 - fi - sleep 1 -done -exit 1 diff --git a/tests/main/apparmor-prompting-smoke/prompt-requester/meta/snap.yaml b/tests/main/apparmor-prompting-smoke/prompt-requester/meta/snap.yaml deleted file mode 100644 index d97df2bf593..00000000000 --- a/tests/main/apparmor-prompting-smoke/prompt-requester/meta/snap.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: prompt-requester -version: 1 -base: core24 -apps: - cat: - command: bin/cat - plugs: - - home - - camera - wait-for: - command: bin/wait-for - plugs: - - audio-record From 995dd1695647abb7d014d93723fc7dfd7da84d96 Mon Sep 17 00:00:00 2001 From: Oliver Calder Date: Mon, 4 May 2026 22:23:22 -0500 Subject: [PATCH 3/7] tests: remove MATCH from scripts run in test user shell Signed-off-by: Oliver Calder --- .../audio_record_single.sh | 20 +++++++++---------- .../audio_record_timespan_allow.sh | 20 +++++++++---------- .../audio_record_timespan_deny.sh | 20 +++++++++---------- .../download_file_defaults.sh | 4 ++-- .../download_file_safer.sh | 4 ++-- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh index 57b5d65cd6f..e2969caf89d 100644 --- a/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh @@ -36,32 +36,32 @@ WAITER_SNAP_PID="$(cat "$SNAP_HOME/running.pid")" # Actually trigger the request by querying the API ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "allow"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "allow"' # Trigger a second request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "deny"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "deny"' # Trigger a third request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "deny"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "deny"' # Trigger a fourth request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "allow"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "allow"' # Trigger a fifth request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "allow"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "allow"' # Tell the waiter to stop waiting touch "$TARGET_FILE" diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh index 8fe5f6a211c..ba021beb111 100644 --- a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh @@ -36,26 +36,26 @@ WAITER_SNAP_PID="$(cat "$SNAP_HOME/running.pid")" # Actually trigger the request by querying the API ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "allow"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "allow"' # Trigger a second request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "allow"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "allow"' # Trigger a third request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "allow"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "allow"' # Trigger a fourth request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "allow"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "allow"' echo "Wait for the rule to expire" sleep 10 @@ -63,8 +63,8 @@ sleep 10 # Trigger a fifth request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "deny"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "deny"' # Tell the waiter to stop waiting touch "$TARGET_FILE" diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh index b90f179f22b..6d9a40b55fd 100644 --- a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh @@ -36,26 +36,26 @@ WAITER_SNAP_PID="$(cat "$SNAP_HOME/running.pid")" # Actually trigger the request by querying the API ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "deny"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "deny"' # Trigger a second request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "deny"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "deny"' # Trigger a third request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "deny"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "deny"' # Trigger a fourth request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "deny"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "deny"' echo "Wait for the rule to expire" sleep 10 @@ -63,8 +63,8 @@ sleep 10 # Trigger a fifth request ASK_BODY="{\"action\": \"ask\", \"interface\": \"audio-record\", \"pid\": $WAITER_SNAP_PID}" RESULT="$(echo "$ASK_BODY" | snap debug api -X POST -H 'Content-Type: application/json' "/v2/interfaces/requests")" -echo "$RESULT" | MATCH '"status-code": 200' -echo "$RESULT" | MATCH '"outcome": "allow"' +echo "$RESULT" | grep '"status-code": 200' +echo "$RESULT" | grep '"outcome": "allow"' # Tell the waiter to stop waiting touch "$TARGET_FILE" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh index 8ac2302299c..ce67f37cbbf 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh @@ -40,8 +40,8 @@ if [ "$CLIENT_OUTPUT" != "success" ] ; then fi # Furthermore, rules with identical path patterns are merged, so we don't # expect any rules with duplicate path patterns. -snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | MATCH '^[[:space:]]*1' -snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | NOMATCH '^[[:space:]]*2' +snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep '^[[:space:]]*1' +snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep -qv '^[[:space:]]*2' TEST_OUTPUT="$(cat "${TEST_DIR}/Downloads/test.txt")" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh b/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh index 51c10514076..079ae311298 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh @@ -39,8 +39,8 @@ fi # Rules with identical path patterns are merged, so we don't expect any rules # with duplicate path patterns. -snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | MATCH '^[[:space:]]*1' -snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | NOMATCH '^[[:space:]]*2' +snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep '^[[:space:]]*1' +snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep -qv '^[[:space:]]*2' TEST_OUTPUT="$(cat "${TEST_DIR}/Downloads/test.txt")" From e0eb992bc2caaf889a58fa6694a6258d004a7899 Mon Sep 17 00:00:00 2001 From: Oliver Calder Date: Tue, 5 May 2026 13:32:32 -0500 Subject: [PATCH 4/7] tests: make prompting integration tests work with sh -e Signed-off-by: Oliver Calder --- .../audio_record_single.sh | 11 ++++++- .../audio_record_timespan_allow.sh | 11 ++++++- .../audio_record_timespan_deny.sh | 11 ++++++- ...iple_actioned_by_other_pid_always_allow.sh | 13 +++++++-- ...tiple_actioned_by_other_pid_always_deny.sh | 15 ++++++++-- .../create_multiple_allow.sh | 13 +++++++-- .../create_multiple_deny.sh | 13 +++++++-- ..._not_actioned_by_other_pid_single_allow.sh | 15 ++++++++-- ...e_not_actioned_by_other_pid_single_deny.sh | 15 ++++++++-- ...create_write_chmod_same_fd_single_allow.sh | 11 ++++++- ...eate_write_chmod_same_path_single_allow.sh | 11 ++++++- ...reate_write_write_same_path_single_deny.sh | 17 ++++++++--- .../download_file_conflict.sh | 13 +++++++-- .../download_file_defaults.sh | 11 ++++++- .../download_file_safer.sh | 11 ++++++- .../read_single_allow.sh | 11 ++++++- .../read_single_deny.sh | 13 +++++++-- .../special_characters.sh | 11 ++++++- .../timespan_allow.sh | 13 +++++++-- .../timespan_deny.sh | 13 +++++++-- ...ltiple_actioned_by_other_pid_allow_deny.sh | 29 ++++++++++++------- ...ltiple_actioned_by_other_pid_deny_allow.sh | 25 +++++++++++----- .../write_single_allow.sh | 11 ++++++- .../write_single_deny.sh | 13 +++++++-- 24 files changed, 273 insertions(+), 57 deletions(-) diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh index e2969caf89d..e77a73c356d 100644 --- a/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh @@ -68,7 +68,16 @@ touch "$TARGET_FILE" wait "$WAITER_SHELL_PID" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh index ba021beb111..03f100dd5df 100644 --- a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh @@ -71,7 +71,16 @@ touch "$TARGET_FILE" wait "$WAITER_SHELL_PID" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh index 6d9a40b55fd..5d32c6b5f67 100644 --- a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh @@ -71,7 +71,16 @@ touch "$TARGET_FILE" wait "$WAITER_SHELL_PID" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.sh index 6742f98d658..f0f3aa44452 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.sh @@ -24,7 +24,7 @@ for dir in test1 test2 test3 ; do name="${dir}/file.txt" echo "Attempt to create $name in the background" snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start create of $name within timeout period" exit 1 fi @@ -44,7 +44,16 @@ mkdir -p "${TEST_DIR}/test4" snap run --shell prompting-client.scripted -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi for dir in test1 test2 test3 ; do name="${dir}/file.txt" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.sh index badeb83bf4b..09f0e65d9fc 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.sh @@ -24,7 +24,7 @@ for dir in test1 test2 test3 ; do name="${dir}/file.txt" echo "Attempt to create $name in the background" snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start create of $name within timeout period" exit 1 fi @@ -41,10 +41,19 @@ done echo "Attempt to create test4/file.txt (for which client will reply)" mkdir -p "${TEST_DIR}/test4" -snap run --shell prompting-client.scripted -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" +snap run --shell prompting-client.scripted -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" || true # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi for dir in test1 test2 test3 ; do name="${dir}/file.txt" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.sh index 5722b1c25d7..97c569776c5 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.sh @@ -11,11 +11,20 @@ fi for name in test1.txt test2.md fail.txt test3.pdf ; do echo "Attempt to write $name" - snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" + snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" || true done # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.sh index c480532f6d1..9b4f302a85d 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.sh @@ -11,11 +11,20 @@ fi for name in test1.txt test2.md succeed.txt test3.pdf ; do echo "Attempt to write $name" - snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" + snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" || true done # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.sh index c485bc07bf9..f6977dd9afe 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.sh @@ -24,7 +24,7 @@ for dir in test1 test2 test3 ; do name="${dir}/file.txt" echo "Attempt to create $name in the background" snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start create of $name within timeout period" exit 1 fi @@ -55,10 +55,19 @@ done echo "Attempt to create test5/file.txt (for which client will reply deny forever)" mkdir -p "${TEST_DIR}/test5" -snap run --shell prompting-client.scripted -c "echo test5/file.txt is written > ${TEST_DIR}/test5/file.txt" +snap run --shell prompting-client.scripted -c "echo test5/file.txt is written > ${TEST_DIR}/test5/file.txt" || true # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi for dir in test1 test2 test3 ; do name="${dir}/file.txt" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.sh index 435b78ff136..ca898ec3d6a 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.sh @@ -24,7 +24,7 @@ for dir in test1 test2 test3 ; do name="${dir}/file.txt" echo "Attempt to create $name in the background" snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start create of $name within timeout period" exit 1 fi @@ -41,7 +41,7 @@ done echo "Attempt to create test4/file.txt (for which client will reply deny single)" mkdir -p "${TEST_DIR}/test4" -snap run --shell prompting-client.scripted -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" +snap run --shell prompting-client.scripted -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" || true for dir in test1 test2 test3 ; do name="${dir}/file.txt" @@ -58,7 +58,16 @@ mkdir -p "${TEST_DIR}/test5" snap run --shell prompting-client.scripted -c "echo test5/file.txt is written > ${TEST_DIR}/test5/file.txt" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi for dir in test1 test2 test3 ; do name="${dir}/file.txt" diff --git a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.sh b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.sh index 7eed949a064..e8e9ebddfab 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.sh @@ -45,7 +45,16 @@ echo "Create, write, and chmod the file" snap run --shell prompting-client.scripted -c "${HELPER_PATH} ${TEST_DIR}/test.txt" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi # Clean up the helper program rm -f "${HELPER_PATH}" diff --git a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_path_single_allow.sh b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_path_single_allow.sh index 391eb8f8fd2..a8f29dcfcda 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_path_single_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_path_single_allow.sh @@ -16,7 +16,16 @@ snap run --shell prompting-client.scripted -c "echo some-content > ${TEST_DIR}/t snap run --shell prompting-client.scripted -c "chmod 654 ${TEST_DIR}/test.txt" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.sh b/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.sh index bef9cd73462..fcc6cd99021 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.sh @@ -11,13 +11,22 @@ if [ -z "$TIMEOUT" ] ; then fi echo "Create, write, and write (again) the file" -snap run --shell prompting-client.scripted -c "touch ${TEST_DIR}/test.txt" -snap run --shell prompting-client.scripted -c "echo some-content > ${TEST_DIR}/test.txt" +snap run --shell prompting-client.scripted -c "touch ${TEST_DIR}/test.txt" || true +snap run --shell prompting-client.scripted -c "echo some-content > ${TEST_DIR}/test.txt" || true snap run --shell prompting-client.scripted -c "echo succeed-content > ${TEST_DIR}/succeed.txt" -snap run --shell prompting-client.scripted -c "echo other-content | tee -a ${TEST_DIR}/test.txt" +snap run --shell prompting-client.scripted -c "echo other-content | tee -a ${TEST_DIR}/test.txt" || true # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_conflict.sh b/tests/main/apparmor-prompting-integration-tests/download_file_conflict.sh index c4aca14a37f..556ea8eebfb 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_conflict.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_conflict.sh @@ -21,12 +21,21 @@ if ! snap run --shell prompting-client.scripted -c "ls ${TEST_DIR}/Downloads" | fi echo "Attempt to write the file, to which the client should reply with a conflicting rule and exit with error" -snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/Downloads/test.txt" +snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/Downloads/test.txt" || true echo "Don't attempt to chmod the file after it has been written, since the client should have exited" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh index ce67f37cbbf..bf6779abc4c 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh @@ -27,7 +27,16 @@ echo "Attempt to chmod the file after it has been written" snap run --shell prompting-client.scripted -c "chmod 664 ${TEST_DIR}/Downloads/test.txt" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh b/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh index 079ae311298..8537c21cb39 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh @@ -27,7 +27,16 @@ echo "Attempt to chmod the file after it has been written" snap run --shell prompting-client.scripted -c "chmod 664 ${TEST_DIR}/Downloads/test.txt" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/read_single_allow.sh b/tests/main/apparmor-prompting-integration-tests/read_single_allow.sh index c7babe78115..b35be7f6ee7 100644 --- a/tests/main/apparmor-prompting-integration-tests/read_single_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/read_single_allow.sh @@ -15,7 +15,16 @@ echo "Attempt to read the file" TEST_OUTPUT="$(snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test.txt")" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/read_single_deny.sh b/tests/main/apparmor-prompting-integration-tests/read_single_deny.sh index 1928ed2614d..eea8c5cf02f 100644 --- a/tests/main/apparmor-prompting-integration-tests/read_single_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/read_single_deny.sh @@ -12,10 +12,19 @@ echo "Prepare the file to be read" echo "testing testing 1 2 3" | tee "${TEST_DIR}/test.txt" echo "Attempt to read the file (should fail)" -TEST_OUTPUT="$(snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test.txt")" +TEST_OUTPUT="$(snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test.txt" || true)" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/special_characters.sh b/tests/main/apparmor-prompting-integration-tests/special_characters.sh index 2fab5fdd536..b7c67561e35 100644 --- a/tests/main/apparmor-prompting-integration-tests/special_characters.sh +++ b/tests/main/apparmor-prompting-integration-tests/special_characters.sh @@ -27,7 +27,16 @@ echo "Skip reading the second file as there's an issue with the prompting-client #SECOND_OUTPUT="$(snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/'foo*?()[]{}\\'")" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/timespan_allow.sh b/tests/main/apparmor-prompting-integration-tests/timespan_allow.sh index c0fd1bc448b..975b2974abb 100644 --- a/tests/main/apparmor-prompting-integration-tests/timespan_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/timespan_allow.sh @@ -18,10 +18,19 @@ done sleep 10 # wait for the rule to expire echo "Attempt to write test4.txt (should fail)" -snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" +snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" || true # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/timespan_deny.sh b/tests/main/apparmor-prompting-integration-tests/timespan_deny.sh index 2958f95ce4f..28786a9ad3e 100644 --- a/tests/main/apparmor-prompting-integration-tests/timespan_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/timespan_deny.sh @@ -11,7 +11,7 @@ fi for name in test1.txt test2.txt test3.txt ; do echo "Attempt to write $name (should fail)" - snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" + snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" || true done # The reply has a hard-coded duration of 10s @@ -21,7 +21,16 @@ echo "Attempt to write test4.txt" snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.sh b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.sh index b75d8dd1314..a6faf031ea0 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.sh @@ -20,7 +20,7 @@ for name in test1.txt test2.txt test3.txt ; do echo "Attempt to write $name in the background" echo "not written" > "${TEST_DIR}/${name}" snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${name}-write-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${name}-write-finished" & - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-started' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start write of $name within timeout period" exit 1 fi @@ -42,7 +42,7 @@ snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TES for name in test1.txt test2.txt test3.txt ; do echo "Check that write for $name has finished" - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-finished' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-finished' ] ; do sleep 0.1 ; done" ; then echo "write of $name did not finish after client replied" exit 1 fi @@ -61,7 +61,7 @@ done for name in test1.txt test2.txt test3.txt ; do echo "Attempt to read $name in the background" snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${name}-read-started; cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}; touch ${WRITABLE}/${name}-read-finished" & - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-started' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start read of $name within timeout period" exit 1 fi @@ -76,20 +76,20 @@ for name in test1.txt test2.txt test3.txt ; do done echo "Attempt to read test4.txt (for which client will reply)" -snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test4.txt > ${WRITABLE}/test4.txt" +snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test4.txt > ${WRITABLE}/test4.txt" || true # Reply for test4.txt will deny always read|write test* for name in test1.txt test2.txt test3.txt ; do echo "Check that read for $name has finished" - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-finished' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-finished' ] ; do sleep 0.1 ; done" ; then echo "read of $name did not finish after client replied" exit 1 fi done for name in test1.txt test2.txt test3.txt test4.txt ; do - TEST_OUTPUT="$(cat "${WRITABLE}/${name}")" + TEST_OUTPUT="$(cat "${WRITABLE}/${name}" || true)" if [ "$TEST_OUTPUT" = "$name is written" ] ; then echo "read unexpectedly succeeded for $name" exit 1 @@ -112,7 +112,7 @@ if [ "$TEST_OUTPUT" != "test5.txt is written" ] ; then fi echo "Attempt to create test5.md (should be denied by previous rule)" -snap run --shell prompting-client.scripted -c "echo test5.md is written > ${TEST_DIR}/test5.md" +snap run --shell prompting-client.scripted -c "echo test5.md is written > ${TEST_DIR}/test5.md" || true if [ -f "${TEST_DIR}/test5.md" ] ; then echo "file creation unexpectedly succeeded for test5.md" exit 1 @@ -121,7 +121,7 @@ fi for name in test5.txt test5.md ; do echo "Attempt to read $name (should be denied by previous rule)" echo "$name is written" > "${TEST_DIR}/${name}" - snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}" + snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}" || true TEST_OUTPUT="$(cat "${WRITABLE}/${name}")" if [ "$TEST_OUTPUT" = "$name is written" ] ; then echo "read unexpectedly succeeded for $name" @@ -130,14 +130,23 @@ for name in test5.txt test5.md ; do done echo "Attempt to create other.txt (should trigger prompt, which is then denied)" -snap run --shell prompting-client.scripted -c "echo other.txt is written > ${TEST_DIR}/other.txt" +snap run --shell prompting-client.scripted -c "echo other.txt is written > ${TEST_DIR}/other.txt" || true if [ -f "${TEST_DIR}/other.txt" ] ; then echo "file creation unexpectedly succeeded for other.txt" exit 1 fi # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.sh b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.sh index 1031f22a856..1c131695bde 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.sh @@ -20,7 +20,7 @@ for name in test1.txt test2.txt test3.txt ; do echo "Attempt to write $name in the background" echo "not written" > "${TEST_DIR}/${name}" snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${name}-write-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${name}-write-finished" & - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-started' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start write of $name within timeout period" exit 1 fi @@ -36,13 +36,13 @@ done echo "Attempt to write test4.txt (for which client will reply)" echo "not written" > "${TEST_DIR}/test4.txt" -snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" +snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" || true # Reply for test4.txt will deny always write test*.txt for name in test1.txt test2.txt test3.txt ; do echo "Check that write for $name has finished" - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-finished' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-finished' ] ; do sleep 0.1 ; done" ; then echo "write of $name did not finish after client replied" exit 1 fi @@ -64,7 +64,7 @@ done for name in test1.txt test2.txt test3.txt ; do echo "Attempt to read $name in the background" snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${name}-read-started; cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}; touch ${WRITABLE}/${name}-read-finished" & - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-started' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start read of $name within timeout period" exit 1 fi @@ -85,7 +85,7 @@ snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test4.txt > ${WRI for name in test1.txt test2.txt test3.txt ; do echo "Check that read for $name has finished" - if ! timeout "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-finished' ] ; do sleep 0.1 ; done" ; then + if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-finished' ] ; do sleep 0.1 ; done" ; then echo "read of $name did not finish after client replied" exit 1 fi @@ -107,7 +107,7 @@ done # create other.txt -> prompt, reply with deny (mostly to make sure the client lives long enough) echo "Attempt to create test5.txt (should be denied by original rule)" -snap run --shell prompting-client.scripted -c "echo test5.txt is written > ${TEST_DIR}/test5.txt" +snap run --shell prompting-client.scripted -c "echo test5.txt is written > ${TEST_DIR}/test5.txt" || true if [ -f "${TEST_DIR}/test5.txt" ] ; then echo "file creation unexpectedly succeeded for test5.txt" exit 1 @@ -133,14 +133,23 @@ for name in test5.txt test5.md ; do done echo "Attempt to create other.txt (should trigger prompt, which is then denied)" -snap run --shell prompting-client.scripted -c "echo other.txt is written > ${TEST_DIR}/other.txt" +snap run --shell prompting-client.scripted -c "echo other.txt is written > ${TEST_DIR}/other.txt" || true if [ -f "${TEST_DIR}/other.txt" ] ; then echo "file creation unexpectedly succeeded for other.txt" exit 1 fi # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/write_single_allow.sh b/tests/main/apparmor-prompting-integration-tests/write_single_allow.sh index 50d35685725..ac115443488 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_single_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/write_single_allow.sh @@ -12,7 +12,16 @@ echo "Attempt to write the file" snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/test.txt" # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" diff --git a/tests/main/apparmor-prompting-integration-tests/write_single_deny.sh b/tests/main/apparmor-prompting-integration-tests/write_single_deny.sh index 909e8f79a00..ebf1159baee 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_single_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/write_single_deny.sh @@ -9,10 +9,19 @@ if [ -z "$TIMEOUT" ] ; then fi echo "Attempt to write the file (should fail)" -snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/test.txt" +snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/test.txt" || true # Wait for the client to write its result and exit -timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}' > /dev/null; do sleep 0.1; done" +for i in $(seq "$TIMEOUT") ; do + if ! pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + break + fi + sleep 1 +done +if pgrep -af "prompting-client.scripted.*${TEST_DIR}" ; then + echo "prompting-client.scripted still running" + exit 1 +fi CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")" From b84b14c2aaf4a71a185d373d31c7f431f66a0162 Mon Sep 17 00:00:00 2001 From: Oliver Calder Date: Tue, 5 May 2026 14:35:44 -0500 Subject: [PATCH 5/7] tests: fix pattern uniqueness checks in prompting integration tests Signed-off-by: Oliver Calder --- .../download_file_defaults.sh | 4 ++-- .../download_file_safer.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh index bf6779abc4c..234857571d6 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh @@ -49,8 +49,8 @@ if [ "$CLIENT_OUTPUT" != "success" ] ; then fi # Furthermore, rules with identical path patterns are merged, so we don't # expect any rules with duplicate path patterns. -snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep '^[[:space:]]*1' -snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep -qv '^[[:space:]]*2' +snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep '^[[:space:]]*1[[:space:]]' +! snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep -q '^[[:space:]]*[^1[[:space:]]]' TEST_OUTPUT="$(cat "${TEST_DIR}/Downloads/test.txt")" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh b/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh index 8537c21cb39..5eb4d27d640 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh @@ -48,8 +48,8 @@ fi # Rules with identical path patterns are merged, so we don't expect any rules # with duplicate path patterns. -snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep '^[[:space:]]*1' -snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep -qv '^[[:space:]]*2' +snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep '^[[:space:]]*1[[:space:]]' +! snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | grep -q '^[[:space:]]*[^1[[:space:]]]' TEST_OUTPUT="$(cat "${TEST_DIR}/Downloads/test.txt")" From d8752366660ee1404b1bc3e6803b14ce9ca4a0d4 Mon Sep 17 00:00:00 2001 From: Oliver Calder Date: Tue, 5 May 2026 14:51:55 -0500 Subject: [PATCH 6/7] tests: clean up any existing running.pid file from previous run Signed-off-by: Oliver Calder --- .../apparmor-prompting-integration-tests/audio_record_single.sh | 1 + .../audio_record_timespan_allow.sh | 1 + .../audio_record_timespan_deny.sh | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh index e77a73c356d..f85e03e3695 100644 --- a/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_single.sh @@ -9,6 +9,7 @@ if [ -z "$TIMEOUT" ] ; then fi SNAP_HOME="$HOME/snap/prompt-requester/current" +rm -f "$SNAP_HOME/running.pid" # Clean up any PID file from previous run # The audio-record interface doesn't use a target file to trigger a prompt. # Instead, we use a file to tell the snap to finish running. We need a snap diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh index 03f100dd5df..fa17f0da331 100644 --- a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_allow.sh @@ -9,6 +9,7 @@ if [ -z "$TIMEOUT" ] ; then fi SNAP_HOME="$HOME/snap/prompt-requester/current" +rm -f "$SNAP_HOME/running.pid" # Clean up any PID file from previous run # The audio-record interface doesn't use a target file to trigger a prompt. # Instead, we use a file to tell the snap to finish running. We need a snap diff --git a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh index 5d32c6b5f67..2fadf6809ac 100644 --- a/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/audio_record_timespan_deny.sh @@ -9,6 +9,7 @@ if [ -z "$TIMEOUT" ] ; then fi SNAP_HOME="$HOME/snap/prompt-requester/current" +rm -f "$SNAP_HOME/running.pid" # Clean up any PID file from previous run # The audio-record interface doesn't use a target file to trigger a prompt. # Instead, we use a file to tell the snap to finish running. We need a snap From 9d51f3d86b016db691b4009763aa1a1729e95814 Mon Sep 17 00:00:00 2001 From: Oliver Calder Date: Tue, 5 May 2026 15:58:31 -0500 Subject: [PATCH 7/7] tests: make all prompting integration test variants use prompt-requester Signed-off-by: Oliver Calder --- .../lib/snaps/prompt-requester/meta/snap.yaml | 4 ++++ ...le_actioned_by_other_pid_always_allow.json | 2 +- ...iple_actioned_by_other_pid_always_allow.sh | 8 ++++---- ...ple_actioned_by_other_pid_always_deny.json | 2 +- ...tiple_actioned_by_other_pid_always_deny.sh | 8 ++++---- .../create_multiple_allow.json | 2 +- .../create_multiple_allow.sh | 2 +- .../create_multiple_deny-temporal.json | 2 +- .../create_multiple_deny.json | 2 +- .../create_multiple_deny.sh | 2 +- ...ed_by_other_pid_single_allow-temporal.json | 2 +- ...ot_actioned_by_other_pid_single_allow.json | 2 +- ..._not_actioned_by_other_pid_single_allow.sh | 10 +++++----- ...not_actioned_by_other_pid_single_deny.json | 2 +- ...e_not_actioned_by_other_pid_single_deny.sh | 10 +++++----- ...e_chmod_same_fd_single_allow-temporal.json | 2 +- ...eate_write_chmod_same_fd_single_allow.json | 2 +- ...create_write_chmod_same_fd_single_allow.sh | 4 ++-- ...chmod_same_path_single_allow-temporal.json | 2 +- ...te_write_chmod_same_path_single_allow.json | 2 +- ...eate_write_chmod_same_path_single_allow.sh | 6 +++--- ..._write_same_path_single_deny-temporal.json | 2 +- ...ate_write_write_same_path_single_deny.json | 2 +- ...reate_write_write_same_path_single_deny.sh | 8 ++++---- .../download_file_conflict.json | 2 +- .../download_file_conflict.sh | 4 ++-- .../download_file_defaults.json | 2 +- .../download_file_defaults.sh | 6 +++--- .../download_file_safer.json | 2 +- .../download_file_safer.sh | 6 +++--- .../read_single_allow.json | 2 +- .../read_single_allow.sh | 2 +- .../read_single_deny.json | 2 +- .../read_single_deny.sh | 2 +- .../special_characters.json | 2 +- .../special_characters.sh | 4 ++-- .../task.yaml | 10 +++------- .../timespan_allow.json | 2 +- .../timespan_allow.sh | 4 ++-- .../timespan_deny-temporal.json | 2 +- .../timespan_deny.json | 2 +- .../timespan_deny.sh | 4 ++-- ...iple_actioned_by_other_pid_allow_deny.json | 2 +- ...ltiple_actioned_by_other_pid_allow_deny.sh | 20 +++++++++---------- ...iple_actioned_by_other_pid_deny_allow.json | 2 +- ...ltiple_actioned_by_other_pid_deny_allow.sh | 20 +++++++++---------- .../write_single_allow-temporal.json | 2 +- .../write_single_allow.json | 2 +- .../write_single_allow.sh | 2 +- .../write_single_deny.json | 2 +- .../write_single_deny.sh | 2 +- 51 files changed, 102 insertions(+), 102 deletions(-) diff --git a/tests/lib/snaps/prompt-requester/meta/snap.yaml b/tests/lib/snaps/prompt-requester/meta/snap.yaml index d97df2bf593..ccff68a09c6 100644 --- a/tests/lib/snaps/prompt-requester/meta/snap.yaml +++ b/tests/lib/snaps/prompt-requester/meta/snap.yaml @@ -7,6 +7,10 @@ apps: plugs: - home - camera + home: + command: bin/cat + plugs: + - home wait-for: command: bin/wait-for plugs: diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.json b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.json index d596e9294d4..a5d93faa7dd 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.json +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.sh index f0f3aa44452..7fdc506c272 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_allow.sh @@ -16,14 +16,14 @@ if [ -z "$TIMEOUT" ] ; then TIMEOUT=10 fi -WRITABLE="$(snap run --shell prompting-client.scripted -c 'cd ~; pwd')/$(basename "$TEST_DIR")" -snap run --shell prompting-client.scripted -c "mkdir -p $WRITABLE" +WRITABLE="$(snap run --shell prompt-requester.home -c 'cd ~; pwd')/$(basename "$TEST_DIR")" +snap run --shell prompt-requester.home -c "mkdir -p $WRITABLE" for dir in test1 test2 test3 ; do mkdir -p "${TEST_DIR}/${dir}" name="${dir}/file.txt" echo "Attempt to create $name in the background" - snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & + snap run --shell prompt-requester.home -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start create of $name within timeout period" exit 1 @@ -41,7 +41,7 @@ done echo "Attempt to create test4/file.txt (for which client will reply)" mkdir -p "${TEST_DIR}/test4" -snap run --shell prompting-client.scripted -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" +snap run --shell prompt-requester.home -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.json b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.json index d05a841fb0e..715928f8c3f 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.json +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.sh index 09f0e65d9fc..1139c33e86e 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_actioned_by_other_pid_always_deny.sh @@ -16,14 +16,14 @@ if [ -z "$TIMEOUT" ] ; then TIMEOUT=10 fi -WRITABLE="$(snap run --shell prompting-client.scripted -c 'cd ~; pwd')/$(basename "$TEST_DIR")" -snap run --shell prompting-client.scripted -c "mkdir -p $WRITABLE" +WRITABLE="$(snap run --shell prompt-requester.home -c 'cd ~; pwd')/$(basename "$TEST_DIR")" +snap run --shell prompt-requester.home -c "mkdir -p $WRITABLE" for dir in test1 test2 test3 ; do mkdir -p "${TEST_DIR}/${dir}" name="${dir}/file.txt" echo "Attempt to create $name in the background" - snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & + snap run --shell prompt-requester.home -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start create of $name within timeout period" exit 1 @@ -41,7 +41,7 @@ done echo "Attempt to create test4/file.txt (for which client will reply)" mkdir -p "${TEST_DIR}/test4" -snap run --shell prompting-client.scripted -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" || true +snap run --shell prompt-requester.home -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" || true # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.json b/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.json index 3ed382b49d4..59cf1f47f28 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.json +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.sh index 97c569776c5..e9daadca708 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_allow.sh @@ -11,7 +11,7 @@ fi for name in test1.txt test2.md fail.txt test3.pdf ; do echo "Attempt to write $name" - snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" || true + snap run --shell prompt-requester.home -c "echo $name is written > ${TEST_DIR}/${name}" || true done # Wait for the client to write its result and exit diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_deny-temporal.json b/tests/main/apparmor-prompting-integration-tests/create_multiple_deny-temporal.json index 51a5c9fdb92..260a4be796b 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_deny-temporal.json +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_deny-temporal.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.json b/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.json index 999b6db530f..6e60351b79c 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.json +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.sh index 9b4f302a85d..12456b3a375 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_deny.sh @@ -11,7 +11,7 @@ fi for name in test1.txt test2.md succeed.txt test3.pdf ; do echo "Attempt to write $name" - snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" || true + snap run --shell prompt-requester.home -c "echo $name is written > ${TEST_DIR}/${name}" || true done # Wait for the client to write its result and exit diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow-temporal.json b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow-temporal.json index c9d0dfac8b8..a38e3ef6cf6 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow-temporal.json +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow-temporal.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.json b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.json index 00da5b1d373..67428a6a4eb 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.json +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.sh index f6977dd9afe..80254a80959 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_allow.sh @@ -16,14 +16,14 @@ if [ -z "$TIMEOUT" ] ; then TIMEOUT=10 fi -WRITABLE="$(snap run --shell prompting-client.scripted -c 'cd ~; pwd')/$(basename "$TEST_DIR")" -snap run --shell prompting-client.scripted -c "mkdir -p $WRITABLE" +WRITABLE="$(snap run --shell prompt-requester.home -c 'cd ~; pwd')/$(basename "$TEST_DIR")" +snap run --shell prompt-requester.home -c "mkdir -p $WRITABLE" for dir in test1 test2 test3 ; do mkdir -p "${TEST_DIR}/${dir}" name="${dir}/file.txt" echo "Attempt to create $name in the background" - snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & + snap run --shell prompt-requester.home -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start create of $name within timeout period" exit 1 @@ -41,7 +41,7 @@ done echo "Attempt to create test4/file.txt (for which client will reply allow single)" mkdir -p "${TEST_DIR}/test4" -snap run --shell prompting-client.scripted -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" +snap run --shell prompt-requester.home -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" for dir in test1 test2 test3 ; do name="${dir}/file.txt" @@ -55,7 +55,7 @@ done echo "Attempt to create test5/file.txt (for which client will reply deny forever)" mkdir -p "${TEST_DIR}/test5" -snap run --shell prompting-client.scripted -c "echo test5/file.txt is written > ${TEST_DIR}/test5/file.txt" || true +snap run --shell prompt-requester.home -c "echo test5/file.txt is written > ${TEST_DIR}/test5/file.txt" || true # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.json b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.json index 72d2f5cad3f..a492e087d27 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.json +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.sh b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.sh index ca898ec3d6a..e9bbaf561d2 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_multiple_not_actioned_by_other_pid_single_deny.sh @@ -16,14 +16,14 @@ if [ -z "$TIMEOUT" ] ; then TIMEOUT=10 fi -WRITABLE="$(snap run --shell prompting-client.scripted -c 'cd ~; pwd')/$(basename "$TEST_DIR")" -snap run --shell prompting-client.scripted -c "mkdir -p $WRITABLE" +WRITABLE="$(snap run --shell prompt-requester.home -c 'cd ~; pwd')/$(basename "$TEST_DIR")" +snap run --shell prompt-requester.home -c "mkdir -p $WRITABLE" for dir in test1 test2 test3 ; do mkdir -p "${TEST_DIR}/${dir}" name="${dir}/file.txt" echo "Attempt to create $name in the background" - snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & + snap run --shell prompt-requester.home -c "touch ${WRITABLE}/${dir}-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${dir}-finished" & if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${dir}-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start create of $name within timeout period" exit 1 @@ -41,7 +41,7 @@ done echo "Attempt to create test4/file.txt (for which client will reply deny single)" mkdir -p "${TEST_DIR}/test4" -snap run --shell prompting-client.scripted -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" || true +snap run --shell prompt-requester.home -c "echo test4/file.txt is written > ${TEST_DIR}/test4/file.txt" || true for dir in test1 test2 test3 ; do name="${dir}/file.txt" @@ -55,7 +55,7 @@ done echo "Attempt to create test5/file.txt (for which client will reply allow forever)" mkdir -p "${TEST_DIR}/test5" -snap run --shell prompting-client.scripted -c "echo test5/file.txt is written > ${TEST_DIR}/test5/file.txt" +snap run --shell prompt-requester.home -c "echo test5/file.txt is written > ${TEST_DIR}/test5/file.txt" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow-temporal.json b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow-temporal.json index ec74871307d..680b126e546 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow-temporal.json +++ b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow-temporal.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.json b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.json index 7f16a990817..e5787490ec4 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.json +++ b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.sh b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.sh index e8e9ebddfab..b1da06f0319 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_write_chmod_same_fd_single_allow.sh @@ -11,7 +11,7 @@ if [ -z "$TIMEOUT" ] ; then fi echo "Compile a simple Go program to make syscalls for us" -HELPER_PATH="$(snap run --shell prompting-client.scripted -c 'echo $HOME')/create-write-chmod" +HELPER_PATH="$(snap run --shell prompt-requester.home -c 'echo $HOME')/create-write-chmod" cat > "${HELPER_PATH}.go" < ${TEST_DIR}/test.txt" -snap run --shell prompting-client.scripted -c "chmod 654 ${TEST_DIR}/test.txt" +snap run --shell prompt-requester.home -c "touch ${TEST_DIR}/test.txt" +snap run --shell prompt-requester.home -c "echo some-content > ${TEST_DIR}/test.txt" +snap run --shell prompt-requester.home -c "chmod 654 ${TEST_DIR}/test.txt" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny-temporal.json b/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny-temporal.json index 5870c0f729c..2710114289f 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny-temporal.json +++ b/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny-temporal.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.json b/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.json index 2dcdcec0f5b..8dff1f4e66f 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.json +++ b/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.sh b/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.sh index fcc6cd99021..c58acf12ee5 100644 --- a/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/create_write_write_same_path_single_deny.sh @@ -11,10 +11,10 @@ if [ -z "$TIMEOUT" ] ; then fi echo "Create, write, and write (again) the file" -snap run --shell prompting-client.scripted -c "touch ${TEST_DIR}/test.txt" || true -snap run --shell prompting-client.scripted -c "echo some-content > ${TEST_DIR}/test.txt" || true -snap run --shell prompting-client.scripted -c "echo succeed-content > ${TEST_DIR}/succeed.txt" -snap run --shell prompting-client.scripted -c "echo other-content | tee -a ${TEST_DIR}/test.txt" || true +snap run --shell prompt-requester.home -c "touch ${TEST_DIR}/test.txt" || true +snap run --shell prompt-requester.home -c "echo some-content > ${TEST_DIR}/test.txt" || true +snap run --shell prompt-requester.home -c "echo succeed-content > ${TEST_DIR}/succeed.txt" +snap run --shell prompt-requester.home -c "echo other-content | tee -a ${TEST_DIR}/test.txt" || true # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_conflict.json b/tests/main/apparmor-prompting-integration-tests/download_file_conflict.json index 13c4537f46b..44afc52f543 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_conflict.json +++ b/tests/main/apparmor-prompting-integration-tests/download_file_conflict.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_conflict.sh b/tests/main/apparmor-prompting-integration-tests/download_file_conflict.sh index 556ea8eebfb..5bc2d223e63 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_conflict.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_conflict.sh @@ -15,13 +15,13 @@ mkdir -p "${TEST_DIR}/Downloads" touch "${TEST_DIR}/Downloads/existing.txt" echo "Attempt to list the contents of the downloads directory" -if ! snap run --shell prompting-client.scripted -c "ls ${TEST_DIR}/Downloads" | grep "existing.txt" ; then +if ! snap run --shell prompt-requester.home -c "ls ${TEST_DIR}/Downloads" | grep "existing.txt" ; then echo "Failed to list contents of ${TEST_DIR}/Downloads" exit 1 fi echo "Attempt to write the file, to which the client should reply with a conflicting rule and exit with error" -snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/Downloads/test.txt" || true +snap run --shell prompt-requester.home -c "echo it is written > ${TEST_DIR}/Downloads/test.txt" || true echo "Don't attempt to chmod the file after it has been written, since the client should have exited" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.json b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.json index 2df013e260d..79b9be87423 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.json +++ b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh index 234857571d6..aeb490e6616 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_defaults.sh @@ -15,16 +15,16 @@ mkdir -p "${TEST_DIR}/Downloads" touch "${TEST_DIR}/Downloads/existing.txt" echo "Attempt to list the contents of the downloads directory" -if ! snap run --shell prompting-client.scripted -c "ls ${TEST_DIR}/Downloads" | grep "existing.txt" ; then +if ! snap run --shell prompt-requester.home -c "ls ${TEST_DIR}/Downloads" | grep "existing.txt" ; then echo "Failed to list contents of ${TEST_DIR}/Downloads" exit 1 fi echo "Attempt to write the file" -snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/Downloads/test.txt" +snap run --shell prompt-requester.home -c "echo it is written > ${TEST_DIR}/Downloads/test.txt" echo "Attempt to chmod the file after it has been written" -snap run --shell prompting-client.scripted -c "chmod 664 ${TEST_DIR}/Downloads/test.txt" +snap run --shell prompt-requester.home -c "chmod 664 ${TEST_DIR}/Downloads/test.txt" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_safer.json b/tests/main/apparmor-prompting-integration-tests/download_file_safer.json index c722ea0b40c..235f77f673b 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_safer.json +++ b/tests/main/apparmor-prompting-integration-tests/download_file_safer.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh b/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh index 5eb4d27d640..eb34f177523 100644 --- a/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh +++ b/tests/main/apparmor-prompting-integration-tests/download_file_safer.sh @@ -15,16 +15,16 @@ mkdir -p "${TEST_DIR}/Downloads" touch "${TEST_DIR}/Downloads/existing.txt" echo "Attempt to list the contents of the downloads directory" -if ! snap run --shell prompting-client.scripted -c "ls ${TEST_DIR}/Downloads" | grep "existing.txt" ; then +if ! snap run --shell prompt-requester.home -c "ls ${TEST_DIR}/Downloads" | grep "existing.txt" ; then echo "Failed to list contents of ${TEST_DIR}/Downloads" exit 1 fi echo "Attempt to write the file" -snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/Downloads/test.txt" +snap run --shell prompt-requester.home -c "echo it is written > ${TEST_DIR}/Downloads/test.txt" echo "Attempt to chmod the file after it has been written" -snap run --shell prompting-client.scripted -c "chmod 664 ${TEST_DIR}/Downloads/test.txt" +snap run --shell prompt-requester.home -c "chmod 664 ${TEST_DIR}/Downloads/test.txt" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/read_single_allow.json b/tests/main/apparmor-prompting-integration-tests/read_single_allow.json index 49031178d81..efd44c95dc4 100644 --- a/tests/main/apparmor-prompting-integration-tests/read_single_allow.json +++ b/tests/main/apparmor-prompting-integration-tests/read_single_allow.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/read_single_allow.sh b/tests/main/apparmor-prompting-integration-tests/read_single_allow.sh index b35be7f6ee7..061f0dd5f88 100644 --- a/tests/main/apparmor-prompting-integration-tests/read_single_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/read_single_allow.sh @@ -12,7 +12,7 @@ echo "Prepare the file to be read" echo "testing testing 1 2 3" | tee "${TEST_DIR}/test.txt" echo "Attempt to read the file" -TEST_OUTPUT="$(snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test.txt")" +TEST_OUTPUT="$(snap run --shell prompt-requester.home -c "cat ${TEST_DIR}/test.txt")" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/read_single_deny.json b/tests/main/apparmor-prompting-integration-tests/read_single_deny.json index f475f3f9dad..d4605261e2b 100644 --- a/tests/main/apparmor-prompting-integration-tests/read_single_deny.json +++ b/tests/main/apparmor-prompting-integration-tests/read_single_deny.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/read_single_deny.sh b/tests/main/apparmor-prompting-integration-tests/read_single_deny.sh index eea8c5cf02f..30bf4b3f04f 100644 --- a/tests/main/apparmor-prompting-integration-tests/read_single_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/read_single_deny.sh @@ -12,7 +12,7 @@ echo "Prepare the file to be read" echo "testing testing 1 2 3" | tee "${TEST_DIR}/test.txt" echo "Attempt to read the file (should fail)" -TEST_OUTPUT="$(snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test.txt" || true)" +TEST_OUTPUT="$(snap run --shell prompt-requester.home -c "cat ${TEST_DIR}/test.txt" || true)" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/special_characters.json b/tests/main/apparmor-prompting-integration-tests/special_characters.json index d19ff292c4c..559a6467377 100644 --- a/tests/main/apparmor-prompting-integration-tests/special_characters.json +++ b/tests/main/apparmor-prompting-integration-tests/special_characters.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/special_characters.sh b/tests/main/apparmor-prompting-integration-tests/special_characters.sh index b7c67561e35..ea64a5c9b30 100644 --- a/tests/main/apparmor-prompting-integration-tests/special_characters.sh +++ b/tests/main/apparmor-prompting-integration-tests/special_characters.sh @@ -19,12 +19,12 @@ echo "$FIRST_CONTENT" | tee "${TEST_DIR}/[アニメ][ゲーム動画].mkv" echo "$SECOND_CONTENT" | tee "${TEST_DIR}/foo*?()[]{}\\" echo "Attempt to read the first file" -FIRST_OUTPUT="$(snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/'[アニメ][ゲーム動画].mkv'")" +FIRST_OUTPUT="$(snap run --shell prompt-requester.home -c "cat ${TEST_DIR}/'[アニメ][ゲーム動画].mkv'")" echo "Skip reading the second file as there's an issue with the prompting-client.scripted parsing the sequence" # TODO: actually do the second read #echo "Attempt to read the second file" -#SECOND_OUTPUT="$(snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/'foo*?()[]{}\\'")" +#SECOND_OUTPUT="$(snap run --shell prompt-requester.home -c "cat ${TEST_DIR}/'foo*?()[]{}\\'")" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/task.yaml b/tests/main/apparmor-prompting-integration-tests/task.yaml index ba76c8313f0..74f39be60ae 100644 --- a/tests/main/apparmor-prompting-integration-tests/task.yaml +++ b/tests/main/apparmor-prompting-integration-tests/task.yaml @@ -76,19 +76,15 @@ prepare: | fi fi - if [[ "$VARIANT" =~ "audio_record" ]] ; then - "$TESTSTOOLS"/snaps-state install-local prompt-requester - snap connect "prompt-requester:audio-record" - # TODO: probably cleaner to use prompt-requester.cat for all tests - # instead of using `snap run --shell prompting-client.scripted` - fi - tests.session prepare -u test tests.cleanup defer tests.session restore -u test tests.session -u test exec sh -c 'mkdir -p "/home/test/integration-tests"' tests.cleanup defer rm -rf /home/test/integration-tests snap install prompting-client + "$TESTSTOOLS"/snaps-state install-local prompt-requester + snap connect "prompt-requester:audio-record" + restore: | snap set system experimental.apparmor-prompting=false diff --git a/tests/main/apparmor-prompting-integration-tests/timespan_allow.json b/tests/main/apparmor-prompting-integration-tests/timespan_allow.json index 94540bd9620..99d7c52ede7 100644 --- a/tests/main/apparmor-prompting-integration-tests/timespan_allow.json +++ b/tests/main/apparmor-prompting-integration-tests/timespan_allow.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/timespan_allow.sh b/tests/main/apparmor-prompting-integration-tests/timespan_allow.sh index 975b2974abb..e0a8d4031a1 100644 --- a/tests/main/apparmor-prompting-integration-tests/timespan_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/timespan_allow.sh @@ -11,14 +11,14 @@ fi for name in test1.txt test2.txt test3.txt ; do echo "Attempt to write $name" - snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" + snap run --shell prompt-requester.home -c "echo $name is written > ${TEST_DIR}/${name}" done # The reply has a hard-coded duration of 10s sleep 10 # wait for the rule to expire echo "Attempt to write test4.txt (should fail)" -snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" || true +snap run --shell prompt-requester.home -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" || true # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/timespan_deny-temporal.json b/tests/main/apparmor-prompting-integration-tests/timespan_deny-temporal.json index 2ddd910a9b9..daf964c26e3 100644 --- a/tests/main/apparmor-prompting-integration-tests/timespan_deny-temporal.json +++ b/tests/main/apparmor-prompting-integration-tests/timespan_deny-temporal.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/timespan_deny.json b/tests/main/apparmor-prompting-integration-tests/timespan_deny.json index fd9bce003e6..6d10d60a547 100644 --- a/tests/main/apparmor-prompting-integration-tests/timespan_deny.json +++ b/tests/main/apparmor-prompting-integration-tests/timespan_deny.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/timespan_deny.sh b/tests/main/apparmor-prompting-integration-tests/timespan_deny.sh index 28786a9ad3e..94df33ade25 100644 --- a/tests/main/apparmor-prompting-integration-tests/timespan_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/timespan_deny.sh @@ -11,14 +11,14 @@ fi for name in test1.txt test2.txt test3.txt ; do echo "Attempt to write $name (should fail)" - snap run --shell prompting-client.scripted -c "echo $name is written > ${TEST_DIR}/${name}" || true + snap run --shell prompt-requester.home -c "echo $name is written > ${TEST_DIR}/${name}" || true done # The reply has a hard-coded duration of 10s sleep 10 # wait for the rule to expire echo "Attempt to write test4.txt" -snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" +snap run --shell prompt-requester.home -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.json b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.json index f8fc8a7c414..5a23066c005 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.json +++ b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.sh b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.sh index a6faf031ea0..ed007e1e49d 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_allow_deny.sh @@ -11,15 +11,15 @@ if [ -z "$TIMEOUT" ] ; then TIMEOUT=10 fi -WRITABLE="$(snap run --shell prompting-client.scripted -c 'cd ~; pwd')/$(basename "$TEST_DIR")" -snap run --shell prompting-client.scripted -c "mkdir -p $WRITABLE" +WRITABLE="$(snap run --shell prompt-requester.home -c 'cd ~; pwd')/$(basename "$TEST_DIR")" +snap run --shell prompt-requester.home -c "mkdir -p $WRITABLE" # First, queue up writes for name in test1.txt test2.txt test3.txt ; do echo "Attempt to write $name in the background" echo "not written" > "${TEST_DIR}/${name}" - snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${name}-write-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${name}-write-finished" & + snap run --shell prompt-requester.home -c "touch ${WRITABLE}/${name}-write-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${name}-write-finished" & if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start write of $name within timeout period" exit 1 @@ -36,7 +36,7 @@ done echo "Attempt to write test4.txt (for which client will reply)" echo "not written" > "${TEST_DIR}/test4.txt" -snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" +snap run --shell prompt-requester.home -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" # Reply for test4.txt will allow always write test*.txt @@ -60,7 +60,7 @@ done for name in test1.txt test2.txt test3.txt ; do echo "Attempt to read $name in the background" - snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${name}-read-started; cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}; touch ${WRITABLE}/${name}-read-finished" & + snap run --shell prompt-requester.home -c "touch ${WRITABLE}/${name}-read-started; cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}; touch ${WRITABLE}/${name}-read-finished" & if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start read of $name within timeout period" exit 1 @@ -76,7 +76,7 @@ for name in test1.txt test2.txt test3.txt ; do done echo "Attempt to read test4.txt (for which client will reply)" -snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test4.txt > ${WRITABLE}/test4.txt" || true +snap run --shell prompt-requester.home -c "cat ${TEST_DIR}/test4.txt > ${WRITABLE}/test4.txt" || true # Reply for test4.txt will deny always read|write test* @@ -104,7 +104,7 @@ done # create other.txt -> prompt, reply with deny (mostly to make sure the client lives long enough) echo "Attempt to create test5.txt (should be allowed by original rule)" -snap run --shell prompting-client.scripted -c "echo test5.txt is written > ${TEST_DIR}/test5.txt" +snap run --shell prompt-requester.home -c "echo test5.txt is written > ${TEST_DIR}/test5.txt" TEST_OUTPUT="$(cat "${TEST_DIR}/test5.txt")" if [ "$TEST_OUTPUT" != "test5.txt is written" ] ; then echo "file creation failed for test5.txt" @@ -112,7 +112,7 @@ if [ "$TEST_OUTPUT" != "test5.txt is written" ] ; then fi echo "Attempt to create test5.md (should be denied by previous rule)" -snap run --shell prompting-client.scripted -c "echo test5.md is written > ${TEST_DIR}/test5.md" || true +snap run --shell prompt-requester.home -c "echo test5.md is written > ${TEST_DIR}/test5.md" || true if [ -f "${TEST_DIR}/test5.md" ] ; then echo "file creation unexpectedly succeeded for test5.md" exit 1 @@ -121,7 +121,7 @@ fi for name in test5.txt test5.md ; do echo "Attempt to read $name (should be denied by previous rule)" echo "$name is written" > "${TEST_DIR}/${name}" - snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}" || true + snap run --shell prompt-requester.home -c "cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}" || true TEST_OUTPUT="$(cat "${WRITABLE}/${name}")" if [ "$TEST_OUTPUT" = "$name is written" ] ; then echo "read unexpectedly succeeded for $name" @@ -130,7 +130,7 @@ for name in test5.txt test5.md ; do done echo "Attempt to create other.txt (should trigger prompt, which is then denied)" -snap run --shell prompting-client.scripted -c "echo other.txt is written > ${TEST_DIR}/other.txt" || true +snap run --shell prompt-requester.home -c "echo other.txt is written > ${TEST_DIR}/other.txt" || true if [ -f "${TEST_DIR}/other.txt" ] ; then echo "file creation unexpectedly succeeded for other.txt" exit 1 diff --git a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.json b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.json index 256b8083998..61348e60130 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.json +++ b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.sh b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.sh index 1c131695bde..cb0d99f7a49 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/write_read_multiple_actioned_by_other_pid_deny_allow.sh @@ -11,15 +11,15 @@ if [ -z "$TIMEOUT" ] ; then TIMEOUT=10 fi -WRITABLE="$(snap run --shell prompting-client.scripted -c 'cd ~; pwd')/$(basename "$TEST_DIR")" -snap run --shell prompting-client.scripted -c "mkdir -p $WRITABLE" +WRITABLE="$(snap run --shell prompt-requester.home -c 'cd ~; pwd')/$(basename "$TEST_DIR")" +snap run --shell prompt-requester.home -c "mkdir -p $WRITABLE" # First, queue up writes for name in test1.txt test2.txt test3.txt ; do echo "Attempt to write $name in the background" echo "not written" > "${TEST_DIR}/${name}" - snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${name}-write-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${name}-write-finished" & + snap run --shell prompt-requester.home -c "touch ${WRITABLE}/${name}-write-started; echo $name is written > ${TEST_DIR}/${name}; touch ${WRITABLE}/${name}-write-finished" & if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-write-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start write of $name within timeout period" exit 1 @@ -36,7 +36,7 @@ done echo "Attempt to write test4.txt (for which client will reply)" echo "not written" > "${TEST_DIR}/test4.txt" -snap run --shell prompting-client.scripted -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" || true +snap run --shell prompt-requester.home -c "echo test4.txt is written > ${TEST_DIR}/test4.txt" || true # Reply for test4.txt will deny always write test*.txt @@ -63,7 +63,7 @@ done for name in test1.txt test2.txt test3.txt ; do echo "Attempt to read $name in the background" - snap run --shell prompting-client.scripted -c "touch ${WRITABLE}/${name}-read-started; cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}; touch ${WRITABLE}/${name}-read-finished" & + snap run --shell prompt-requester.home -c "touch ${WRITABLE}/${name}-read-started; cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}; touch ${WRITABLE}/${name}-read-finished" & if ! timeout --verbose "$TIMEOUT" sh -c "while ! [ -f '${WRITABLE}/${name}-read-started' ] ; do sleep 0.1 ; done" ; then echo "failed to start read of $name within timeout period" exit 1 @@ -79,7 +79,7 @@ for name in test1.txt test2.txt test3.txt ; do done echo "Attempt to read test4.txt (for which client will reply)" -snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/test4.txt > ${WRITABLE}/test4.txt" +snap run --shell prompt-requester.home -c "cat ${TEST_DIR}/test4.txt > ${WRITABLE}/test4.txt" # Reply for test4.txt will allow always read|write test* @@ -107,14 +107,14 @@ done # create other.txt -> prompt, reply with deny (mostly to make sure the client lives long enough) echo "Attempt to create test5.txt (should be denied by original rule)" -snap run --shell prompting-client.scripted -c "echo test5.txt is written > ${TEST_DIR}/test5.txt" || true +snap run --shell prompt-requester.home -c "echo test5.txt is written > ${TEST_DIR}/test5.txt" || true if [ -f "${TEST_DIR}/test5.txt" ] ; then echo "file creation unexpectedly succeeded for test5.txt" exit 1 fi echo "Attempt to create test5.md (should be allowed by previous rule)" -snap run --shell prompting-client.scripted -c "echo test5.md is written > ${TEST_DIR}/test5.md" +snap run --shell prompt-requester.home -c "echo test5.md is written > ${TEST_DIR}/test5.md" TEST_OUTPUT="$(cat "${TEST_DIR}/test5.md")" if [ "$TEST_OUTPUT" != "test5.md is written" ] ; then echo "file creation failed for test5.md" @@ -124,7 +124,7 @@ fi for name in test5.txt test5.md ; do echo "Attempt to read $name (should be allowed by previous rule)" echo "$name is written" > "${TEST_DIR}/${name}" - snap run --shell prompting-client.scripted -c "cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}" + snap run --shell prompt-requester.home -c "cat ${TEST_DIR}/${name} > ${WRITABLE}/${name}" TEST_OUTPUT="$(cat "${WRITABLE}/${name}")" if [ "$TEST_OUTPUT" != "${name} is written" ] ; then echo "read failed for ${name}" @@ -133,7 +133,7 @@ for name in test5.txt test5.md ; do done echo "Attempt to create other.txt (should trigger prompt, which is then denied)" -snap run --shell prompting-client.scripted -c "echo other.txt is written > ${TEST_DIR}/other.txt" || true +snap run --shell prompt-requester.home -c "echo other.txt is written > ${TEST_DIR}/other.txt" || true if [ -f "${TEST_DIR}/other.txt" ] ; then echo "file creation unexpectedly succeeded for other.txt" exit 1 diff --git a/tests/main/apparmor-prompting-integration-tests/write_single_allow-temporal.json b/tests/main/apparmor-prompting-integration-tests/write_single_allow-temporal.json index ec74871307d..680b126e546 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_single_allow-temporal.json +++ b/tests/main/apparmor-prompting-integration-tests/write_single_allow-temporal.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/write_single_allow.json b/tests/main/apparmor-prompting-integration-tests/write_single_allow.json index 7d57e83010c..d7a2a3cfd9c 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_single_allow.json +++ b/tests/main/apparmor-prompting-integration-tests/write_single_allow.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/write_single_allow.sh b/tests/main/apparmor-prompting-integration-tests/write_single_allow.sh index ac115443488..3b99e113be2 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_single_allow.sh +++ b/tests/main/apparmor-prompting-integration-tests/write_single_allow.sh @@ -9,7 +9,7 @@ if [ -z "$TIMEOUT" ] ; then fi echo "Attempt to write the file" -snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/test.txt" +snap run --shell prompt-requester.home -c "echo it is written > ${TEST_DIR}/test.txt" # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do diff --git a/tests/main/apparmor-prompting-integration-tests/write_single_deny.json b/tests/main/apparmor-prompting-integration-tests/write_single_deny.json index a87ae9b84b1..4221bcc6337 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_single_deny.json +++ b/tests/main/apparmor-prompting-integration-tests/write_single_deny.json @@ -1,7 +1,7 @@ { "version": 1, "prompt-filter": { - "snap": "prompting-client", + "snap": "prompt-requester", "interface": "home", "constraints": { "path": "$BASE_PATH/.*" diff --git a/tests/main/apparmor-prompting-integration-tests/write_single_deny.sh b/tests/main/apparmor-prompting-integration-tests/write_single_deny.sh index ebf1159baee..b8b3f0ad641 100644 --- a/tests/main/apparmor-prompting-integration-tests/write_single_deny.sh +++ b/tests/main/apparmor-prompting-integration-tests/write_single_deny.sh @@ -9,7 +9,7 @@ if [ -z "$TIMEOUT" ] ; then fi echo "Attempt to write the file (should fail)" -snap run --shell prompting-client.scripted -c "echo it is written > ${TEST_DIR}/test.txt" || true +snap run --shell prompt-requester.home -c "echo it is written > ${TEST_DIR}/test.txt" || true # Wait for the client to write its result and exit for i in $(seq "$TIMEOUT") ; do