Skip to content

Commit

Permalink
add explicit worker test
Browse files Browse the repository at this point in the history
  • Loading branch information
withinboredom committed Dec 17, 2023
1 parent 4552510 commit fee1d06
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions caddy/caddy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,39 @@ func TestPhpServerXAccelRedirect(t *testing.T) {
tester.AssertGetResponse("http://localhost:9080/xaccel.php?redir=/hello.txt", http.StatusOK, "Hello")
tester.AssertGetResponse("http://localhost:9080/xaccel.php?redir=/not_exist.txt", http.StatusNotFound, "")
}

func TestPhpServerXAccelRedirectWorker(t *testing.T) {
tester := caddytest.NewTester(t)
tester.InitServer(`
{
skip_install_trust
admin localhost:2999
http_port 9080
https_port 9443
frankenphp {
worker ../testdata/index.php 2
}
order php_server before respond
}
localhost:9080 {
root * ../testdata
php_server {
file_server off
@accel header X-Accel-Redirect *
handle_response @accel {
root * ../testdata
rewrite {rp.header.X-Accel-Redirect}
file_server
}
}
respond "Not found" 404
}
`, "caddyfile")

tester.AssertGetResponse("http://localhost:9080", http.StatusOK, "I am by birth a Genevese (i not set)")
tester.AssertGetResponse("http://localhost:9080/hello.txt", http.StatusNotFound, "Not found")
tester.AssertGetResponse("http://localhost:9080/xaccel.php?redir=/hello.txt", http.StatusOK, "Hello")
tester.AssertGetResponse("http://localhost:9080/xaccel.php?redir=/not_exist.txt", http.StatusNotFound, "")
}

0 comments on commit fee1d06

Please sign in to comment.