Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Move the later tests to the config writers
The one-line request wrappers go with them. Configs with several
repositories, a key out of place on purpose, the cache on or no
repository of their own stay written out.
Diffstat (limited to 'tests/t0204-limits.sh')
| -rwxr-xr-x | tests/t0204-limits.sh | 54 |
1 file changed, 16 insertions, 38 deletions
diff --git a/tests/t0204-limits.sh b/tests/t0204-limits.sh index 1a1d7ad..ecc33bf 100755 --- a/tests/t0204-limits.sh +++ b/tests/t0204-limits.sh @@ -29,26 +29,10 @@ test_expect_success 'set up limit fixtures' ' git tag tag-$i || exit 1 done ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "max-ref-count=2" && - echo "max-diff-lines=20" && - echo "max-diff-files=0" && - echo "repo.url=limits" && - echo "repo.path=$PWD/repos/limits/.git" - } >limitrc && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "max-diff-files=1" && - echo "repo.url=limits" && - echo "repo.path=$PWD/repos/limits/.git" - } >limitfilesrc + cgitrc_repo limitrc limits max-ref-count=2 max-diff-lines=20 max-diff-files=0 && + cgitrc_repo limitfilesrc limits max-diff-files=1 ' -limitq() { CGIT_CONFIG="$PWD/limitrc" QUERY_STRING="$1" cgit; } - # An index query is compared against every repository the listing holds, so # an enormous one multiplies out across the whole index. Clamping it rather # than refusing it keeps the cost bounded without making an ordinary search @@ -71,7 +55,7 @@ test_expect_success 'an ordinary query still filters the index' ' # hands the overflow to page on their own, so a limit that leaked between the # two sections would show up as the wrong link or the wrong count here. test_expect_success 'refs page lists max-ref-count branches and tags' ' - limitq "url=limits/refs/" >tmp && + cgit_rc limitrc "url=limits/refs/" >tmp && test $(grep -c "log/?h=" tmp) -eq 2 && test $(grep -c "/tag/?h=tag-" tmp) -eq 2 ' @@ -82,16 +66,16 @@ test_expect_success 'refs page links each overflow to its own category' ' ' test_expect_success 'branch page paginates independently' ' - limitq "url=limits/refs/heads/" >tmp && + cgit_rc limitrc "url=limits/refs/heads/" >tmp && test $(grep -c "log/?h=" tmp) -eq 2 && grep "\[next\]" tmp && - limitq "url=limits/refs/heads/&ofs=2" >tmp && + cgit_rc limitrc "url=limits/refs/heads/&ofs=2" >tmp && grep "\[prev\]" tmp && ! grep "/tag/?h=tag-" tmp ' test_expect_success 'tag page paginates independently' ' - limitq "url=limits/refs/tags/&ofs=2" >tmp && + cgit_rc limitrc "url=limits/refs/tags/&ofs=2" >tmp && grep "/tag/?h=tag-" tmp && grep "\[prev\]" tmp && ! grep "log/?h=" tmp @@ -107,8 +91,8 @@ test_expect_success 'a negative ref count lists every ref' ' echo "summary-tags=$n" && sed "s/^max-ref-count=2$/max-ref-count=$n/" limitrc } >count$n.rc && - CGIT_CONFIG="$PWD/count$n.rc" QUERY_STRING="url=limits/refs/" cgit >refs$n && - CGIT_CONFIG="$PWD/count$n.rc" QUERY_STRING="url=limits/" cgit >summary$n || + cgit_rc count$n.rc "url=limits/refs/" >refs$n && + cgit_rc count$n.rc "url=limits/" >summary$n || return 1 done && grep "log/?h=branch-3" refs0 && @@ -122,7 +106,7 @@ test_expect_success 'a negative ref count lists every ref' ' # The rest of the commit still renders, so one huge file cannot hide the # small change beside it. test_expect_success 'oversized file diff is replaced by a link' ' - limitq "url=limits/commit/" >tmp && + cgit_rc limitrc "url=limits/commit/" >tmp && grep "too large to be rendered inline" tmp && grep "View it on its own page" tmp ' @@ -132,7 +116,7 @@ test_expect_success 'small file in the same commit still renders inline' ' ' test_expect_success 'the single-file diff page always renders in full' ' - limitq "url=limits/diff/big.c" >tmp && + cgit_rc limitrc "url=limits/diff/big.c" >tmp && grep "class=.hunk." tmp && ! grep "too large to be rendered inline" tmp ' @@ -141,13 +125,13 @@ test_expect_success 'the single-file diff page always renders in full' ' # so it drops the whole body back to the diffstat while a request naming a # single file stays unaffected. test_expect_success 'a commit changing too many files shows stat only' ' - CGIT_CONFIG="$PWD/limitfilesrc" QUERY_STRING="url=limits/commit/" cgit >tmp && + cgit_rc limitfilesrc "url=limits/commit/" >tmp && grep "too large to be rendered inline" tmp && ! grep "class=.hunk." tmp ' test_expect_success 'the single-file page is not limited by max-diff-files' ' - CGIT_CONFIG="$PWD/limitfilesrc" QUERY_STRING="url=limits/diff/small.c" cgit >tmp && + cgit_rc limitfilesrc "url=limits/diff/small.c" >tmp && grep "class=.hunk." tmp ' @@ -164,15 +148,9 @@ test_expect_success 'a diff of an oversized blob is not inlined' ' awk "BEGIN{for(i=0;i<401;i++)print \"aaaaaaaa\"}" >big.txt && git commit -am change ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "max-blob-size=1" && - echo "repo.url=blobdiff" && - echo "repo.path=$PWD/repos/blobdiff/.git" - } >blobdiffrc && + cgitrc_repo blobdiffrc blobdiff max-blob-size=1 && sha=$(git -C repos/blobdiff rev-parse HEAD) && - CGIT_CONFIG="$PWD/blobdiffrc" QUERY_STRING="url=blobdiff/commit/&id=$sha" cgit >tmp && + cgit_rc blobdiffrc "url=blobdiff/commit/&id=$sha" >tmp && grep "Binary files differ" tmp && ! grep "aaaaaaaa" tmp ' @@ -184,7 +162,7 @@ test_expect_success 'every page showing a blob refuses an oversized one alike' ' } >blobpagesrc && for page in tree plain blob blame do - CGIT_CONFIG="$PWD/blobpagesrc" QUERY_STRING="url=blobdiff/$page/big.txt" cgit >tmp && + cgit_rc blobpagesrc "url=blobdiff/$page/big.txt" >tmp && grep "^Status: 413 Content Too Large" tmp && grep "Blob size (3 KB) exceeds the limit (1 KB)" tmp || return 1 done @@ -202,7 +180,7 @@ test_expect_success 'patch and rawdiff show an oversized blob as binary' ' } >blobrc && for p in patch rawdiff do - CGIT_CONFIG="$PWD/blobrc" QUERY_STRING="url=limits/$p/" cgit >tmp && + cgit_rc blobrc "url=limits/$p/" >tmp && grep "^Binary files" tmp && ! grep "^+1999$" tmp || return 1 done |
