Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Test that the cache listing is off by default
The listing exposes the urls other visitors asked for, and every
request for it used the shared config, which turns it on.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0003-cache.sh | 20 |
1 file changed, 20 insertions, 0 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index c044a84..c7e8369 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -81,6 +81,26 @@ test_expect_success 'a full table gives each request a slot of its own' ' test_cmp output.full output.second ' +# The listing names the cache path and the urls other visitors asked for, so +# it answers only where enable-cache-list is set, and as plain text. +test_expect_success 'the cache listing answers only where it is enabled' ' + sed -e "/^enable-cache-list=/d" -e "s/^cache-size=.*/cache-size=0/" cgitrc >nolistrc && + cgit_rc nolistrc "url=foo/ls_cache" >nolist.out && + test_grep "^Status: 404" nolist.out && + test_grep ! -F "$PWD/cache" nolist.out && + sed "s/^cache-size=.*/cache-size=0/" cgitrc >listrc && + cgit_ok listrc "url=foo/ls_cache" >list.out && + test_grep "^Content-Type: text/plain" list.out && + test_grep -F "$PWD/cache/" list.out +' + +test_expect_success 'a cache listing without its directory says so' ' + sed -e "s|^cache-root=.*|cache-root=$PWD/no-such-cache|" -e "s/^cache-size=.*/cache-size=0/" cgitrc >nocacherc && + cgit_rc nocacherc "url=foo/ls_cache" >nocache.out 2>nocache.err && + test_grep "^Status: 200" nocache.out && + test_grep -F "Unable to open $PWD/no-such-cache: No such file or directory" nocache.err +' + # Page output is buffered, so a slot only holds the whole page if the buffer is # emptied before the size of what was generated is taken. The blob set up here # is larger than one buffer, so a missing flush would leave the cached copy cut |
