Skip to content

Commit

Permalink
tests: adjust prompting download file tests now that rules may overlap
Browse files Browse the repository at this point in the history
Now that canonical#14538 has landed, rules
may overlap as long as their outcomes do not conflict. As such, the
download_file_defaults test case is no longer expected to fail.

Signed-off-by: Oliver Calder <[email protected]>
  • Loading branch information
olivercalder committed Oct 21, 2024
1 parent a6db230 commit 180f45d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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" ; then
if ! snap run --shell prompting-client.scripted -c "ls ${TEST_DIR}/Downloads" | grep "existing.txt" ; then
echo "Failed to list contents of ${TEST_DIR}/Downloads"
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,17 @@ timeout "$TIMEOUT" sh -c "while pgrep -f 'prompting-client.scripted.*${TEST_DIR}

CLIENT_OUTPUT="$(cat "${TEST_DIR}/result")"

# We don't expect success, since there should be a rule conflict with the rule
# we just added to grant read access forever
if [ "$CLIENT_OUTPUT" = "success" ] ; then
echo "test unexpectedly succeeded, expected rule conflict error"
# Now that two rules with the same pattern variant may coexist so long as their
# outcomes do not conflict, we expect success.
if [ "$CLIENT_OUTPUT" != "success" ] ; then
echo "test failed"
echo "output='$CLIENT_OUTPUT'"
exit 1
fi

if ! grep 'cannot add rule: a rule with conflicting path pattern and permission already exists in the rule database' "${TEST_DIR}/result" ; then
echo "test failed, expected rule conflict error"
echo "output='$CLIENT_OUTPUT'"
exit 1
fi
TEST_OUTPUT="$(cat "${TEST_DIR}/Downloads/test.txt")"

if [ -f "$TEST_DIR/test.txt" ] ; then
echo "file creation unexpectedly succeeded for test.txt"
cat "${TEST_DIR}/test.txt"
if [ "$TEST_OUTPUT" != "it is written" ] ; then
echo "write failed for test.txt"
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi
mkdir -p "${TEST_DIR}/Downloads"
touch "${TEST_DIR}/Downloads/existing.txt"

echo "Attempt to list the contents of the parent directory"
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
echo "Failed to list contents of ${TEST_DIR}/Downloads"
exit 1
Expand Down

0 comments on commit 180f45d

Please sign in to comment.