Diff options
Diffstat (limited to '')
| -rwxr-xr-x | tests/t0205-config.sh | 41 |
1 file changed, 18 insertions, 23 deletions
diff --git a/tests/t0205-config.sh b/tests/t0205-config.sh index 4536e49..32c260e 100755 --- a/tests/t0205-config.sh +++ b/tests/t0205-config.sh @@ -1,43 +1,35 @@ #!/bin/sh -# Checks what the configuration parser reports on stderr. A key it does not -# know, a repo key before any repository and a filter set by a scanned -# repository without trust-scan-config are each ignored with a warning naming -# the key, a repo filter in the main cgitrc passes without one, a repository -# whose path is missing answers 404 on every page, and a config cgit fully -# understands stays silent. +# Checks what the configuration parser reports on stderr. 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 && + write_script drain-filter <<-\EOF && + cat >/dev/null + EOF + 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" && echo "repo.desc=early" && echo "repo.url=diag" && echo "repo.path=$PWD/repos/foo/.git" && - echo "repo.about-filter=exec:/bin/true" + echo "repo.readme=:file-1" && + echo "repo.about-filter=exec:$PWD/drain-filter" } >earlyrc ' 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 ' @@ -50,7 +42,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 ' @@ -60,14 +52,17 @@ 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 ' +# The filter prints nothing, so an empty about div shows that it ran in place +# of the readme. It reads its input first, so its exit cannot race cgit's +# write. test_expect_success 'a repo filter in the main cgitrc needs no flag' ' - ! grep "about-filter" err && - CGIT_CONFIG="$PWD/earlyrc" QUERY_STRING="url=diag/" cgit >tmp 2>err && + cgit_rc earlyrc "url=diag/about/" >tmp 2>err && + grep "<div id=.about.></div>" tmp && ! grep "about-filter" err ' @@ -82,7 +77,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 && @@ -106,7 +101,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 ' |
