diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Gate scanned filters with `trust-scan-filters`
Diffstat (limited to 'tests')
-rw-r--r--tests/extensions/lib.sh1
-rwxr-xr-xtests/setup.sh1
-rwxr-xr-xtests/t0205-config.sh34
-rwxr-xr-xtests/t0206-trailers.sh1
-rwxr-xr-xtests/t0501-about-render.sh1
-rwxr-xr-xtests/t0502-syntax-highlight.sh1
-rwxr-xr-xtests/t0503-link-commits.sh1
-rwxr-xr-xtests/t0504-email-avatar.sh1
-rwxr-xr-xtests/t0506-link-trailers.sh1
9 files changed, 30 insertions, 12 deletions
diff --git a/tests/extensions/lib.sh b/tests/extensions/lib.sh
index 26fcbec..ec1ef85 100644
--- a/tests/extensions/lib.sh
+++ b/tests/extensions/lib.sh
@@ -59,7 +59,6 @@ cgit_lua_probe() {
cat >lua-probe-cgitrc <<EOF
virtual-root=/
cache-size=0
-enable-filter-overrides=1
repo.url=lua-probe
repo.path=$cgit_lua_probe_gitdir
repo.commit-filter=lua:$PWD/lua-probe.lua
diff --git a/tests/setup.sh b/tests/setup.sh
index de4fcc6..f84b1b6 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -129,7 +129,6 @@ summary-log=5
summary-branches=5
summary-tags=5
clone-url=git://example.org/\$CGIT_REPO_URL.git
-enable-filter-overrides=1
repo.url=foo
repo.path=$PWD/repos/foo/.git
diff --git a/tests/t0205-config.sh b/tests/t0205-config.sh
index a7d32f4..1a4f5d0 100755
--- a/tests/t0205-config.sh
+++ b/tests/t0205-config.sh
@@ -1,8 +1,9 @@
#!/bin/sh
# Checks what the configuration parser reports on stderr. A key it does not
-# know, a repo key before any repository and a filter override without its
-# enabling flag are each ignored with a warning naming the key, and a config
+# know, a repo key before any repository and a filter set by a scanned
+# repository without trust-scan-filters are each ignored with a warning naming
+# the key, a repo filter in the main cgitrc passes without one, and a config
# cgit fully understands stays silent.
test_description='Check configuration diagnostics'
@@ -40,8 +41,33 @@ test_expect_success 'a repo key before any repo.url is reported' '
grep "Ignoring repo.desc before any repo.url" err
'
-test_expect_success 'a filter override without its flag is reported' '
- grep "Ignoring repo about-filter: enable-filter-overrides is not set" err
+test_expect_success 'a filter in a scanned repository is reported without its flag' '
+ git clone -q --bare repos/foo/.git scan/foo.git &&
+ echo "commit-filter=exec:$FILTER_DIRECTORY/dump.sh" >scan/foo.git/cgitrc &&
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "scan-path=$PWD/scan"
+ } >scanrc &&
+ CGIT_CONFIG="$PWD/scanrc" QUERY_STRING="url=foo.git/commit/" cgit >tmp 2>err &&
+ grep "<div class=.commit-subject.>commit 5" tmp &&
+ grep "Ignoring commit-filter in $PWD/scan/foo.git/: trust-scan-filters is not set" err
+'
+
+test_expect_success 'the flag lets a scanned repository set its filters' '
+ {
+ echo "trust-scan-filters=1" &&
+ cat scanrc
+ } >scanrc-on &&
+ CGIT_CONFIG="$PWD/scanrc-on" QUERY_STRING="url=foo.git/commit/" cgit >tmp 2>err &&
+ grep "<div class=.commit-subject.>COMMIT 5" tmp &&
+ ! grep "Ignoring" err
+'
+
+test_expect_success 'a repo filter in the main cgitrc needs no flag' '
+ ! grep "about-filter" err &&
+ CGIT_CONFIG="$PWD/earlyrc" QUERY_STRING="url=diag/" cgit >tmp 2>err &&
+ ! grep "about-filter" err
'
test_expect_success 'a fully understood config stays silent' '
diff --git a/tests/t0206-trailers.sh b/tests/t0206-trailers.sh
index 75c59a1..e8e615c 100755
--- a/tests/t0206-trailers.sh
+++ b/tests/t0206-trailers.sh
@@ -42,7 +42,6 @@ test_expect_success 'point cgit at it with trailers on and the dump filters' '
virtual-root=/
cache-size=0
enable-trailers=1
- enable-filter-overrides=1
repo.url=trailers
repo.path=$PWD/repos/trailers/.git
repo.trailer-filter=exec:$FILTER_DIRECTORY/dump.sh
diff --git a/tests/t0501-about-render.sh b/tests/t0501-about-render.sh
index c2fdb71..f870c0e 100755
--- a/tests/t0501-about-render.sh
+++ b/tests/t0501-about-render.sh
@@ -46,7 +46,6 @@ test_expect_success 'point cgit at it through the about filter' '
cat >cgitrc <<-EOF
virtual-root=/
cache-size=0
- enable-filter-overrides=1
repo.url=md
repo.path=$PWD/repos/md/.git
repo.readme=master:README.md
diff --git a/tests/t0502-syntax-highlight.sh b/tests/t0502-syntax-highlight.sh
index a6e3fcb..31ab7e7 100755
--- a/tests/t0502-syntax-highlight.sh
+++ b/tests/t0502-syntax-highlight.sh
@@ -54,7 +54,6 @@ test_expect_success 'place the fake lexers beside a config naming the filter' '
cat >cgitrc <<-EOF
virtual-root=/
cache-size=0
- enable-filter-overrides=1
repo.url=fake
repo.path=$PWD/repos/fake/.git
repo.source-filter=lua:$EXTENSIONS_DIRECTORY/syntax-highlight.lua
diff --git a/tests/t0503-link-commits.sh b/tests/t0503-link-commits.sh
index 1dfb28c..d977517 100755
--- a/tests/t0503-link-commits.sh
+++ b/tests/t0503-link-commits.sh
@@ -40,7 +40,6 @@ test_expect_success 'point cgit at it through the commit filter' '
cat >cgitrc <<-EOF
virtual-root=/
cache-size=0
- enable-filter-overrides=1
repo.url=linky
repo.path=$PWD/repos/linky/.git
repo.commit-filter=lua:$EXTENSIONS_DIRECTORY/link-commits.lua
diff --git a/tests/t0504-email-avatar.sh b/tests/t0504-email-avatar.sh
index 1af8988..91ddc20 100755
--- a/tests/t0504-email-avatar.sh
+++ b/tests/t0504-email-avatar.sh
@@ -57,7 +57,6 @@ test_expect_success CGIT_LUA_OSSL 'point cgit at it through the email filter' '
cat >cgitrc <<-EOF
virtual-root=/
cache-size=0
- enable-filter-overrides=1
repo.url=avatar
repo.path=$PWD/repos/avatar/.git
repo.email-filter=lua:$EXTENSIONS_DIRECTORY/email-gravatar.lua
diff --git a/tests/t0506-link-trailers.sh b/tests/t0506-link-trailers.sh
index d397309..f6fedf2 100755
--- a/tests/t0506-link-trailers.sh
+++ b/tests/t0506-link-trailers.sh
@@ -47,7 +47,6 @@ test_expect_success 'point cgit at it through the trailer filter' '
virtual-root=/
cache-size=0
enable-trailers=1
- enable-filter-overrides=1
repo.url=linky
repo.path=$PWD/repos/linky/.git
repo.trailer-filter=lua:$EXTENSIONS_DIRECTORY/link-trailers.lua