Diff options
Diffstat (limited to 'tests/t0401-serve.sh')
| -rwxr-xr-x | tests/t0401-serve.sh | 52 |
1 file changed, 48 insertions, 4 deletions
diff --git a/tests/t0401-serve.sh b/tests/t0401-serve.sh index ca15e1c..23b8697 100755 --- a/tests/t0401-serve.sh +++ b/tests/t0401-serve.sh @@ -1,9 +1,11 @@ #!/bin/sh -# Checks how tools/serve.py, the preview server that runs the built binary and -# hands its output back over HTTP, tells the CGI headers from the body. The -# cases live in serve-split-check.py beside this file, and nothing here touches -# a repository, so the fixtures stay unbuilt. +# Checks tools/serve.py, the preview server that runs the built binary and +# hands its output back over HTTP. The cases live beside this file, in +# serve-split-check.py for how the CGI headers are told from the body and in +# serve-handler-check.py for a request served on a free loopback port with a +# stub in place of cgit. Nothing here touches a repository, so the fixtures +# stay unbuilt. test_description='Check the preview server splits CGI output correctly' CGIT_TEST_NO_CREATE_REPOS=YesPlease @@ -51,4 +53,46 @@ test_expect_success 'output with no blank line at all is all headers' ' split_check no-blank-line ' +handler_check() { + mkdir "$1" && + "$PYTHON" -I "$TEST_OUTPUT_DIRECTORY/serve-handler-check.py" \ + "$TEST_OUTPUT_DIRECTORY/.." "$PWD/$1" "$1" +} + +test_expect_success 'a request reaches the CGI with the environment it needs' ' + handler_check environment +' + +test_expect_success 'a request body reaches the CGI with its length' ' + handler_check post-body +' + +test_expect_success 'a root-level asset is served from the data directory' ' + handler_check asset +' + +test_expect_success 'a file of that name inside a repository goes to the CGI' ' + handler_check repository-file +' + +test_expect_success 'a link out of the data directory is no asset' ' + handler_check asset-link-outside +' + +test_expect_success 'a CGI that fails is answered with 500' ' + handler_check failing-cgi +' + +test_expect_success 'a CGI that stalls is answered with 504' ' + handler_check stalled-cgi +' + +test_expect_success 'a body over the cap is refused with 413' ' + handler_check oversized-body +' + +test_expect_success 'a HEAD request gets the headers alone' ' + handler_check head +' + test_done |
