Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce 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 '')
-rwxr-xr-xtests/t0201-filters.sh31
-rwxr-xr-xtests/t0202-submodule-links.sh4
-rwxr-xr-xtests/t0203-dates.sh26
-rwxr-xr-xtests/t0204-limits.sh54
-rwxr-xr-xtests/t0205-config.sh23
-rwxr-xr-xtests/t0206-trailers.sh2
-rwxr-xr-xtests/t0208-mailmap.sh2
-rwxr-xr-xtests/t0301-security.sh135
-rwxr-xr-xtests/t0303-robustness.sh219
-rwxr-xr-xtests/t0505-auth.sh2
-rwxr-xr-xtests/t0507-hooks.sh4
11 files changed, 182 insertions, 320 deletions
diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh
index 2e59a1d..8d8743a 100755
--- a/tests/t0201-filters.sh
+++ b/tests/t0201-filters.sh
@@ -57,9 +57,8 @@ do
done
test_expect_success 'the blame page goes through the source filter too' '
- echo "enable-blame=1" >blamerc &&
- sed "s/^cache-size=.*/cache-size=0/" cgitrc >>blamerc &&
- CGIT_CONFIG="$PWD/blamerc" QUERY_STRING="url=filter-exec/blame/a%2bb" cgit >tmp &&
+ cgitrc_copy blamerc enable-blame=1 &&
+ cgit_rc blamerc "url=filter-exec/blame/a%2bb" >tmp &&
grep "<td class=.linenumbers.>" tmp &&
grep "<code>a+b HELLO$" tmp
'
@@ -67,22 +66,14 @@ test_expect_success 'the blame page goes through the source filter too' '
# A readme read at another branch links into the tree at that branch, which
# the filter is told as the query to follow a path with.
test_expect_success 'the about filter gets the tree url at the readme branch' '
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "readme=:a+b" &&
- echo "about-filter=exec:$FILTER_DIRECTORY/dump.sh" &&
- echo "root-readme=$PWD/root.txt" &&
- echo "repo.url=filtered" &&
- echo "repo.path=$PWD/repos/filter/.git"
- } >aboutargsrc &&
- CGIT_CONFIG="$PWD/aboutargsrc" QUERY_STRING="url=filtered/about/&h=1%2b2" cgit >tmp &&
+ cgitrc_repo aboutargsrc filtered readme=:a+b "about-filter=exec:$FILTER_DIRECTORY/dump.sh" "root-readme=$PWD/root.txt" "repo.path=$PWD/repos/filter/.git" &&
+ cgit_rc aboutargsrc "url=filtered/about/&h=1%2b2" >tmp &&
grep "<div id=.about.>a+b /filtered/tree/ ?h=1%2B2 HELLO" tmp
'
test_expect_success 'the site readme leaves the tree url empty' '
echo site >root.txt &&
- CGIT_CONFIG="$PWD/aboutargsrc" QUERY_STRING="p=about" cgit >tmp &&
+ cgit_rc aboutargsrc "p=about" >tmp &&
grep "root.txt SITE" tmp
'
@@ -92,9 +83,9 @@ test_expect_success 'only a repository page hands filters its variables' '
echo "repo url: $CGIT_REPO_URL."
EOF
sed "s|^about-filter=.*|about-filter=exec:$PWD/env.sh|" aboutargsrc >envrc &&
- CGIT_CONFIG="$PWD/envrc" QUERY_STRING="url=filtered/about/" cgit >tmp &&
+ cgit_rc envrc "url=filtered/about/" >tmp &&
grep "repo url: filtered\." tmp &&
- CGIT_CONFIG="$PWD/envrc" QUERY_STRING="p=about" cgit >tmp &&
+ cgit_rc envrc "p=about" >tmp &&
grep "repo url: \." tmp
'
@@ -113,7 +104,7 @@ test_expect_success CGIT_LUA 'a failing lua filter still renders an error page'
echo "repo.path=$PWD/repos/foo/.git" &&
echo "auth-filter=lua:$PWD/broken.lua"
} >brokenrc &&
- CGIT_CONFIG="$PWD/brokenrc" QUERY_STRING="url=foo/commit" cgit >tmp 2>err &&
+ cgit_rc brokenrc "url=foo/commit" >tmp 2>err &&
grep "Status: 500" tmp &&
grep "Lua error in" err
'
@@ -126,7 +117,7 @@ test_expect_success CGIT_LUA 'a lua filter raising a table is named by type' '
function filter_close() return 0 end
EOF
sed "s|broken.lua|tabled.lua|" brokenrc >tabledrc &&
- CGIT_CONFIG="$PWD/tabledrc" QUERY_STRING="url=foo/commit" cgit >tmp 2>err &&
+ cgit_rc tabledrc "url=foo/commit" >tmp 2>err &&
grep "Status: 500" tmp &&
grep "Lua error in .*tabled.lua: (error object is a table value)" err
'
@@ -146,7 +137,7 @@ test_expect_success CGIT_LUA 'a lua filter that writes while loading still rende
echo "repo.path=$PWD/repos/foo/.git" &&
echo "repo.commit-filter=lua:$PWD/loud.lua"
} >loudrc &&
- CGIT_CONFIG="$PWD/loudrc" QUERY_STRING="url=foo/commit" cgit >tmp &&
+ cgit_rc loudrc "url=foo/commit" >tmp &&
grep "written while loading" tmp &&
grep "</html>" tmp
'
@@ -173,7 +164,7 @@ test_expect_success CGIT_LUA 'a lua filter can encode an argument and include a
function filter_close() return 0 end
EOF
sed "s|loud.lua|apis.lua|" loudrc >apisrc &&
- CGIT_CONFIG="$PWD/apisrc" QUERY_STRING="url=foo/commit" cgit >tmp &&
+ cgit_rc apisrc "url=foo/commit" >tmp &&
grep "a+b%26c|included <b>bold</b>" tmp
'
diff --git a/tests/t0202-submodule-links.sh b/tests/t0202-submodule-links.sh
index 2cbbba7..a5810a0 100755
--- a/tests/t0202-submodule-links.sh
+++ b/tests/t0202-submodule-links.sh
@@ -55,7 +55,7 @@ test_expect_success 'set up a parent repo with submodules' '
'
test_expect_success 'generate subparent/tree' '
- CGIT_CONFIG="$PWD/subrc" QUERY_STRING="url=subparent/tree/" cgit >tmp
+ cgit_rc subrc "url=subparent/tree/" >tmp
'
test_expect_success 'an ssh url served here links to the local repo' '
@@ -93,7 +93,7 @@ test_expect_success 'an unresolvable url stays unlinked with a tooltip' '
test_expect_success 'the links stay off without the flag' '
sed "/enable-gitmodules-links/d" subrc >subrcoff &&
- CGIT_CONFIG="$PWD/subrcoff" QUERY_STRING="url=subparent/tree/" cgit >tmp &&
+ cgit_rc subrcoff "url=subparent/tree/" >tmp &&
! grep "subtarget/tree" tmp &&
grep "class=.ls-mod.>local-ssh</span>" tmp
'
diff --git a/tests/t0203-dates.sh b/tests/t0203-dates.sh
index 60a4e5a..5c3567f 100755
--- a/tests/t0203-dates.sh
+++ b/tests/t0203-dates.sh
@@ -34,66 +34,64 @@ daterc() {
} >daterc
}
-dateq() { CGIT_CONFIG="$PWD/daterc" QUERY_STRING="$1" cgit; }
-
test_expect_success 'relative dates are on by default' '
daterc &&
- dateq "url=dated/refs/" >tmp &&
+ cgit_rc daterc "url=dated/refs/" >tmp &&
grep "class=.age-" tmp
'
test_expect_success 'enable-relative-dates=0 shows a calendar date' '
daterc "enable-relative-dates=0" &&
- dateq "url=dated/refs/" >tmp &&
+ cgit_rc daterc "url=dated/refs/" >tmp &&
! grep "class=.age-" tmp &&
grep "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]<" tmp
'
test_expect_success 'the index and log columns follow the same flag' '
daterc "enable-relative-dates=0" &&
- dateq "" >tmp &&
+ cgit_rc daterc "" >tmp &&
! grep "class=.age-" tmp &&
- dateq "url=dated/log/" >tmp &&
+ cgit_rc daterc "url=dated/log/" >tmp &&
! grep "class=.age-" tmp
'
test_expect_success 'date-format selects the calendar format' '
daterc "enable-relative-dates=0" "date-format=iso8601" &&
- dateq "url=dated/refs/" >tmp &&
+ cgit_rc daterc "url=dated/refs/" >tmp &&
grep ">[0-9-]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] +0000<" tmp
'
test_expect_success 'date-format accepts a strftime format' '
daterc "enable-relative-dates=0" "date-format=format:%Y/%m/%d" &&
- dateq "url=dated/refs/" >tmp &&
+ cgit_rc daterc "url=dated/refs/" >tmp &&
grep ">[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]<" tmp
'
test_expect_success 'an unknown date-format falls back to short' '
daterc "enable-relative-dates=0" "date-format=nonsense" &&
- dateq "url=dated/refs/" >tmp &&
+ cgit_rc daterc "url=dated/refs/" >tmp &&
grep "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]<" tmp &&
daterc "enable-relative-dates=0" "date-format=format:" &&
- dateq "url=dated/refs/" >tmp &&
+ cgit_rc daterc "url=dated/refs/" >tmp &&
grep "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]<" tmp
'
test_expect_success 'a date-format git would refuse falls back to short' '
daterc "enable-relative-dates=0" "date-format=local-local" &&
- dateq "url=dated/refs/" >tmp &&
+ cgit_rc daterc "url=dated/refs/" >tmp &&
grep "^Status: 200" tmp &&
grep "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]<" tmp
'
test_expect_success 'date-format=local is the default format in local time' '
daterc "enable-relative-dates=0" "date-format=local" &&
- dateq "url=dated/refs/" >tmp &&
+ cgit_rc daterc "url=dated/refs/" >tmp &&
grep ">[A-Z][a-z][a-z] [A-Z][a-z][a-z] [0-9]* [0-9:]* [0-9]*<" tmp
'
test_expect_success 'date-format still formats the log fallback' '
daterc "date-format=rfc2822" &&
- dateq "url=dated/log/" >tmp &&
+ cgit_rc daterc "url=dated/log/" >tmp &&
grep "class=.age-" tmp &&
grep ">[A-Z][a-z][a-z], [0-9]* Apr 2005 " tmp
'
@@ -101,7 +99,7 @@ test_expect_success 'date-format still formats the log fallback' '
test_expect_success 'date-format leaves the commit page on ISO 8601' '
daterc "date-format=rfc2822" &&
sha=$(git -C repos/dated rev-parse HEAD~1) &&
- dateq "url=dated/commit/&id=$sha" >tmp &&
+ cgit_rc daterc "url=dated/commit/&id=$sha" >tmp &&
grep "2005-04-07 [0-9:]* +0000" tmp &&
! grep "Apr 2005" tmp
'
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
diff --git a/tests/t0205-config.sh b/tests/t0205-config.sh
index dbc73e9..f13b2ec 100755
--- a/tests/t0205-config.sh
+++ b/tests/t0205-config.sh
@@ -6,14 +6,7 @@ test_description='Check configuration diagnostics'
. ./setup.sh
test_expect_success 'set up configs' '
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "no-such-key=1" &&
- echo "repo.url=diag" &&
- echo "repo.path=$PWD/repos/foo/.git" &&
- echo "repo.no-such-repo-key=1"
- } >diagrc &&
+ cgitrc_repo diagrc diag no-such-key=1 "repo.path=$PWD/repos/foo/.git" repo.no-such-repo-key=1 &&
{
echo "virtual-root=/" &&
echo "cache-size=0" &&
@@ -26,14 +19,14 @@ test_expect_success 'set up configs' '
'
test_expect_success 'unknown keys are reported and the page still renders' '
- CGIT_CONFIG="$PWD/diagrc" QUERY_STRING="url=diag/" cgit >tmp 2>err &&
+ cgit_rc diagrc "url=diag/" >tmp 2>err &&
grep "Status: 200" tmp &&
grep "Unknown config key: no-such-key" err &&
grep "Unknown repo config key: no-such-repo-key" err
'
test_expect_success 'a repo key before any repo.url is reported' '
- CGIT_CONFIG="$PWD/earlyrc" QUERY_STRING="url=diag/" cgit >tmp 2>err &&
+ cgit_rc earlyrc "url=diag/" >tmp 2>err &&
grep "Status: 200" tmp &&
grep "Ignoring repo.desc before any repo.url" err
'
@@ -46,7 +39,7 @@ test_expect_success 'a filter in a scanned repository is reported without its fl
echo "cache-size=0" &&
echo "scan-path=$PWD/scan"
} >scanrc &&
- CGIT_CONFIG="$PWD/scanrc" QUERY_STRING="url=foo.git/commit/" cgit >tmp 2>err &&
+ cgit_rc scanrc "url=foo.git/commit/" >tmp 2>err &&
grep "<div class=.commit-subject.>commit 5" tmp &&
grep "Ignoring commit-filter in $PWD/scan/foo.git/: trust-scan-config is not set" err
'
@@ -56,7 +49,7 @@ test_expect_success 'the flag lets a scanned repository set its filters' '
echo "trust-scan-config=1" &&
cat scanrc
} >scanrc-on &&
- CGIT_CONFIG="$PWD/scanrc-on" QUERY_STRING="url=foo.git/commit/" cgit >tmp 2>err &&
+ cgit_rc scanrc-on "url=foo.git/commit/" >tmp 2>err &&
grep "<div class=.commit-subject.>COMMIT 5" tmp &&
! grep "Ignoring" err
'
@@ -64,7 +57,7 @@ test_expect_success 'the flag lets a scanned repository set its filters' '
# The filter prints nothing, so an empty about div shows that it ran in place
# of the readme.
test_expect_success 'a repo filter in the main cgitrc needs no flag' '
- CGIT_CONFIG="$PWD/earlyrc" QUERY_STRING="url=diag/about/" cgit >tmp 2>err &&
+ cgit_rc earlyrc "url=diag/about/" >tmp 2>err &&
grep "<div id=.about.></div>" tmp &&
! grep "about-filter" err
'
@@ -80,7 +73,7 @@ test_expect_success 'a repository whose path is missing answers 404' '
mkdir -p gone-cache &&
for page in "" log/ commit/ "tag/&h=x" atom/ plain/f
do
- CGIT_CONFIG="$PWD/gonerc" QUERY_STRING="url=gone/$page" cgit >tmp 2>err &&
+ cgit_rc gonerc "url=gone/$page" >tmp 2>err &&
grep "^Status: 404 Not Found" tmp &&
grep "Failed to open gone: No such file or directory" tmp || return 1
done &&
@@ -104,7 +97,7 @@ test_expect_success 'a NUL inside a comment does not end it' '
echo "repo.path=$PWD/repos/foo/.git"
} >nulrc &&
grep -c Smuggled nulrc &&
- CGIT_CONFIG="$PWD/nulrc" QUERY_STRING="url=" cgit >tmp &&
+ cgit_rc nulrc "url=" >tmp &&
grep "</html>" tmp &&
! grep Smuggled tmp
'
diff --git a/tests/t0206-trailers.sh b/tests/t0206-trailers.sh
index 61fba94..15c3600 100755
--- a/tests/t0206-trailers.sh
+++ b/tests/t0206-trailers.sh
@@ -87,7 +87,7 @@ test_expect_success 'a message with no block gets no table' '
test_expect_success 'with the flag off the message stays whole' '
sed "s/^enable-commit-trailers=1/enable-commit-trailers=0/" cgitrc >cgitrc-off &&
- CGIT_CONFIG="$PWD/cgitrc-off" QUERY_STRING="url=trailers/commit/" cgit >tmp &&
+ cgit_rc cgitrc-off "url=trailers/commit/" >tmp &&
! grep "commit-trailers" tmp &&
grep "Signed-off-by: A U Thor" tmp
'
diff --git a/tests/t0208-mailmap.sh b/tests/t0208-mailmap.sh
index 86f6d50..ec33cd9 100755
--- a/tests/t0208-mailmap.sh
+++ b/tests/t0208-mailmap.sh
@@ -73,7 +73,7 @@ test_expect_success 'with the flag off the old ident shows' '
echo "enable-mailmap=0" &&
cat cgitrc
} >cgitrc-off &&
- CGIT_CONFIG="$PWD/cgitrc-off" QUERY_STRING="url=mapped/log/" cgit >tmp &&
+ cgit_rc cgitrc-off "url=mapped/log/" >tmp &&
grep "<td class=.col-author.>Old Name</td>" tmp
'
diff --git a/tests/t0301-security.sh b/tests/t0301-security.sh
index 453d521..3fc491f 100755
--- a/tests/t0301-security.sh
+++ b/tests/t0301-security.sh
@@ -23,18 +23,9 @@ test_expect_success 'set up security fixtures' '
git add -A &&
git commit -m fixtures
) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "max-blob-size=1" &&
- echo "enable-tree-group-dirs=1" &&
- echo "repo.url=sec" &&
- echo "repo.path=$PWD/repos/sec/.git"
- } >seccgitrc
+ cgitrc_repo seccgitrc sec max-blob-size=1 enable-tree-group-dirs=1
'
-secq() { CGIT_CONFIG="$PWD/seccgitrc" QUERY_STRING="$1" cgit; }
-
# A revision beginning with a dash reaches git as an option rather than as a
# tip, so a request for id=--output=<path> could create or truncate any file
# the server is able to write.
@@ -54,7 +45,7 @@ test_expect_success 'a valid id= still renders the log' '
'
test_expect_success 'a small blob is still served' '
- secq "url=sec/plain/afile" >tmp &&
+ cgit_rc seccgitrc "url=sec/plain/afile" >tmp &&
grep -F top tmp
'
@@ -72,14 +63,14 @@ test_expect_success 'markdown readme without a filter is escaped as plain text'
echo "repo.path=$PWD/repos/sec/.git" &&
echo "repo.readme=master:readme.txt"
} >secreadmerc &&
- CGIT_CONFIG="$PWD/secreadmerc" QUERY_STRING="url=md/about/" cgit >tmp &&
+ cgit_rc secreadmerc "url=md/about/" >tmp &&
grep "pre class=.plaintext." tmp &&
grep "&lt;script&gt;" tmp &&
! grep "<script>alert(1)</script>" tmp
'
test_expect_success 'non-markdown readme without a filter is escaped as plain text' '
- CGIT_CONFIG="$PWD/secreadmerc" QUERY_STRING="url=txt/about/" cgit >tmp &&
+ cgit_rc secreadmerc "url=txt/about/" >tmp &&
grep "pre class=.plaintext." tmp &&
grep "&lt;script&gt;" tmp &&
! grep "<script>alert(2)</script>" tmp
@@ -94,10 +85,10 @@ test_expect_success 'root-readme without a filter is its own page, as written' '
echo "cache-size=0" &&
echo "root-readme=$PWD/root.html"
} >secrootrc &&
- CGIT_CONFIG="$PWD/secrootrc" QUERY_STRING="url=" cgit >tmp &&
+ cgit_rc secrootrc "url=" >tmp &&
grep "<li><a title=.About this site. href=./?p=about.>about</a>" tmp &&
! grep "<b>site</b>" tmp &&
- CGIT_CONFIG="$PWD/secrootrc" QUERY_STRING="p=about" cgit >tmp &&
+ cgit_rc secrootrc "p=about" >tmp &&
grep "^<b>site</b>$" tmp
'
@@ -114,7 +105,7 @@ test_expect_success 'diff options submit through a button' '
# Grouping directories ahead of files is behaviour this fork adds, so nothing
# upstream covers it.
test_expect_success 'tree groups directories before files' '
- secq "url=sec/tree/" >tmp &&
+ cgit_rc seccgitrc "url=sec/tree/" >tmp &&
dirline=$(grep -n "tree/zsub" tmp | head -1 | cut -d: -f1) &&
fileline=$(grep -n "tree/afile" tmp | head -1 | cut -d: -f1) &&
test -n "$dirline" &&
@@ -136,14 +127,9 @@ test_expect_success 'ssdiff percent-encodes a quoted file path' '
printf "a\nc\n" >"$name" &&
git commit -am change
) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=xss" &&
- echo "repo.path=$PWD/repos/xss/.git"
- } >xssrc &&
+ cgitrc_repo xssrc xss &&
sha=$(git -C repos/xss rev-parse HEAD) &&
- CGIT_CONFIG="$PWD/xssrc" QUERY_STRING="url=xss/diff/&id=$sha&ss=1" cgit >tmp &&
+ cgit_rc xssrc "url=xss/diff/&id=$sha&ss=1" >tmp &&
grep "tree/x%27y.txt" tmp &&
! grep "href=.[^>]*x.y.txt.[^>]*>" tmp
'
@@ -159,15 +145,10 @@ test_expect_success 'a message-less commit renders without crashing' '
cid=$(git hash-object -t commit -w raw) &&
git update-ref refs/heads/master "$cid"
) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=nomsg" &&
- echo "repo.path=$PWD/repos/nomsg/.git"
- } >nomsgrc &&
- CGIT_CONFIG="$PWD/nomsgrc" QUERY_STRING="url=nomsg/log/&showmsg=1" cgit >tmp &&
+ cgitrc_repo nomsgrc nomsg &&
+ cgit_rc nomsgrc "url=nomsg/log/&showmsg=1" >tmp &&
grep "no commit message" tmp &&
- CGIT_CONFIG="$PWD/nomsgrc" QUERY_STRING="url=nomsg/" cgit >tmp &&
+ cgit_rc nomsgrc "url=nomsg/" >tmp &&
grep "no commit message" tmp
'
@@ -188,19 +169,13 @@ test_expect_success 'set up a repo whose branches point at odd objects' '
grep -q "tree.refs/heads/points-at-tree" refs.out &&
grep -q "tag.refs/heads/points-at-tag" refs.out
) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "branch-sort=age" &&
- echo "repo.url=oddref" &&
- echo "repo.path=$PWD/repos/oddref/.git"
- } >oddrefrc
+ cgitrc_repo oddrefrc oddref branch-sort=age
'
test_expect_success 'the refs, branch and summary pages sort such branches' '
for page in refs/ refs/heads/ ""
do
- CGIT_CONFIG="$PWD/oddrefrc" QUERY_STRING="url=oddref/$page" cgit >tmp &&
+ cgit_rc oddrefrc "url=oddref/$page" >tmp &&
grep "points-at-tree" tmp &&
grep "</html>" tmp || return 1
done
@@ -208,7 +183,7 @@ test_expect_success 'the refs, branch and summary pages sort such branches' '
test_expect_success 'name-sorted branches are unaffected' '
sed "s/^branch-sort=age$/branch-sort=name/" oddrefrc >oddrefnamerc &&
- CGIT_CONFIG="$PWD/oddrefnamerc" QUERY_STRING="url=oddref/refs/heads/" cgit >tmp &&
+ cgit_rc oddrefnamerc "url=oddref/refs/heads/" >tmp &&
grep "points-at-tree" tmp &&
grep "</html>" tmp
'
@@ -239,7 +214,7 @@ test_expect_success 'set up a submodule fixture with a hostile module-link' '
'
test_expect_success 'a surplus conversion does not crash the tree view' '
- CGIT_CONFIG="$PWD/modlinkrc" QUERY_STRING="url=modlink/tree/" cgit >tmp &&
+ cgit_rc modlinkrc "url=modlink/tree/" >tmp &&
grep "ls-mod" tmp
'
@@ -248,38 +223,20 @@ test_expect_success 'a surplus conversion is shown literally, not filled' '
'
test_expect_success 'a well-formed module-link still takes name and sha1' '
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "module-link=/mod/%s/commit/?id=%s" &&
- echo "repo.url=modlink" &&
- echo "repo.path=$PWD/repos/modlink/.git"
- } >modlinkokrc &&
- CGIT_CONFIG="$PWD/modlinkokrc" QUERY_STRING="url=modlink/tree/" cgit >tmp &&
+ cgitrc_repo modlinkokrc modlink "module-link=/mod/%s/commit/?id=%s" &&
+ cgit_rc modlinkokrc "url=modlink/tree/" >tmp &&
grep "href=./mod/submod/commit/?id=$sub." tmp
'
test_expect_success 'a per-path module-link takes only the sha1' '
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=modlink" &&
- echo "repo.path=$PWD/repos/modlink/.git" &&
- echo "repo.module-link.submod=https://example.com/s/?id=%s"
- } >modlinkpathrc &&
- CGIT_CONFIG="$PWD/modlinkpathrc" QUERY_STRING="url=modlink/tree/" cgit >tmp &&
+ cgitrc_repo modlinkpathrc modlink "repo.module-link.submod=https://example.com/s/?id=%s" &&
+ cgit_rc modlinkpathrc "url=modlink/tree/" >tmp &&
grep "href=.https://example.com/s/?id=$sub." tmp
'
test_expect_success 'a doubled percent in a module-link renders as one' '
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "module-link=/m/%s/%%/%s" &&
- echo "repo.url=modlink" &&
- echo "repo.path=$PWD/repos/modlink/.git"
- } >modlinkpctrc &&
- CGIT_CONFIG="$PWD/modlinkpctrc" QUERY_STRING="url=modlink/tree/" cgit >tmp &&
+ cgitrc_repo modlinkpctrc modlink "module-link=/m/%s/%%/%s" &&
+ cgit_rc modlinkpctrc "url=modlink/tree/" >tmp &&
grep "href=./m/submod/%/$sub." tmp
'
@@ -297,7 +254,7 @@ test_expect_success 'a clone endpoint with http clone off answers the same way'
echo "enable-http-clone=0" &&
cat cgitrc
} >noclonerc &&
- CGIT_CONFIG="$PWD/noclonerc" QUERY_STRING="url=foo/info/refs" cgit >tmp &&
+ cgit_rc noclonerc "url=foo/info/refs" >tmp &&
grep "^Status: 404 Not Found" tmp &&
grep "<select name=.h. " tmp
'
@@ -321,17 +278,11 @@ test_expect_success 'set up a hostile .gitmodules' '
git add .gitmodules &&
git commit -m hostile
) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "enable-gitmodules-links=1" &&
- echo "repo.url=modlink" &&
- echo "repo.path=$PWD/repos/modlink/.git"
- } >modlinkgmrc
+ cgitrc_repo modlinkgmrc modlink enable-gitmodules-links=1
'
test_expect_success 'a javascript url never reaches an href' '
- CGIT_CONFIG="$PWD/modlinkgmrc" QUERY_STRING="url=modlink/tree/" cgit >tmp &&
+ cgit_rc modlinkgmrc "url=modlink/tree/" >tmp &&
! grep "href=.javascript:" tmp &&
grep "class=.ls-mod. title=.javascript:alert(1).>submod</span>" tmp
'
@@ -373,21 +324,11 @@ test_expect_success 'set up the advisory fixtures' '
esac
exit 1
EOF
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "auth-filter=exec:$PWD/auth.sh" &&
- echo "repo.url=cve" &&
- echo "repo.path=$PWD/repos/cve/.git" &&
- echo "repo.readme=$PWD/readme/README" &&
- echo "repo.source-filter=exec:$FILTER_DIRECTORY/dump.sh"
- } >cverc
+ cgitrc_repo cverc cve "auth-filter=exec:$PWD/auth.sh" "repo.readme=$PWD/readme/README" "repo.source-filter=exec:$FILTER_DIRECTORY/dump.sh"
'
-cveq() { CGIT_CONFIG="$PWD/cverc" QUERY_STRING="$1" cgit; }
-
test_expect_success 'a newline in a file name cannot split the headers' '
- cveq "url=cve/plain/crlf%0d%0aX-Injected:%201.txt" >tmp &&
+ cgit_rc cverc "url=cve/plain/crlf%0d%0aX-Injected:%201.txt" >tmp &&
grep "^Status: 200" tmp &&
! grep "^X-Injected" tmp &&
grep "^Content-Disposition: inline; filename=.crlf\\\\r\\\\nX-Injected: 1.txt.$" tmp
@@ -401,48 +342,48 @@ test_expect_success 'a posted length past any buffer is clamped' '
'
test_expect_success 'the dumb transport refuses a path that climbs out' '
- cveq "url=cve/objects/../config" >tmp &&
+ cgit_rc cverc "url=cve/objects/../config" >tmp &&
grep "^Status: 404" tmp &&
! grep "repositoryformatversion" tmp &&
- cveq "url=cve/objects/info/../../config" >tmp &&
+ cgit_rc cverc "url=cve/objects/info/../../config" >tmp &&
grep "^Status: 404" tmp &&
! grep "repositoryformatversion" tmp
'
test_expect_success 'the about page serves nothing above the readme directory' '
- cveq "url=cve/about/../cverc" >tmp &&
+ cgit_rc cverc "url=cve/about/../cverc" >tmp &&
grep "^Status: 404" tmp &&
! grep "virtual-root" tmp &&
- cveq "url=cve/about/" >tmp &&
+ cgit_rc cverc "url=cve/about/" >tmp &&
grep "readme text" tmp
'
test_expect_success 'a commit with an empty author renders everywhere' '
- cveq "url=cve/log/&h=noname" >tmp &&
+ cgit_rc cverc "url=cve/log/&h=noname" >tmp &&
grep ">empty author</a>" tmp &&
- cveq "url=cve/commit/&h=noname" >tmp &&
+ cgit_rc cverc "url=cve/commit/&h=noname" >tmp &&
grep "<div class=.commit-subject.>empty author<" tmp &&
- cveq "url=cve/atom/&h=noname" >tmp &&
+ cgit_rc cverc "url=cve/atom/&h=noname" >tmp &&
grep "<name>unknown</name>" tmp &&
! grep "<email></email>" tmp
'
test_expect_success 'a percent sign without digits behind it is read as itself' '
- cveq "url=cve/log/&q=%" >tmp &&
+ cgit_rc cverc "url=cve/log/&q=%" >tmp &&
grep "^Status: 200" tmp &&
- cveq "url=cve/log/&q=%zz%2" >tmp &&
+ cgit_rc cverc "url=cve/log/&q=%zz%2" >tmp &&
grep "^Status: 200" tmp &&
grep "value=.%zz%2." tmp
'
test_expect_success 'script in a file name is escaped on the diff page' '
- cveq "url=cve/diff/" >tmp &&
+ cgit_rc cverc "url=cve/diff/" >tmp &&
! grep "<script>alert" tmp &&
grep "&lt;script&gt;alert(1)x.txt" tmp
'
test_expect_success 'shell syntax in a file name reaches a filter as a plain argument' '
- cveq "url=cve/tree/%24(touch%20pwned).c" >tmp &&
+ cgit_rc cverc "url=cve/tree/%24(touch%20pwned).c" >tmp &&
grep "^Status: 200" tmp &&
grep "pwned).c" tmp &&
! test -e pwned &&
diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh
index 5348b43..f1ae9cd 100755
--- a/tests/t0303-robustness.sh
+++ b/tests/t0303-robustness.sh
@@ -10,17 +10,9 @@ test_description='Check the audit regressions'
test_expect_success 'set up a repository and a config to vary' '
mkrepo repos/rob 3 &&
sha=$(git -C repos/rob rev-parse HEAD~1) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "snapshots=tar.gz" &&
- echo "repo.url=rob" &&
- echo "repo.path=$PWD/repos/rob/.git"
- } >robrc
+ cgitrc_repo robrc rob snapshots=tar.gz
'
-robq() { CGIT_CONFIG="$PWD/robrc" QUERY_STRING="$1" cgit; }
-
test_expect_success 'a repository without a path answers 404' '
{
echo "virtual-root=/" &&
@@ -31,7 +23,7 @@ test_expect_success 'a repository without a path answers 404' '
} >nopathrc &&
for r in nopath emptypath
do
- CGIT_CONFIG="$PWD/nopathrc" QUERY_STRING="url=$r/log/" cgit >tmp &&
+ cgit_rc nopathrc "url=$r/log/" >tmp &&
grep "^Status: 404 Not Found" tmp &&
grep "Failed to open $r: Not a valid git repository" tmp || return 1
done
@@ -42,7 +34,7 @@ test_expect_success 'a repository without a path answers 404' '
test_expect_success 'a repository without a path has no age on the index' '
mkdir -p "(null)/refs/heads" &&
>"(null)/refs/heads/master" &&
- CGIT_CONFIG="$PWD/nopathrc" QUERY_STRING="url=" cgit >tmp &&
+ cgit_rc nopathrc "url=" >tmp &&
grep "</html>" tmp &&
! grep "<time " tmp
'
@@ -57,12 +49,12 @@ test_expect_success 'a repository with an empty url is skipped with a warning' '
echo "repo.url=rob" &&
echo "repo.path=$PWD/repos/rob/.git"
} >nourlrc &&
- CGIT_CONFIG="$PWD/nourlrc" QUERY_STRING="url=rob/" cgit >tmp 2>err &&
+ cgit_rc nourlrc "url=rob/" >tmp 2>err &&
grep "^Status: 200" tmp &&
grep "Ignoring repository with an empty url" err &&
- CGIT_CONFIG="$PWD/nourlrc" QUERY_STRING="url=" cgit >tmp &&
+ cgit_rc nourlrc "url=" >tmp &&
! grep nourl tmp &&
- CGIT_CONFIG="$PWD/nourlrc" QUERY_STRING="r=" cgit >tmp &&
+ cgit_rc nourlrc "r=" >tmp &&
! grep nourl tmp
'
@@ -73,7 +65,7 @@ test_expect_success 'a scan path that is itself a repository is named after it'
echo "remove-suffix=1" &&
echo "scan-path=$PWD/repos/rob"
} >rootrc &&
- CGIT_CONFIG="$PWD/rootrc" QUERY_STRING="url=" cgit >tmp &&
+ cgit_rc rootrc "url=" >tmp &&
grep "toplevel-repo.><a href=./rob/.>rob</a>" tmp
'
@@ -86,7 +78,7 @@ test_expect_success 'a repo key after scan-path is reported instead of applied'
echo "scan-path=$PWD/repos" &&
echo "repo.desc=misplaced"
} >stalerc &&
- CGIT_CONFIG="$PWD/stalerc" QUERY_STRING="url=" cgit >tmp 2>err &&
+ cgit_rc stalerc "url=" >tmp 2>err &&
! grep "misplaced" tmp &&
grep "Ignoring repo.desc before any repo.url" err
'
@@ -100,7 +92,7 @@ test_expect_success 'a valueless or broken git config in a scanned repository is
echo "enable-git-config=1" &&
echo "scan-path=$PWD/scan"
} >gitcfgrc &&
- CGIT_CONFIG="$PWD/gitcfgrc" QUERY_STRING="url=" cgit >tmp 2>err &&
+ 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
'
@@ -113,7 +105,7 @@ test_expect_success 'only descriptive keys are taken from a scanned repository'
echo "head-content=<script>alert(1)</script>" &&
echo "logo-link=javascript:alert(2)"
} >scan/b.git/cgitrc &&
- CGIT_CONFIG="$PWD/gitcfgrc" QUERY_STRING="url=b.git/about/" cgit >tmp 2>err &&
+ cgit_rc gitcfgrc "url=b.git/about/" >tmp 2>err &&
grep "from the repo" tmp &&
grep "pre class=.plaintext." tmp &&
! grep "alert(" tmp &&
@@ -123,7 +115,7 @@ test_expect_success 'only descriptive keys are taken from a scanned repository'
test_expect_success 'a filesystem readme from a scanned repository is refused' '
echo "readme=/etc/hosts" >scan/b.git/cgitrc &&
- CGIT_CONFIG="$PWD/gitcfgrc" QUERY_STRING="url=b.git/about/" cgit >tmp 2>err &&
+ cgit_rc gitcfgrc "url=b.git/about/" >tmp 2>err &&
grep "Ignoring readme in " err
'
@@ -132,7 +124,7 @@ test_expect_success 'a filesystem readme from a scanned repository is refused' '
test_expect_success 'a readme ending in a colon is refused like a path on disk' '
echo "outside the repository" >"scan/outside:" &&
echo "readme=../outside:" >scan/b.git/cgitrc &&
- CGIT_CONFIG="$PWD/gitcfgrc" QUERY_STRING="url=b.git/about/" cgit >tmp 2>err &&
+ cgit_rc gitcfgrc "url=b.git/about/" >tmp 2>err &&
grep "Ignoring readme in " err &&
! grep "outside the repository" tmp
'
@@ -143,7 +135,7 @@ test_expect_success 'a readme set after scan-path reaches a scanned repository'
rm scan/b.git/cgitrc &&
cat gitcfgrc >laterrc &&
echo "readme=master:file-1" >>laterrc &&
- CGIT_CONFIG="$PWD/laterrc" QUERY_STRING="url=b.git/about/" cgit >tmp &&
+ cgit_rc laterrc "url=b.git/about/" >tmp &&
grep "<pre class=.plaintext.>1$" tmp
'
@@ -167,7 +159,7 @@ test_expect_success 'html serving from a scanned repository waits on trust' '
echo "mimetype.html=text/html" &&
echo "scan-path=$PWD/scan2"
} >htmlrc &&
- CGIT_CONFIG="$PWD/htmlrc" QUERY_STRING="url=c.git/plain/page.html" cgit >tmp 2>err &&
+ 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 &&
grep "Ignoring enable-html-serving in $PWD/scan2/c.git/: trust-scan-config is not set" err
@@ -178,19 +170,19 @@ test_expect_success 'with trust-scan-config the same repository serves html' '
echo "trust-scan-config=1" &&
cat htmlrc
} >htmltrustrc &&
- CGIT_CONFIG="$PWD/htmltrustrc" QUERY_STRING="url=c.git/plain/page.html" cgit >tmp &&
+ cgit_rc htmltrustrc "url=c.git/plain/page.html" >tmp &&
grep "^Content-Type: text/html" tmp &&
! grep "^X-Content-Type-Options" tmp
'
test_expect_success SYMLINKS 'a symlink cycle under the scan path is entered once' '
ln -s . scan/loop &&
- CGIT_CONFIG="$PWD/gitcfgrc" QUERY_STRING="url=" cgit >tmp &&
+ cgit_rc gitcfgrc "url=" >tmp &&
test $(grep -c "toplevel-repo" tmp) = 2
'
test_expect_success 'a bare query parameter does not swallow the next one' '
- robq "url=rob/commit/&x&id=$sha" >tmp &&
+ cgit_rc robrc "url=rob/commit/&x&id=$sha" >tmp &&
grep "<div class=.commit-subject.>commit 2" tmp
'
@@ -199,7 +191,7 @@ test_expect_success 'a filter that cannot run answers one error page' '
echo "commit-filter=exec:$PWD/no/such/filter" &&
cat robrc
} >badfilterrc &&
- CGIT_CONFIG="$PWD/badfilterrc" QUERY_STRING="url=rob/commit/" cgit >tmp 2>err &&
+ cgit_rc badfilterrc "url=rob/commit/" >tmp 2>err &&
test $(grep -c "^Status:" tmp) = 1 &&
grep "Unable to complete the request" tmp &&
grep "Unable to run filter $PWD/no/such/filter" err &&
@@ -211,7 +203,7 @@ test_expect_success 'a filter that exits without reading does not end cgit' '
echo "email-filter=exec:true" &&
cat robrc
} >truerc &&
- CGIT_CONFIG="$PWD/truerc" QUERY_STRING="url=rob/log/" cgit >tmp &&
+ cgit_rc truerc "url=rob/log/" >tmp &&
grep "^Status: 200" tmp &&
grep "</html>" tmp
'
@@ -223,7 +215,7 @@ test_expect_success 'a commit encoding header is read without its newline' '
git add file-1 &&
git -c i18n.commitEncoding=ISO-8859-1 commit -m "$(printf "caf\351")"
) &&
- robq "url=rob/commit/" >tmp &&
+ cgit_rc robrc "url=rob/commit/" >tmp &&
grep "<div class=.commit-subject.>caf$(printf "\303\251")<" tmp
'
@@ -242,43 +234,43 @@ test_expect_success 'a path below the about page answers 404' '
} >aboutrc &&
for path in sub sub/ missing.png file-1 ../robrc
do
- CGIT_CONFIG="$PWD/aboutrc" QUERY_STRING="url=rob/about/$path" cgit >tmp 2>err &&
+ cgit_rc aboutrc "url=rob/about/$path" >tmp 2>err &&
grep "^Status: 404" tmp &&
grep "^Content-Type: text/html" tmp &&
! grep fatal err || return 1
done &&
- CGIT_CONFIG="$PWD/aboutrc" QUERY_STRING="p=about&path=x" cgit >tmp &&
+ cgit_rc aboutrc "p=about&path=x" >tmp &&
grep "^Status: 404" tmp
'
test_expect_success 'a snapshot name holding a slash is refused' '
- robq "url=rob/snapshot/:/../../...tar.gz" >tmp &&
+ cgit_rc robrc "url=rob/snapshot/:/../../...tar.gz" >tmp &&
grep "^Status: 404" tmp &&
- robq "url=rob/snapshot/rob-master.tar.gz" >tmp &&
+ cgit_rc robrc "url=rob/snapshot/rob-master.tar.gz" >tmp &&
grep "^Status: 200" tmp
'
test_expect_success 'a path opening with a colon is refused on the log and patch pages' '
- robq "url=rob/log/:%25x" >tmp &&
+ cgit_rc robrc "url=rob/log/:%25x" >tmp &&
grep "^Status: 400" tmp &&
- robq "url=rob/patch/:%25x" >tmp &&
+ cgit_rc robrc "url=rob/patch/:%25x" >tmp &&
grep "^Status: 400" tmp &&
test $(grep -c "^Status:" tmp) = 1
'
test_expect_success 'a revision spelled like an option is refused' '
git -C repos/rob update-ref refs/heads/--stdin HEAD &&
- robq "url=rob/log/&h=--stdin" >tmp &&
+ cgit_rc robrc "url=rob/log/&h=--stdin" >tmp &&
grep "^Status: 404" tmp &&
- robq "url=rob/blame/file-1&id=--stdin" >tmp &&
+ cgit_rc robrc "url=rob/blame/file-1&id=--stdin" >tmp &&
grep "^Status: 400" tmp &&
- robq "url=rob/atom/&h=--stdin" >tmp &&
+ cgit_rc robrc "url=rob/atom/&h=--stdin" >tmp &&
grep "^Status: 404" tmp
'
test_expect_success 'the blob page reads a file through an annotated tag' '
git -C repos/rob -c tag.gpgsign=false tag -a -m note ann HEAD &&
- robq "url=rob/blob/&h=ann&path=file-1" >tmp &&
+ cgit_rc robrc "url=rob/blob/&h=ann&path=file-1" >tmp &&
strip_headers <tmp >body &&
printf "more\n" >want &&
test_cmp want body
@@ -288,14 +280,14 @@ test_expect_success 'the blob page reads a file through an annotated tag' '
# blob page used to answer such a request with the raw commit object.
test_expect_success 'the blob page walks a path out of the commit or tag the id names' '
tip=$(git -C repos/rob rev-parse HEAD) &&
- robq "url=rob/blob/file-1&id=$tip" >tmp &&
+ cgit_rc robrc "url=rob/blob/file-1&id=$tip" >tmp &&
strip_headers <tmp >body &&
test_cmp want body &&
tag=$(git -C repos/rob rev-parse ann) &&
- robq "url=rob/blob/file-1&id=$tag" >tmp &&
+ cgit_rc robrc "url=rob/blob/file-1&id=$tag" >tmp &&
strip_headers <tmp >body &&
test_cmp want body &&
- robq "url=rob/blob/missing&id=$tip" >tmp &&
+ cgit_rc robrc "url=rob/blob/missing&id=$tip" >tmp &&
grep "^Status: 404" tmp
'
@@ -319,21 +311,21 @@ test_expect_success 'the commit page shows a message whole when text follows its
echo "enable-commit-trailers=1" &&
cat robrc
} >trailrc &&
- CGIT_CONFIG="$PWD/trailrc" QUERY_STRING="url=rob/commit/" cgit >tmp &&
+ cgit_rc trailrc "url=rob/commit/" >tmp &&
! grep "commit-trailers" tmp &&
grep "Conflicts:" tmp
'
test_expect_success 'a revision expression that walks the history is refused' '
- robq "url=rob/log/&h=:/zzzz" >tmp &&
+ cgit_rc robrc "url=rob/log/&h=:/zzzz" >tmp &&
grep "^Status: 404" tmp &&
- robq "url=rob/commit/&id=HEAD^{/zzzz}" >tmp &&
+ cgit_rc robrc "url=rob/commit/&id=HEAD^{/zzzz}" >tmp &&
grep "^Status: 400" tmp &&
- robq "url=rob/log/&qt=range&q=:/zzzz" >tmp &&
+ cgit_rc robrc "url=rob/log/&qt=range&q=:/zzzz" >tmp &&
grep "^Status: 400" tmp &&
- robq "url=rob/log/&qt=range&q=master~1..master" >tmp &&
+ cgit_rc robrc "url=rob/log/&qt=range&q=master~1..master" >tmp &&
grep "^Status: 400" tmp &&
- robq "url=rob/log/&qt=range&q=$sha..master" >tmp &&
+ cgit_rc robrc "url=rob/log/&qt=range&q=$sha..master" >tmp &&
grep "^Status: 200" tmp
'
@@ -345,20 +337,14 @@ test_expect_success 'a commit with a broken tree line does not crash the blob pa
git hash-object -t commit -w --stdin --literally) &&
echo $bad >.git/refs/heads/bad
) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=broken" &&
- echo "repo.path=$PWD/broken/.git" &&
- echo "repo.readme=:file-1"
- } >brokenrc &&
- CGIT_CONFIG="$PWD/brokenrc" QUERY_STRING="url=broken/blob/&h=bad&path=file-1" cgit >tmp &&
+ 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 &&
grep "^Status: 404" tmp
'
test_expect_success 'a die inside git answers one 500 page and logs the reason' '
printf "[core\n" >>broken/.git/config &&
- CGIT_CONFIG="$PWD/brokenrc" QUERY_STRING="url=broken/log/" cgit >tmp 2>err &&
+ cgit_rc brokenrc "url=broken/log/" >tmp 2>err &&
grep "^Status: 500" tmp &&
test $(grep -c "^Status:" tmp) = 1 &&
grep "bad config line" err &&
@@ -370,17 +356,12 @@ test_expect_success 'a history with a missing parent renders up to the gap' '
older=$(git -C gap rev-parse HEAD~3) &&
parent=$(git -C gap rev-parse HEAD~2) &&
rm gap/.git/objects/$(echo $parent | cut -c1-2)/$(echo $parent | cut -c3-) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=gap" &&
- echo "repo.path=$PWD/gap/.git"
- } >gaprc &&
- CGIT_CONFIG="$PWD/gaprc" QUERY_STRING="url=gap/log/" cgit >tmp 2>err &&
+ cgitrc_repo gaprc gap "repo.path=$PWD/gap/.git" &&
+ cgit_rc gaprc "url=gap/log/" >tmp 2>err &&
test $(grep -c "^Status:" tmp) = 1 &&
grep "Unable to complete the request" tmp &&
grep "Failed to traverse parents" err &&
- CGIT_CONFIG="$PWD/gaprc" QUERY_STRING="url=gap/patch/&id2=$older" cgit >tmp &&
+ cgit_rc gaprc "url=gap/patch/&id2=$older" >tmp &&
test $(grep -c "^Status:" tmp) = 1 &&
grep "^Status: 500" tmp
'
@@ -403,13 +384,8 @@ test_expect_success 'a corrupt blob in a collected diff answers the error' '
test_copy_bytes $((size / 2)) <$obj >half &&
mv half $obj
) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=corrupt" &&
- echo "repo.path=$PWD/corrupt/.git"
- } >corruptrc &&
- CGIT_CONFIG="$PWD/corruptrc" QUERY_STRING="url=corrupt/commit/" cgit >tmp 2>err &&
+ cgitrc_repo corruptrc corrupt "repo.path=$PWD/corrupt/.git" &&
+ cgit_rc corruptrc "url=corrupt/commit/" >tmp 2>err &&
grep "is corrupt" err &&
grep "Unable to complete the request" tmp
'
@@ -427,7 +403,7 @@ test_expect_success 'a filter pipeline sees the default SIGPIPE disposition' '
echo "source-filter=exec:$PWD/pipe.sh" &&
cat robrc
} >piperc &&
- CGIT_CONFIG="$PWD/piperc" QUERY_STRING="url=rob/tree/file-1" cgit >tmp 2>err &&
+ cgit_rc piperc "url=rob/tree/file-1" >tmp 2>err &&
grep "^Status: 200" tmp &&
! grep -i "broken pipe" err
'
@@ -435,7 +411,7 @@ test_expect_success 'a filter pipeline sees the default SIGPIPE disposition' '
test_expect_success 'the fallback branch skips a name spelled like an option' '
git -C repos/rob update-ref refs/heads/-first HEAD &&
git -C repos/rob symbolic-ref HEAD refs/heads/gone &&
- robq "url=rob/" >tmp &&
+ cgit_rc robrc "url=rob/" >tmp &&
git -C repos/rob symbolic-ref HEAD refs/heads/master &&
grep "^Status: 200" tmp
'
@@ -459,13 +435,13 @@ test_expect_success 'a blank line in the mimetype file is skipped' '
echo "mimetype-file=$PWD/mime.types" &&
cat robrc
} >mimerc &&
- CGIT_CONFIG="$PWD/mimerc" QUERY_STRING="url=rob/plain/note.cgt" cgit >tmp &&
+ cgit_rc mimerc "url=rob/plain/note.cgt" >tmp &&
grep "^Content-Type: image/x-cgit" tmp
'
test_expect_success 'an indented comment in the mimetype file is skipped' '
printf " # cgt used to be image/x-old\nimage/x-cgit cgt\n" >mime.types &&
- CGIT_CONFIG="$PWD/mimerc" QUERY_STRING="url=rob/plain/note.cgt" cgit >tmp &&
+ cgit_rc mimerc "url=rob/plain/note.cgt" >tmp &&
grep "^Content-Type: image/x-cgit" tmp
'
@@ -479,9 +455,9 @@ test_expect_success 'a refs page named with an id is not cached for ever' '
grep -v "^cache-size" robrc
} >ttlrc &&
full=$(git -C repos/rob rev-parse HEAD) &&
- CGIT_CONFIG="$PWD/ttlrc" QUERY_STRING="url=rob/refs/&id=$full" cgit >tmp &&
+ cgit_rc ttlrc "url=rob/refs/&id=$full" >tmp &&
git -C repos/rob tag later HEAD &&
- CGIT_CONFIG="$PWD/ttlrc" QUERY_STRING="url=rob/refs/&id=$full" cgit >tmp &&
+ cgit_rc ttlrc "url=rob/refs/&id=$full" >tmp &&
grep ">later<" tmp
'
@@ -500,15 +476,15 @@ test_expect_success 'the diff caps hold when the path names a directory' '
echo "max-diff-files=2" &&
cat robrc
} >caprc &&
- CGIT_CONFIG="$PWD/caprc" QUERY_STRING="url=rob/diff/dir" cgit >tmp &&
+ cgit_rc caprc "url=rob/diff/dir" >tmp &&
grep "too large to be rendered inline" tmp &&
- CGIT_CONFIG="$PWD/caprc" QUERY_STRING="url=rob/diff/dir/f1" cgit >tmp &&
+ cgit_rc caprc "url=rob/diff/dir/f1" >tmp &&
! grep "too large to be rendered inline" tmp
'
test_expect_success 'a snapshot of a tag spelled like an option is archived' '
git -C repos/rob update-ref refs/tags/-l HEAD &&
- robq "url=rob/snapshot/-l.tar.gz" >tmp &&
+ cgit_rc robrc "url=rob/snapshot/-l.tar.gz" >tmp &&
grep "^Status: 200" tmp &&
strip_headers <tmp | gzip -dc | tar -tf - >list &&
grep "file-1" list
@@ -535,9 +511,9 @@ test_expect_success 'a disk readme in the repository directory serves no sibling
cat robrc &&
echo "repo.readme=README"
} >diskrc &&
- CGIT_CONFIG="$PWD/diskrc" QUERY_STRING="url=rob/about/" cgit >tmp &&
+ cgit_rc diskrc "url=rob/about/" >tmp &&
grep "hello" tmp &&
- CGIT_CONFIG="$PWD/diskrc" QUERY_STRING="url=rob/about/config" cgit >tmp &&
+ cgit_rc diskrc "url=rob/about/config" >tmp &&
grep "^Status: 404" tmp &&
! grep "repositoryformatversion" tmp
'
@@ -545,23 +521,18 @@ test_expect_success 'a disk readme in the repository directory serves no sibling
test_expect_success 'a tag pointing at a tag links the inner tag by id' '
git -C repos/rob -c tag.gpgsign=false tag -a -m outer outer ann &&
inner=$(git -C repos/rob rev-parse ann) &&
- robq "url=rob/tag/&id=$inner" >tmp &&
+ cgit_rc robrc "url=rob/tag/&id=$inner" >tmp &&
grep "^Status: 200" tmp &&
grep "tagged object" tmp
'
test_expect_success 'the dumb transport serves an empty repository' '
git init -q --bare empty.git &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=empty" &&
- echo "repo.path=$PWD/empty.git"
- } >emptyrc &&
- CGIT_CONFIG="$PWD/emptyrc" QUERY_STRING="url=empty/info/refs" cgit >tmp &&
+ cgitrc_repo emptyrc empty "repo.path=$PWD/empty.git" &&
+ cgit_rc emptyrc "url=empty/info/refs" >tmp &&
grep "^Status: 200" tmp &&
grep "^Content-Type: text/plain" tmp &&
- CGIT_CONFIG="$PWD/emptyrc" QUERY_STRING="url=empty/objects/info" cgit >tmp &&
+ cgit_rc emptyrc "url=empty/objects/info" >tmp &&
grep "^Status: 404" tmp
'
@@ -569,10 +540,10 @@ test_expect_success 'the dumb transport serves an empty repository' '
# its size up front and compare what arrived against it.
test_expect_success 'the dumb transport sends a file with its size' '
git -C repos/rob repack -q -d &&
- robq "url=rob/objects/info/packs" >tmp &&
+ cgit_rc robrc "url=rob/objects/info/packs" >tmp &&
pack=$(strip_headers <tmp | sed -n "s/^P //p" | head -1) &&
test -n "$pack" &&
- robq "url=rob/objects/pack/$pack" >tmp &&
+ cgit_rc robrc "url=rob/objects/pack/$pack" >tmp &&
grep "^Status: 200" tmp &&
size=$(wc -c <repos/rob/.git/objects/pack/$pack | tr -d " ") &&
grep "^Content-Length: $size$" tmp &&
@@ -588,43 +559,38 @@ test_expect_success 'the dumb transport withholds the alternates file' '
for path in info/alternates info//alternates info/./alternates ./info/alternates \
info/Alternates /info/alternates
do
- robq "url=rob/objects/$path" >tmp &&
+ cgit_rc robrc "url=rob/objects/$path" >tmp &&
grep "^Status: 404" tmp &&
! grep "repos/foo" tmp || return 1
done &&
rm repos/rob/.git/objects/info/alternates &&
- robq "url=rob/objects/info/packs" >tmp &&
+ cgit_rc robrc "url=rob/objects/info/packs" >tmp &&
grep "^Status: 200" tmp
'
# A reftable repository keeps only a placeholder in its HEAD file, so the
# 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' '
- robq "url=rob/HEAD" >tmp &&
+ cgit_rc robrc "url=rob/HEAD" >tmp &&
grep "^Status: 200" tmp &&
strip_headers <tmp >head &&
echo "ref: refs/heads/master" >expect &&
test_cmp expect head &&
git init -q --bare --ref-format=reftable -b trunk rt.git &&
git -C repos/rob push -q "$PWD/rt.git" master:trunk &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=rt" &&
- echo "repo.path=$PWD/rt.git"
- } >rtrc &&
- CGIT_CONFIG="$PWD/rtrc" QUERY_STRING="url=rt/HEAD" cgit >tmp &&
+ cgitrc_repo rtrc rt "repo.path=$PWD/rt.git" &&
+ cgit_rc rtrc "url=rt/HEAD" >tmp &&
strip_headers <tmp >head &&
echo "ref: refs/heads/trunk" >expect &&
test_cmp expect head &&
- CGIT_CONFIG="$PWD/emptyrc" QUERY_STRING="url=empty/HEAD" cgit >tmp &&
+ cgit_rc emptyrc "url=empty/HEAD" >tmp &&
strip_headers <tmp >head &&
echo "ref: refs/heads/master" >expect &&
test_cmp expect head
'
test_expect_success 'a reftable repository shows its age on the index' '
- CGIT_CONFIG="$PWD/rtrc" QUERY_STRING="url=" cgit >tmp &&
+ cgit_rc rtrc "url=" >tmp &&
grep "<td class=.col-idle.><time " tmp
'
@@ -638,7 +604,7 @@ test_expect_success 'a client that disconnects ends the request quietly' '
git add long.txt &&
git commit -m long
) &&
- { robq "url=rob/tree/long.txt" 2>err; echo $? >status; } | head -c 1 >/dev/null &&
+ { cgit_rc robrc "url=rob/tree/long.txt" 2>err; echo $? >status; } | head -c 1 >/dev/null &&
test "$(cat status)" = 0 &&
! grep -i "broken pipe" err &&
! grep "die()" err
@@ -655,11 +621,11 @@ test_expect_success 'pages behind an auth filter are marked private' '
echo "auth-filter=exec:$PWD/letin.sh" &&
cat robrc
} >letinrc &&
- CGIT_CONFIG="$PWD/letinrc" QUERY_STRING="url=rob/log/" cgit >tmp &&
+ cgit_rc letinrc "url=rob/log/" >tmp &&
grep "^Status: 200" tmp &&
grep "^Cache-Control: private$" tmp &&
grep "^Vary: Cookie$" tmp &&
- robq "url=rob/log/" >tmp &&
+ cgit_rc robrc "url=rob/log/" >tmp &&
! grep "^Cache-Control" tmp &&
! grep "^Vary" tmp
'
@@ -668,10 +634,10 @@ test_expect_success 'pages behind an auth filter are marked private' '
# the branch asked for has to survive that hop.
test_expect_success 'the about redirect keeps the query string' '
git -C repos/rob branch other HEAD &&
- robq "url=rob/about&h=other&x=1" >tmp &&
+ cgit_rc robrc "url=rob/about&h=other&x=1" >tmp &&
grep "^Status: 302" tmp &&
grep "^Location: /rob/?h=other&x=1$" tmp &&
- CGIT_CONFIG="$PWD/aboutrc" QUERY_STRING="url=rob/about&h=other" cgit >tmp &&
+ cgit_rc aboutrc "url=rob/about&h=other" >tmp &&
grep "^Status: 200" tmp
'
@@ -683,9 +649,9 @@ test_expect_success 'the readme follows an annotated tag as the head' '
cat robrc &&
echo "repo.readme=:file-1"
} >tagreadmerc &&
- CGIT_CONFIG="$PWD/tagreadmerc" QUERY_STRING="url=rob/about/&h=v1" cgit >tmp &&
+ cgit_rc tagreadmerc "url=rob/about/&h=v1" >tmp &&
grep "^Status: 200" tmp &&
- CGIT_CONFIG="$PWD/tagreadmerc" QUERY_STRING="url=rob/tree/&h=v1" cgit >tmp &&
+ cgit_rc tagreadmerc "url=rob/tree/&h=v1" >tmp &&
grep ">about<" tmp
'
@@ -702,7 +668,7 @@ test_expect_success 'a symlink whose target is a large blob is listed without it
git update-index --add --cacheinfo 120000,$big,biglink &&
git commit -m biglink
) &&
- robq "url=rob/tree/" >tmp &&
+ cgit_rc robrc "url=rob/tree/" >tmp &&
grep "biglink" tmp &&
! grep "aaaaaaaaaa" tmp
'
@@ -716,7 +682,7 @@ test_expect_success 'a chain of single directories is followed a bounded number
git add d &&
git commit -m deep
) &&
- robq "url=rob/tree/" >tmp &&
+ cgit_rc robrc "url=rob/tree/" >tmp &&
test $(grep -o "class=.ls-dir." tmp | wc -l) -le 17
'
@@ -731,7 +697,7 @@ test_expect_success 'an unreadable project list is named with its error' '
echo "project-list=$PWD/projdir" &&
echo "scan-path=$PWD/repos"
} >projrc &&
- CGIT_CONFIG="$PWD/projrc" QUERY_STRING="url=" cgit >tmp 2>err &&
+ cgit_rc projrc "url=" >tmp 2>err &&
grep "project list .*projdir: Is a directory" err
'
@@ -744,7 +710,7 @@ test_expect_success SANITY 'a scan entry that cannot be searched is named in ful
echo "cache-size=0" &&
echo "scan-path=$PWD/scanperm"
} >scanpermrc &&
- CGIT_CONFIG="$PWD/scanpermrc" QUERY_STRING="url=" cgit >tmp 2>err &&
+ cgit_rc scanpermrc "url=" >tmp 2>err &&
grep "Unable to stat .*scanperm/locked/objects: Permission denied" err
'
@@ -759,7 +725,7 @@ test_expect_success 'a readme past max-blob-size is reported on the about page'
cat robrc &&
echo "repo.readme=:big-readme"
} >bigreadmerc &&
- CGIT_CONFIG="$PWD/bigreadmerc" QUERY_STRING="url=rob/about/" cgit >tmp &&
+ cgit_rc bigreadmerc "url=rob/about/" >tmp &&
grep "The readme is larger than max-blob-size (1 KB)" tmp
'
@@ -767,9 +733,9 @@ test_expect_success 'a readme past max-blob-size is reported on the about page'
# that was just refused must not be looked up to get there, since the wider
# revision syntax walks the whole history for a match.
test_expect_success 'the error page does not resolve the id it refused' '
- robq "url=rob/log/&id=$sha" >tmp &&
+ cgit_rc robrc "url=rob/log/&id=$sha" >tmp &&
grep "<title>.* @ " tmp &&
- robq "url=rob/log/&id=%3A/commit" >tmp &&
+ cgit_rc robrc "url=rob/log/&id=%3A/commit" >tmp &&
grep "^Status: 400" tmp &&
! grep "<title>.* @ " tmp
'
@@ -794,22 +760,17 @@ test_expect_success 'odd dates and zones in pushed objects render' '
git hash-object -t commit -w --literally --stdin) &&
git update-ref refs/heads/zone $zone
) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=dates" &&
- echo "repo.path=$PWD/repos/dates/.git"
- } >datesrc &&
+ cgitrc_repo datesrc dates &&
for q in "url=dates/" "url=dates/refs/" "url=dates/tag/&h=early" \
"url=dates/log/&h=far" "url=dates/commit/&h=far" "url=dates/commit/&h=zone" \
"url=dates/atom/&h=far"
do
- CGIT_CONFIG="$PWD/datesrc" QUERY_STRING="$q" cgit >tmp 2>err &&
+ cgit_rc datesrc "$q" >tmp 2>err &&
grep "^Status: 200" tmp &&
! grep "Unable to complete" tmp &&
! grep "Timestamp" err || return 1
done &&
- CGIT_CONFIG="$PWD/datesrc" QUERY_STRING="url=dates/commit/&h=far" cgit >tmp &&
+ cgit_rc datesrc "url=dates/commit/&h=far" >tmp &&
grep "1970-01-01" tmp
'
@@ -826,7 +787,7 @@ test_expect_success 'a notes ref that names no tree is passed over' '
for q in "url=dates/" "url=dates/log/" "url=dates/refs/" "url=dates/tree/" \
"url=dates/snapshot/dates-base.tar.asc"
do
- CGIT_CONFIG="$PWD/notesrc" QUERY_STRING="$q" cgit >tmp 2>err &&
+ cgit_rc notesrc "$q" >tmp 2>err &&
! grep "Unable to complete" tmp &&
! grep "notes tree" err || return 1
done &&
@@ -839,7 +800,7 @@ test_expect_success 'a scanned defbranch cannot name a path outside the reposito
mkdir -p secret &&
touch -t 200001010000 secret/file &&
echo "defbranch=../../../../secret/file" >scan/b.git/cgitrc &&
- CGIT_CONFIG="$PWD/gitcfgrc" QUERY_STRING="url=" cgit >tmp &&
+ cgit_rc gitcfgrc "url=" >tmp &&
grep ">b.git</a>" tmp &&
! grep "data-ut=.946" tmp
'
diff --git a/tests/t0505-auth.sh b/tests/t0505-auth.sh
index 3ae134d..7dd4a36 100755
--- a/tests/t0505-auth.sh
+++ b/tests/t0505-auth.sh
@@ -69,7 +69,7 @@ test_expect_success CGIT_LUA_NOAUTH 'without the modules a protected repository
repo.url=authy
repo.path=$PWD/repos/authy/.git
EOF
- CGIT_CONFIG="$PWD/guardedrc" QUERY_STRING="url=authy/log/" cgit >tmp &&
+ cgit_rc guardedrc "url=authy/log/" >tmp &&
! grep "guarded commit" tmp &&
grep "Unable to complete the request" tmp
'
diff --git a/tests/t0507-hooks.sh b/tests/t0507-hooks.sh
index 9211f8b..ec31546 100755
--- a/tests/t0507-hooks.sh
+++ b/tests/t0507-hooks.sh
@@ -32,8 +32,8 @@ test_expect_success 'set up a cache of two repositories and the index' '
CGIT_CONFIG="$PWD/cachedrc" PATH_INFO="$page" QUERY_STRING= cgit >/dev/null ||
return 1
done &&
- CGIT_CONFIG="$PWD/cachedrc" QUERY_STRING="url=a.git/refs/" cgit >/dev/null &&
- CGIT_CONFIG="$PWD/cachedrc" QUERY_STRING="url=b.git/refs/" cgit >/dev/null &&
+ cgit_rc cachedrc "url=a.git/refs/" >/dev/null &&
+ cgit_rc cachedrc "url=b.git/refs/" >/dev/null &&
echo writer >slots/0123abcd.lock &&
cp -R slots pristine &&
sed -e "s|^cache_root=.*|cache_root='\''$PWD/slots'\''|" \