Diff options
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0303-robustness.sh | 270 |
1 file changed, 88 insertions, 182 deletions
diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index 41b2bc4..0bb402f 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -7,6 +7,25 @@ test_description='Check the audit regressions' . ./setup.sh +# Writes a config to the file named first, rooted at / with the cache off, +# holding the settings named after it in order, for a site cgitrc_repo cannot +# describe, a scan or more than one repository say. +cgitrc_site() { + cgitrc_site_file=$1 + shift + printf '%s\n' virtual-root=/ cache-size=0 "$@" >"$cgitrc_site_file" +} + +# Fails unless the response in the file named second opens with the status +# named first and carries no other, as a page that fails once its headers are +# out answers a second time below them. +expect_status() { + sed -n 1p "$2" >status-line && + test_grep "^Status: $1 " status-line && + grep "^Status:" "$2" >status-lines && + test_line_count = 1 status-lines +} + # The tests that only read a repository share rob, and each test that changes # one, or needs one in a shape of its own, builds it, so what a test finds # does not hang on the tests that ran before it. @@ -17,17 +36,11 @@ test_expect_success 'set up a repository and a config to vary' ' ' test_expect_success 'a repository without a path answers 404' ' - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=nopath" && - echo "repo.url=emptypath" && - echo "repo.path=" - } >nopathrc && + cgitrc_site nopathrc repo.url=nopath repo.url=emptypath repo.path= && for r in nopath emptypath do cgit_rc nopathrc "url=$r/log/" >tmp && - grep "^Status: 404 Not Found" tmp && + expect_status 404 tmp && grep "Failed to open $r: Not a valid git repository" tmp || return 1 done ' @@ -35,11 +48,7 @@ test_expect_success 'a repository without a path answers 404' ' # The index dates a repository from files under its path, and one without a # path has none, whatever sits in the working directory. test_expect_success 'a repository without a path has no age on the index' ' - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=nopath" - } >nopathagerc && + cgitrc_site nopathagerc repo.url=nopath && mkdir -p "(null)/refs/heads" && >"(null)/refs/heads/master" && cgit_ok nopathagerc "url=" >tmp && @@ -49,47 +58,28 @@ test_expect_success 'a repository without a path has no age on the index' ' ' test_expect_success 'a repository with an empty url is skipped with a warning' ' - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=" && - echo "repo.path=$PWD/repos/rob/.git" && - echo "repo.desc=nourl" && - echo "repo.url=rob" && - echo "repo.path=$PWD/repos/rob/.git" - } >nourlrc && + cgitrc_site nourlrc repo.url= "repo.path=$PWD/repos/rob/.git" repo.desc=nourl \ + repo.url=rob "repo.path=$PWD/repos/rob/.git" && cgit_rc nourlrc "url=rob/" >tmp 2>err && - grep "^Status: 200" tmp && + expect_status 200 tmp && grep "Ignoring repository with an empty url" err && for query in url= r= do cgit_rc nourlrc "$query" >tmp 2>err && - test_grep "^Status: 200" tmp && + expect_status 200 tmp && test_grep ">rob</a>" tmp && test_grep ! nourl tmp || return 1 done ' test_expect_success 'a scan path that is itself a repository is named after it' ' - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "remove-suffix=1" && - echo "scan-path=$PWD/repos/rob" - } >rootrc && + cgitrc_site rootrc remove-suffix=1 "scan-path=$PWD/repos/rob" && cgit_rc rootrc "url=" >tmp && grep "toplevel-repo.><a href=./rob/.>rob</a>" tmp ' test_expect_success 'a repo key after scan-path is reported instead of applied' ' - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=first" && - echo "repo.path=$PWD/repos/rob/.git" && - echo "scan-path=$PWD/repos" && - echo "repo.desc=misplaced" - } >stalerc && + cgitrc_site stalerc repo.url=first "repo.path=$PWD/repos/rob/.git" "scan-path=$PWD/repos" repo.desc=misplaced && cgit_rc stalerc "url=" >tmp 2>err && ! grep "misplaced" tmp && grep "Ignoring repo.desc before any repo.url" err @@ -98,12 +88,7 @@ test_expect_success 'a repo key after scan-path is reported instead of applied' test_expect_success 'a valueless or broken git config in a scanned repository is skipped' ' git clone -q --bare repos/rob/.git scan/a.git && printf "[cgit]\n\thide\n[cgit\n" >>scan/a.git/config && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "enable-git-config=1" && - echo "scan-path=$PWD/scan" - } >gitcfgrc && + cgitrc_site gitcfgrc enable-git-config=1 "scan-path=$PWD/scan" && cgit_rc gitcfgrc "url=" >tmp 2>err && grep "toplevel-repo.><a href=./a.git/.>" tmp && grep "Ignoring unreadable config in $PWD/scan/a.git/config" err @@ -134,22 +119,15 @@ test_expect_success 'set up a scanned repository setting every key that waits on module-link=https://evil.example/module/%s module-link.sub=https://evil.example/path/%s EOF - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "scan-path=$PWD/scankeys" - } >scankeysrc && - { - echo "trust-scan-config=1" && - cat scankeysrc - } >scankeystrustrc + cgitrc_site scankeysrc "scan-path=$PWD/scankeys" && + cgitrc_site scankeystrustrc trust-scan-config=1 "scan-path=$PWD/scankeys" ' test_expect_success 'only descriptive keys are taken from a scanned repository' ' for page in about/ "" tree/ do cgit_rc scankeysrc "url=k/$page" >tmp 2>err && - test_grep "^Status: 200" tmp && + expect_status 200 tmp && test_grep "<p class=.sub desc.>from the repo</p>" tmp && test_grep ! "evil" tmp && test_grep ! "alert(" tmp || return 1 @@ -181,23 +159,16 @@ test_expect_success 'a filesystem readme from a scanned repository is refused' ' git clone -q --bare repos/rob/.git readmescan/b.git && echo "outside the repository" >outside && echo "outside the repository" >"readmescan/outside:" && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "scan-path=$PWD/readmescan" - } >readmescanrc && - { - echo "trust-scan-config=1" && - cat readmescanrc - } >readmescantrustrc && + cgitrc_site readmescanrc "scan-path=$PWD/readmescan" && + cgitrc_site readmescantrustrc trust-scan-config=1 "scan-path=$PWD/readmescan" && for readme in "$PWD/outside" ../outside: do echo "readme=$readme" >readmescan/b.git/cgitrc && cgit_rc readmescanrc "url=b.git/about/" >tmp 2>err && - test_grep "^Status: 302" tmp && + expect_status 302 tmp && test_grep "Ignoring readme in $PWD/readmescan/b.git/: trust-scan-config is not set" err && cgit_rc readmescantrustrc "url=b.git/about/" >tmp && - test_grep "^Status: 200" tmp && + expect_status 200 tmp && test_grep "outside the repository" tmp || return 1 done ' @@ -206,12 +177,7 @@ test_expect_success 'a filesystem readme from a scanned repository is refused' ' # scan-path line, so a readme set after the scan still applies. test_expect_success 'a readme set after scan-path reaches a scanned repository' ' git clone -q --bare repos/rob/.git laterscan/b.git && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "scan-path=$PWD/laterscan" && - echo "readme=master:file-1" - } >laterrc && + cgitrc_site laterrc "scan-path=$PWD/laterscan" readme=master:file-1 && cgit_rc laterrc "url=b.git/about/" >tmp && grep "<pre class=.plaintext.>1$" tmp ' @@ -225,13 +191,7 @@ test_expect_success 'html serving from a scanned repository waits on trust' ' mkdir -p scan2 && git clone -q --bare repos/html/.git scan2/c.git && git -C scan2/c.git config cgit.enable-html-serving 1 && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "enable-git-config=1" && - echo "mimetype.html=text/html" && - echo "scan-path=$PWD/scan2" - } >htmlrc && + cgitrc_site htmlrc enable-git-config=1 mimetype.html=text/html "scan-path=$PWD/scan2" && cgit_rc htmlrc "url=c.git/plain/page.html" >tmp 2>err && grep "^Content-Type: text/plain" tmp && grep "^X-Content-Type-Options: nosniff" tmp && @@ -240,10 +200,8 @@ test_expect_success 'html serving from a scanned repository waits on trust' ' # The repository and config are the ones the test above set up. test_expect_success 'with trust-scan-config the same repository serves html' ' - { - echo "trust-scan-config=1" && - cat htmlrc - } >htmltrustrc && + cgitrc_site htmltrustrc trust-scan-config=1 enable-git-config=1 \ + mimetype.html=text/html "scan-path=$PWD/scan2" && cgit_rc htmltrustrc "url=c.git/plain/page.html" >tmp && grep "^Content-Type: text/html" tmp && ! grep "^X-Content-Type-Options" tmp @@ -253,11 +211,7 @@ test_expect_success SYMLINKS 'a symlink cycle under the scan path is entered onc mkdir loopscan && git clone -q --bare repos/rob/.git loopscan/r.git && ln -s . loopscan/loop && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "scan-path=$PWD/loopscan" - } >looprc && + cgitrc_site looprc "scan-path=$PWD/loopscan" && cgit_ok looprc "url=" >tmp && test_grep "<td class=.col-name toplevel-repo.><a href=./r.git/.>r.git</a>" tmp && test $(grep -c "<tr class=.repo.>" tmp) = 1 @@ -271,12 +225,9 @@ test_expect_success 'a bare query parameter does not swallow the next one' ' # Whether cgit first sees the filter's exit status or its closed pipe # depends on which side runs first, so either message will do. test_expect_success 'a filter that cannot run answers one error page' ' - { - echo "commit-filter=exec:$PWD/no/such/filter" && - cat robrc - } >badfilterrc && + cgitrc_repo badfilterrc rob "commit-filter=exec:$PWD/no/such/filter" && cgit_rc badfilterrc "url=rob/commit/" >tmp 2>err && - test $(grep -c "^Status:" tmp) = 1 && + expect_status 200 tmp && grep "Unable to complete the request" tmp && grep -e "Unable to run filter $PWD/no/such/filter" -e "Unable to write the page" err && grep "Unable to exec filter" err @@ -288,12 +239,10 @@ test_expect_success 'a filter that cannot run answers one error page' ' # the write has to block and then fail however the two sides are scheduled. test_expect_success 'a filter that exits without reading does not end cgit' ' mkrepo repos/quit 1 && - test_seq 20000 >repos/quit/big.txt && - git -C repos/quit add big.txt && - git -C repos/quit commit -q -m big && + test_commit -C repos/quit --no-tag big big.txt "$(test_seq 20000)" && cgitrc_repo quitrc quit source-filter=exec:true && cgit_rc quitrc "url=quit/tree/big.txt" >tmp 2>err && - test $(grep -c "^Status:" tmp) = 1 && + expect_status 200 tmp && test_grep "<div class=.blob-header.>blob: " tmp ' @@ -323,20 +272,19 @@ test_expect_success 'a path below the about page answers 404' ' for path in sub sub/ missing.png file-1 ../aboutrc do cgit_rc aboutrc "url=about/about/$path" >tmp 2>err && - grep "^Status: 404" tmp && + expect_status 404 tmp && grep "^Content-Type: text/html" tmp && ! grep fatal err || return 1 done && cgit_rc aboutrc "p=about&path=x" >tmp && - grep "^Status: 404" tmp + expect_status 404 tmp ' test_expect_success 'a path opening with a colon is refused on the log and patch pages' ' cgit_rc robrc "url=rob/log/:%25x" >tmp && - grep "^Status: 400" tmp && + expect_status 400 tmp && cgit_rc robrc "url=rob/patch/:%25x" >tmp && - grep "^Status: 400" tmp && - test $(grep -c "^Status:" tmp) = 1 + expect_status 400 tmp ' test_expect_success 'a revision spelled like an option is refused' ' @@ -344,11 +292,11 @@ test_expect_success 'a revision spelled like an option is refused' ' git -C repos/optref update-ref refs/heads/--stdin HEAD && cgitrc_repo optrefrc optref && cgit_rc optrefrc "url=optref/log/&h=--stdin" >tmp && - grep "^Status: 404" tmp && + expect_status 404 tmp && cgit_rc optrefrc "url=optref/blame/file-1&id=--stdin" >tmp && - grep "^Status: 400" tmp && + expect_status 400 tmp && cgit_rc optrefrc "url=optref/atom/&h=--stdin" >tmp && - grep "^Status: 404" tmp + expect_status 404 tmp ' # Three tests read through the annotated tag set up here. @@ -379,20 +327,20 @@ test_expect_success 'the blob page walks a path out of the commit or tag the id strip_headers <tmp >body && test_cmp want body && cgit_rc taggedrc "url=tagged/blob/missing&id=$tip" >tmp && - grep "^Status: 404" tmp + expect_status 404 tmp ' test_expect_success 'a revision expression that walks the history is refused' ' cgit_rc robrc "url=rob/log/&h=:/zzzz" >tmp && - grep "^Status: 404" tmp && + expect_status 404 tmp && cgit_rc robrc "url=rob/commit/&id=HEAD^{/zzzz}" >tmp && - grep "^Status: 400" tmp && + expect_status 400 tmp && cgit_rc robrc "url=rob/log/&qt=range&q=:/zzzz" >tmp && - grep "^Status: 400" tmp && + expect_status 400 tmp && cgit_rc robrc "url=rob/log/&qt=range&q=master~1..master" >tmp && - grep "^Status: 400" tmp && + expect_status 400 tmp && cgit_rc robrc "url=rob/log/&qt=range&q=$sha..master" >tmp && - grep "^Status: 200" tmp + expect_status 200 tmp ' # git update-ref refuses a ref to an object it cannot parse, so the ref is @@ -405,7 +353,7 @@ test_expect_success REFFILES 'a commit with a broken tree line does not crash th echo $bad >broken/.git/refs/heads/bad && cgitrc_repo brokenrc broken "repo.path=$PWD/broken/.git" repo.readme=:file-1 && cgit_rc brokenrc "url=broken/blob/&h=bad&path=file-1" >tmp && - test_grep "^Status: 404" tmp + expect_status 404 tmp ' test_expect_success 'a die inside git answers one 500 page and logs the reason' ' @@ -413,8 +361,7 @@ test_expect_success 'a die inside git answers one 500 page and logs the reason' printf "[core\n" >>badconfig/.git/config && cgitrc_repo badconfigrc badconfig "repo.path=$PWD/badconfig/.git" && cgit_rc badconfigrc "url=badconfig/log/" >tmp 2>err && - test_grep "^Status: 500" tmp && - test $(grep -c "^Status:" tmp) = 1 && + expect_status 500 tmp && test_grep "bad config line" err && test_grep ! "bad config line" tmp ' @@ -432,12 +379,11 @@ test_expect_success 'a history with a missing parent answers one error' ' rm "gap/.git/objects/$(test_oid_to_path $parent)" && cgitrc_repo gaprc gap "repo.path=$PWD/gap/.git" && cgit_rc gaprc "url=gap/log/" >tmp 2>err && - test $(grep -c "^Status:" tmp) = 1 && + expect_status 200 tmp && test_grep "<div class=.error.>Unable to complete the request</div>" tmp && test_grep "Failed to traverse parents of commit $tip" err && cgit_rc gaprc "url=gap/patch/&id2=$older" >tmp && - test $(grep -c "^Status:" tmp) = 1 && - test_grep "^Status: 500" tmp + expect_status 500 tmp ' # The commit page collects each file's diff body before printing it, so a @@ -460,7 +406,7 @@ test_expect_success 'a corrupt blob in a collected diff answers the error' ' ) && cgitrc_repo corruptrc corrupt "repo.path=$PWD/corrupt/.git" && cgit_rc corruptrc "url=corrupt/commit/" >tmp 2>err && - test $(grep -c "^Status:" tmp) = 1 && + expect_status 200 tmp && test_grep "<div class=.error.>Unable to complete the request</div>" tmp && test_grep "is corrupt" err ' @@ -537,16 +483,12 @@ test_expect_success GZIP 'a snapshot of a tag spelled like an option is archived test -n "$CGIT_VALGRIND" || test_set_prereq NO_VALGRIND test_expect_success NO_VALGRIND 'a snapshot format whose compressor is missing answers 500' ' - { - echo "snapshots=tar.xz" && - grep -v "^snapshots" robrc - } >xzrc && + cgitrc_repo xzrc rob snapshots=tar.xz && cgitbin=$(command -v cgit) && mkdir -p nobin && PATH="$PWD/nobin" CGIT_CONFIG="$PWD/xzrc" \ QUERY_STRING="url=rob/snapshot/rob-master.tar.xz" "$cgitbin" >tmp && - grep "^Status: 500" tmp && - test $(grep -c "^Status:" tmp) = 1 + expect_status 500 tmp ' test_expect_success 'a disk readme in the repository directory serves no sibling' ' @@ -556,7 +498,7 @@ test_expect_success 'a disk readme in the repository directory serves no sibling cgit_rc diskrc "url=disk/about/" >tmp && grep "hello" tmp && cgit_rc diskrc "url=disk/about/config" >tmp && - grep "^Status: 404" tmp && + expect_status 404 tmp && ! grep "repositoryformatversion" tmp ' @@ -574,10 +516,10 @@ test_expect_success 'the dumb transport serves an empty repository' ' git init -q --bare empty.git && cgitrc_repo emptyrc empty "repo.path=$PWD/empty.git" && cgit_rc emptyrc "url=empty/info/refs" >tmp && - grep "^Status: 200" tmp && + expect_status 200 tmp && grep "^Content-Type: text/plain" tmp && cgit_rc emptyrc "url=empty/objects/info" >tmp && - grep "^Status: 404" tmp + expect_status 404 tmp ' # A pack is handed over as it sits on the disk, so the client can be told @@ -590,7 +532,7 @@ test_expect_success 'the dumb transport sends a file with its size' ' pack=$(strip_headers <tmp | sed -n "s/^P //p" | head -n 1) && test -n "$pack" && cgit_rc packedrc "url=packed/objects/pack/$pack" >tmp && - grep "^Status: 200" tmp && + expect_status 200 tmp && size=$(wc -c <repos/packed/.git/objects/pack/$pack | tr -d " ") && grep "^Content-Length: $size$" tmp && strip_headers <tmp >body && @@ -601,7 +543,7 @@ test_expect_success 'the dumb transport sends a file with its size' ' # branch a client is to check out has to come from the refs instead. test_expect_success 'the dumb transport answers HEAD from the refs' ' cgit_rc robrc "url=rob/HEAD" >tmp && - grep "^Status: 200" tmp && + expect_status 200 tmp && strip_headers <tmp >head && echo "ref: refs/heads/master" >expect && test_cmp expect head && @@ -633,12 +575,8 @@ test_expect_success 'a reftable repository shows its age on the index' ' # has to outgrow the pipe for the write after the reader has gone to fail. test_expect_success 'a client that disconnects ends the request quietly' ' mkrepo repos/long 1 && - ( - cd repos/long && - awk "BEGIN{for(i=0;i<20000;i++) print \"line \" i}" >long.txt && - git add long.txt && - git commit -m long - ) && + test_commit -C repos/long --no-tag long long.txt \ + "$(awk "BEGIN{for(i=0;i<20000;i++) print \"line \" i}")" && cgitrc_repo longrc long && { cgit_rc longrc "url=long/tree/long.txt" 2>err; echo $? >status; } | test_copy_bytes 1 >/dev/null && test "$(cat status)" = 0 && @@ -653,12 +591,9 @@ test_expect_success 'pages behind an auth filter are marked private' ' write_script letin.sh <<-\EOF && exit 1 EOF - { - echo "auth-filter=exec:$PWD/letin.sh" && - cat robrc - } >letinrc && + cgitrc_repo letinrc rob "auth-filter=exec:$PWD/letin.sh" && cgit_rc letinrc "url=rob/log/" >tmp && - grep "^Status: 200" tmp && + expect_status 200 tmp && grep "^Cache-Control: private$" tmp && grep "^Vary: Cookie$" tmp && cgit_ok robrc "url=rob/log/" >tmp && @@ -673,11 +608,11 @@ test_expect_success 'the about redirect keeps the query string' ' git -C repos/redirect branch other HEAD && cgitrc_repo redirectrc redirect && cgit_rc redirectrc "url=redirect/about&h=other&x=1" >tmp && - grep "^Status: 302" tmp && + expect_status 302 tmp && grep "^Location: /redirect/?h=other&x=1$" tmp && cgitrc_repo redirectreadmerc redirect repo.readme=master:file-1 && cgit_rc redirectreadmerc "url=redirect/about&h=other" >tmp && - grep "^Status: 200" tmp + expect_status 200 tmp ' # A readme named without a branch is read from the head being browsed, and an @@ -687,14 +622,14 @@ test_expect_success 'the readme follows an annotated tag as the head' ' git -C repos/tagreadme tag -a -m release v1 HEAD && cgitrc_repo tagreadmerc tagreadme repo.readme=:file-1 && cgit_rc tagreadmerc "url=tagreadme/about/&h=v1" >tmp && - grep "^Status: 200" tmp && + expect_status 200 tmp && cgit_rc tagreadmerc "url=tagreadme/tree/&h=v1" >tmp && grep ">about<" tmp ' test_expect_success 'the about redirect encodes the repository url once' ' cgit_url "foo%2Bbar/about/" >tmp && - grep "^Status: 302" tmp && + expect_status 302 tmp && grep "^Location: /foo%2Bbar/$" tmp ' @@ -719,12 +654,7 @@ test_expect_success 'a symlink whose target is a large blob is listed without it # same error text is expected from either path. test_expect_success 'an unreadable project list is named with its error' ' mkdir -p projdir && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "project-list=$PWD/projdir" && - echo "scan-path=$PWD/repos" - } >projrc && + cgitrc_site projrc "project-list=$PWD/projdir" "scan-path=$PWD/repos" && cgit_rc projrc "url=" >tmp 2>err && grep "project list .*projdir: Is a directory" err ' @@ -733,11 +663,7 @@ test_expect_success SANITY 'a scan entry that cannot be searched is named in ful mkdir -p scanperm/locked && test_when_finished "chmod 755 scanperm/locked" && chmod 644 scanperm/locked && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "scan-path=$PWD/scanperm" - } >scanpermrc && + cgitrc_site scanpermrc "scan-path=$PWD/scanperm" && cgit_rc scanpermrc "url=" >tmp 2>err && grep "Unable to stat .*scanperm/locked/objects: Permission denied" err ' @@ -746,9 +672,7 @@ test_expect_success SANITY 'a scan entry that cannot be searched is named in ful # has nothing to show. test_expect_success 'a readme past max-blob-size is reported on the about page' ' mkrepo repos/bigreadme 1 && - test_seq 1 1000 >repos/bigreadme/big-readme && - git -C repos/bigreadme add big-readme && - git -C repos/bigreadme commit -q -m "big readme" && + test_commit -C repos/bigreadme --no-tag "big readme" big-readme "$(test_seq 1 1000)" && cgitrc_repo bigreadmerc bigreadme max-blob-size=1 repo.readme=:big-readme && cgit_rc bigreadmerc "url=bigreadme/about/" >tmp && grep "The readme is larger than max-blob-size (1 KB)" tmp @@ -761,7 +685,7 @@ test_expect_success 'the error page does not resolve the id it refused' ' cgit_rc robrc "url=rob/log/&id=$sha" >tmp && grep "<title>.* @ " tmp && cgit_rc robrc "url=rob/log/&id=%3A/commit" >tmp && - test_grep "^Status: 400" tmp && + expect_status 400 tmp && test_grep "<title>Bad Request - rob - " tmp && test_grep ! "<title>.* @ " tmp ' @@ -780,7 +704,7 @@ test_expect_success 'a notes ref that names no tree is passed over' ' cgit_ok notesrc "$q" >tmp || return 1 done && cgit_rc notesrc "url=notes/snapshot/notes-base.tar.asc" >tmp 2>err && - test_grep "^Status: 404" tmp && + expect_status 404 tmp && test_grep "<div class=.error.>No signature for notes-base.tar</div>" tmp && test_grep ! "notes tree" err ' @@ -794,11 +718,7 @@ test_expect_success REFFILES 'a scanned defbranch cannot name a path outside the mkdir -p secret && touch -t 200001010000 secret/file && echo "defbranch=../../../../secret/file" >defscan/b.git/cgitrc && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "scan-path=$PWD/defscan" - } >defscanrc && + cgitrc_site defscanrc "scan-path=$PWD/defscan" && cgit_rc defscanrc "url=" >tmp && grep ">b.git</a>" tmp && ! grep "data-ut=.946" tmp @@ -811,13 +731,9 @@ test_expect_success REFFILES 'a crafted HEAD cannot date a repository from outsi touch -t 200001010000 aimed/file && git init -q --bare headscan/h.git && echo "ref: refs/heads/../../../../aimed/file" >headscan/h.git/HEAD && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "scan-path=$PWD/headscan" - } >headrc && + cgitrc_site headrc "scan-path=$PWD/headscan" && cgit_rc headrc "url=" >tmp && - test_grep "^Status: 200" tmp && + expect_status 200 tmp && test_grep ">h.git</a>" tmp && test_grep ! "data-ut=.946" tmp ' @@ -826,12 +742,7 @@ test_expect_success REFFILES 'a crafted HEAD cannot date a repository from outsi # its own page, and a request that names one anyway is told why. test_expect_success 'blame turns away a binary file' ' mkrepo repos/binblame 1 && - ( - cd repos/binblame && - printf "a\000b\n" >bin.dat && - git add bin.dat && - git commit -q -m binary - ) && + test_commit -C repos/binblame --no-tag --printf binary bin.dat "a\000b\n" && cgitrc_repo binblamerc binblame repo.enable-blame=1 && cgit_ok binblamerc "url=binblame/blame/bin.dat" >tmp && test_grep "<div class=.error.>Blob is binary</div>" tmp && @@ -853,12 +764,7 @@ test_expect_success 'descriptive values from a scanned repository are escaped' ' owner=owner <x> & "q" '\''s section=section <x> & "q" '\''s EOF - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "enable-index-owner=1" && - echo "scan-path=$PWD/descscan" - } >descrc && + cgitrc_site descrc enable-index-owner=1 "scan-path=$PWD/descscan" && cgit_ok descrc "url=" >tmp && test_grep "<a href=./d.git/.>desc <x> & \"q\" .s</a>" tmp && test_grep "<a href=./?q=owner+%3Cx%3E+%26+%22q%22+%27s.>owner <x> & \"q\" .s</a>" tmp && |
