diff options
Diffstat (limited to 'tests/t0201-limits.sh')
| -rwxr-xr-x | tests/t0201-limits.sh | 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 33 insertions, 13 deletions
diff --git a/tests/t0201-limits.sh b/tests/t0201-limits.sh index 72d8a23..f09c290 100755 --- a/tests/t0201-limits.sh +++ b/tests/t0201-limits.sh @@ -1,5 +1,14 @@ #!/bin/sh +# Checks the ceilings a config can put on a page, that is the caps on refs +# listed, on the lines and the files a diff renders inline, and on the size +# of a blob any view will inflate, along with the clamp on how long an index +# query may be. Crossing one of these has to trim the page or point the +# reader at somewhere better suited, never drop the request, so each case +# watches what survives as closely as what is left out. The last case is the +# same idea applied to a filter, which degrades to escaped text rather than +# failing when its highlighting library is absent. + test_description='Check the ref listing and diff size limits' . ./setup.sh @@ -7,8 +16,10 @@ if [ $CGIT_HAS_LUA -eq 1 ]; then test_set_prereq LUA fi -# A repo with several branches and tags, one commit with an oversized file -# diff beside a small one, and configs that pin tiny limits. +# The limits only show themselves against content that crosses them, so the +# fixture carries more branches and tags than max-ref-count allows and a +# commit whose oversized file diff sits beside a small one, which is what +# tells a per file limit apart from a whole page one. test_expect_success 'set up limit fixtures' ' mkrepo repos/limits 1 && ( @@ -43,10 +54,10 @@ test_expect_success 'set up limit fixtures' ' limitq() { CGIT_CONFIG="$PWD/limitrc" QUERY_STRING="$1" cgit; } -# --- A request cannot ask for an unbounded amount of matching --------------- -# The query is compared against every repository the index lists, so an -# enormous one would multiply out across the whole listing. It is clamped -# rather than rejected, so an ordinary query still narrows the page. +# 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 +# behave any differently. test_expect_success 'an enormous query is clamped, not rejected' ' long=$(awk "BEGIN{s=\"\";for(i=0;i<4000;i++)s=s \"a\"; print s}") && test ${#long} -eq 4000 && @@ -62,7 +73,9 @@ test_expect_success 'an ordinary query still filters the index' ' ! grep ">bar<" tmp ' -# --- The refs page caps each section and links to the category pages -------- +# The combined refs page caps branches and tags separately, and the pages it +# 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 && test $(grep -c "log/?h=" tmp) -eq 2 && @@ -90,7 +103,10 @@ test_expect_success 'tag page paginates independently' ' ! grep "log/?h=" tmp ' -# --- Oversized file diffs link out instead of rendering inline -------------- +# A file that busts max-diff-lines is replaced by a link to its own page, +# where the reader asked for that one file and the limit no longer applies. +# 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 && grep "too large to be rendered inline" tmp && @@ -107,7 +123,9 @@ test_expect_success 'the single-file diff page always renders in full' ' ! grep "too large to be rendered inline" tmp ' -# --- Commits over max-diff-files fall back to the diffstat ------------------ +# max-diff-files counts the files in a commit rather than the lines in one, +# 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 && grep "too large to be rendered inline" tmp && @@ -119,9 +137,9 @@ test_expect_success 'the single-file page is not limited by max-diff-files' ' grep "class=.hunk." tmp ' -# --- max-blob-size also bounds the diff path -------------------------------- -# The diff family must not inflate a blob larger than max-blob-size just to -# render it. Such a file is reported as binary instead of inlined. +# The diff views must not inflate a blob past max-blob-size merely to render +# it, which is the same defence the tree and plain views make and is easy to +# miss on this path. Such a file is reported as binary instead. test_expect_success 'a diff of an oversized blob is not inlined' ' mkrepo repos/blobdiff 1 && ( @@ -145,7 +163,9 @@ test_expect_success 'a diff of an oversized blob is not inlined' ' ! grep "aaaaaaaa" tmp ' -# --- The shipped highlight filter degrades to escaped passthrough ----------- +# A missing scintillua leaves the shipped filter with nothing to highlight +# with, and a filter that failed there would take the whole page down with +# it, so it has to hand the source back escaped instead. test_expect_success LUA 'highlight filter passes text through without scintillua' ' { echo "virtual-root=/" && |
