From f653896b1850f52af3e85a0eb3a00442cba5e5cd Mon Sep 17 00:00:00 2001 From: John Cardullo Date: Fri, 3 Jul 2026 10:06:24 -0700 Subject: [PATCH] tests: Add test cases for file-forwarding in test-run.sh Add regression tests to verify that remote URIs and local files can be forwarded correctly, and that empty paths result in an error. --- tests/test-run.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/test-run.sh b/tests/test-run.sh index d5bf37d0b..a61f927b2 100644 --- a/tests/test-run.sh +++ b/tests/test-run.sh @@ -24,7 +24,7 @@ set -euo pipefail skip_without_bwrap skip_revokefs_without_fuse -echo "1..27" +echo "1..30" # Use stable rather than master as the branch so we can test that the run # command automatically finds the branch correctly @@ -608,3 +608,23 @@ assert_file_has_content hello_out "not allowed to avoid sandbox escape" assert_not_file_has_content hello_out "secret-file" ok "--persist doesn't allow sandbox escape via a symlink (CVE-2024-42472)" + +run --file-forwarding --command=sh org.test.Hello -c 'echo "$@"' sh @@u https://google.com @@ > file_fwd_out +assert_file_has_content file_fwd_out "^https://google.com$" +ok "file-forwarding remote URI" + +if $FLATPAK documents &> /dev/null; then + echo "test" > local_file.txt + run --file-forwarding --command=sh org.test.Hello -c 'echo "$@"' sh @@ local_file.txt @@ > file_fwd_out2 + assert_file_has_content file_fwd_out2 "/doc/" + ok "file-forwarding valid path" + + if run --file-forwarding --command=sh org.test.Hello -c 'echo "$@"' sh @@ "" @@ &> file_fwd_err; then + assert_not_reached "Should not be able to forward empty path" + fi + assert_file_has_content file_fwd_err "Invalid path" + ok "file-forwarding empty path" +else + ok "file-forwarding valid path # SKIP (no document portal)" + ok "file-forwarding empty path # SKIP (no document portal)" +fi \ No newline at end of file