summaryrefslogtreecommitdiff
path: root/caddytest/integration
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2021-04-19 21:54:12 -0400
committerGitHub <noreply@github.com>2021-04-19 19:54:12 -0600
commitd789596bc0b014c99d75c00fe8e55c40ee3d58e3 (patch)
treeafb7c01838832af81d10df46b0e11ea26ece3a15 /caddytest/integration
parent96bb3659299ae5ef28ffb3f9a23e16417c570924 (diff)
caddyhttp: Implement better logic for inserting the HTTP->HTTPS redirs (#4033)
* caddyhttp: Implement better logic for inserting the HTTP->HTTPS redirs * caddyhttp: Add integration test
Diffstat (limited to 'caddytest/integration')
-rw-r--r--caddytest/integration/autohttps_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/caddytest/integration/autohttps_test.go b/caddytest/integration/autohttps_test.go
index db6329a..72968e9 100644
--- a/caddytest/integration/autohttps_test.go
+++ b/caddytest/integration/autohttps_test.go
@@ -80,3 +80,26 @@ func TestAutoHTTPRedirectsWithHTTPListenerFirstInAddresses(t *testing.T) {
`, "json")
tester.AssertRedirect("http://localhost:9080/", "https://localhost/", http.StatusPermanentRedirect)
}
+
+func TestAutoHTTPRedirectsInsertedBeforeUserDefinedCatchAll(t *testing.T) {
+ tester := caddytest.NewTester(t)
+ tester.InitServer(`
+ {
+ http_port 9080
+ https_port 9443
+ local_certs
+ }
+ http://:9080 {
+ respond "Foo"
+ }
+ http://baz.localhost:9080 {
+ respond "Baz"
+ }
+ bar.localhost {
+ respond "Bar"
+ }
+ `, "caddyfile")
+ tester.AssertRedirect("http://bar.localhost:9080/", "https://bar.localhost/", http.StatusPermanentRedirect)
+ tester.AssertGetResponse("http://foo.localhost:9080/", 200, "Foo")
+ tester.AssertGetResponse("http://baz.localhost:9080/", 200, "Baz")
+}