Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Test every setting in the scan cache key
Only strict-export and the global filters were ever varied against one
cache-root, so dropping any of the other inputs passed. Leaving out
trust-scan-config is the one that matters most. A list scanned under
it carries the filters pushers set, the list is read back with no trust
check, and a site that does not trust its scans would run them.
| -rwxr-xr-x | tests/t0003-cache.sh | 94 |
1 file changed, 94 insertions, 0 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index 3dd171b..a07950b 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -481,6 +481,100 @@ test_expect_success 'a config that scans differently keeps its own list' ' ! grep ">two</a>" strict.out ' +# A list scanned under trust-scan-config carries the filters a repository +# set, and the list is read back with no trust check, so a config that does +# not trust its scans has to keep a list of its own. Pages are left uncached, +# since the page cache is keyed on the request alone. +test_expect_success 'a config that trusts its scans keeps its own list' ' + mkrepo trusted/one 1 && + echo "commit-filter=exec:$FILTER_DIRECTORY/dump.sh" >trusted/one/.git/cgitrc && + { + echo "virtual-root=/" && + echo "cache-root=$PWD/cache7" && + echo "cache-size=64" && + echo "cache-dynamic-ttl=0" && + echo "scan-path=$PWD/trusted" + } >distrustrc && + { + echo "trust-scan-config=1" && + cat distrustrc + } >trustrc && + rm -rf cache7 && mkdir cache7 && + cgit_ok trustrc "url=one/commit/" >trust.out && + test_grep "<div class=.commit-subject.>COMMIT 1" trust.out && + cgit_rc distrustrc "url=one/commit/" >distrust.out 2>distrust.err && + test_grep "^Status: 200" distrust.out && + test_grep "<div class=.commit-subject.>commit 1" distrust.out && + test_grep "Ignoring commit-filter in $PWD/trusted/one/.git/: trust-scan-config is not set" distrust.err && + ls cache7/rc-* >lists && + test_line_count = 2 lists +' + +# Every setting the scan reads, or hands each repository as a default, goes +# into the name of the list, so changing any one of them, or the path, must +# start a list of its own. +test_expect_success 'every setting the scan depends on keeps its own list' ' + mkrepo keyed/one 1 && + echo one >projects && + { + echo "virtual-root=/" && + echo "cache-root=$PWD/cache8" && + echo "cache-size=64" && + echo "scan-path=$PWD/keyed" + } >keyedrc && + rm -rf cache8 && mkdir cache8 && + cgit_ok keyedrc "url=" >/dev/null && + sed "s|^scan-path=.*|scan-path=$PWD/keyed/one|" keyedrc >keyed-setting-rc && + cgit_ok keyed-setting-rc "url=" >/dev/null && + ls cache8/rc-* >lists && + test_line_count = 2 lists && + lists=2 && + while read setting + do + { + echo "$setting" && + cat keyedrc + } >keyed-setting-rc && + cgit_ok keyed-setting-rc "url=" >/dev/null && + lists=$((lists + 1)) && + ls cache8/rc-* >lists && + test_line_count = $lists lists || + { echo "$setting shares a list" && return 1; } + done <<-EOF + project-list=$PWD/projects + strict-export=git-daemon-export-ok + section=Sec + module-link=https://example.org/%s + clone-url=https://example.org/\$CGIT_REPO_URL + scan-hidden-path=1 + case-sensitive-sort=0 + remove-suffix=1 + section-from-path=1 + enable-git-config=1 + trust-scan-config=1 + snapshots=zip + max-stats=year + branch-sort=age + commit-sort=date + enable-blame=1 + enable-commit-graph=1 + enable-commit-trailers=1 + enable-follow-links=1 + enable-gitmodules-links=1 + enable-html-serving=1 + enable-log-filecount=1 + enable-log-linecount=1 + enable-mailmap=0 + enable-remote-branches=1 + enable-subject-links=1 + about-filter=exec:$FILTER_DIRECTORY/dump.sh + commit-filter=exec:$FILTER_DIRECTORY/dump.sh + email-filter=exec:$FILTER_DIRECTORY/dump.sh + source-filter=exec:$FILTER_DIRECTORY/dump.sh + trailer-filter=exec:$FILTER_DIRECTORY/dump.sh + EOF +' + # A negative ttl never expires, so a list however old is served and kept. A # rebuild runs in a child holding the request's copy of fd 9, so cat reaching # the end of that pipe means any rebuild is done, as the positive ttl after |
