From 7227e7933c793408076cee0e63bc2e98fc4cc3c1 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 12:27:42 -1000 Subject: Hold the plain tests to a working page The plain requests passed on any answer short of a crash, and the listing test never looked at where its links led. The types config was a copy of the shared one with its page cache still on, which cgitrc_copy exists to switch off. --- tests/t0105-plain.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/t0105-plain.sh b/tests/t0105-plain.sh index 6a96b61..97c1164 100755 --- a/tests/t0105-plain.sh +++ b/tests/t0105-plain.sh @@ -9,7 +9,7 @@ test_description='Check content on plain page' . ./setup.sh test_expect_success 'generate foo/plain/file-1' ' - cgit_url "foo/plain/file-1" >tmp + cgit_ok_url "foo/plain/file-1" >tmp ' test_expect_success 'a text file is served as text/plain' ' @@ -29,10 +29,9 @@ test_expect_success 'a missing path is a 404' ' ' test_expect_success 'a directory answers with a listing of links' ' - cgit_url "foo/plain" >tmp && - grep "
  • tmp && + test_grep "
  • file-1
  • " tmp && + test_grep "
  • file-5
  • " tmp ' test_expect_success 'a blob whose bytes look binary is served as octet-stream' ' @@ -42,7 +41,7 @@ test_expect_success 'a blob whose bytes look binary is served as octet-stream' ' git add blob.bin && git commit -m binary ) && - cgit_url "foo/plain/blob.bin" >tmp && + cgit_ok_url "foo/plain/blob.bin" >tmp && sed "/^$/q" tmp | grep "^Content-Type: application/octet-stream$" ' @@ -59,15 +58,11 @@ test_expect_success 'only text and xml types carry a charset' ' ) && docx=application/vnd.openxmlformats-officedocument. && docx=${docx}wordprocessingml.document && - { - echo "enable-html-serving=1" && - echo "mimetype.docx=$docx" && - echo "mimetype.svg=image/svg+xml" && - cat cgitrc - } >typesrc && - cgit_rc typesrc "url=foo/plain/doc.docx" >tmp && + cgitrc_copy typesrc enable-html-serving=1 "mimetype.docx=$docx" \ + mimetype.svg=image/svg+xml && + cgit_ok typesrc "url=foo/plain/doc.docx" >tmp && sed "/^$/q" tmp | grep "^Content-Type: $docx$" && - cgit_rc typesrc "url=foo/plain/pic.svg" >tmp && + cgit_ok typesrc "url=foo/plain/pic.svg" >tmp && sed "/^$/q" tmp | grep "^Content-Type: image/svg+xml; charset=UTF-8$" ' @@ -84,7 +79,7 @@ test_expect_success 'plain answers once for duplicate tree entries' ' git update-ref refs/heads/master $c ) && cgitrc_repo duprc dup mimetype.png=image/png && - cgit_rc duprc "url=dup/plain/x.png" >tmp && + cgit_ok duprc "url=dup/plain/x.png" >tmp && test $(grep -c "^Status:" tmp) = 1 && test $(grep -c "^Content-Type:" tmp) = 1 && grep "^Content-Type: image/png" tmp @@ -92,6 +87,7 @@ test_expect_success 'plain answers once for duplicate tree entries' ' # A header line cannot carry a control byte, and a web server refuses the # whole response over one, so a file name holding one is sent with a stand-in. +# The commit joins the dup repository the test above built. test_expect_success 'a control character in a file name stays out of the headers' ' ( cd repos/dup && @@ -100,7 +96,7 @@ test_expect_success 'a control character in a file name stays out of the headers c=$(echo ctl | git commit-tree $top) && git update-ref refs/heads/ctl $c ) && - cgit_rc duprc "url=dup/plain/ctl%01name.txt&h=ctl" >tmp && + cgit_ok duprc "url=dup/plain/ctl%01name.txt&h=ctl" >tmp && grep "^Content-Disposition: inline; filename=.ctl?name.txt.$" tmp ' -- cgit 2.12.1