diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Harden the lua filter failure paths
Diffstat (limited to 'tests')
-rwxr-xr-xtests/t0201-filters.sh22
1 file changed, 22 insertions, 0 deletions
diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh
index a8341aa..8d67c4f 100755
--- a/tests/t0201-filters.sh
+++ b/tests/t0201-filters.sh
@@ -65,4 +65,26 @@ do
"
done
+test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA
+test "$CGIT_HAS_LUA" -eq 1 || say 'cgit built without lua, error page check skipped'
+
+# A die inside a lua filter has to reach the visitor as an error page rather
+# than being fed back into the filter that just failed.
+test_expect_success CGIT_LUA 'a failing lua filter still renders an error page' '
+ cat >broken.lua <<-\EOF &&
+ function filter_open(...) error("boom") end
+ function filter_write(str) end
+ function filter_close() return 0 end
+ EOF
+ {
+ echo "cache-size=0" &&
+ echo "repo.url=foo" &&
+ echo "repo.path=$PWD/repos/foo/.git" &&
+ echo "auth-filter=lua:$PWD/broken.lua"
+ } >brokenrc &&
+ CGIT_CONFIG="$PWD/brokenrc" QUERY_STRING="url=foo/commit" cgit >tmp &&
+ grep "Status: 400" tmp &&
+ grep "Lua error in" tmp
+'
+
test_done