summaryrefslogtreecommitdiff
path: root/caddytest
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2020-09-17 23:46:24 -0400
committerGitHub <noreply@github.com>2020-09-17 21:46:24 -0600
commitd16ede358a2ec049bda28bf37e79c9cfcaa64c29 (patch)
tree9304f4b06287fa2cbeafda019a70556a00e119ee /caddytest
parentc82c231ba7ec7c400e4d48ab943f57a6b29a2a2a (diff)
metrics: Fix hidden panic while observing with bad exemplars (#3733)
* metrics: Fixing panic while observing with bad exemplars Signed-off-by: Dave Henderson <dhenderson@gmail.com> * Minor cleanup The server is already added to the context. So, we can simply use that to get the server name, which is a field on the server. * Add integration test for auto HTTP->HTTPS redirects A test like this would have caught the problem in the first place Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'caddytest')
-rw-r--r--caddytest/integration/autohttps_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/caddytest/integration/autohttps_test.go b/caddytest/integration/autohttps_test.go
new file mode 100644
index 0000000..62f172d
--- /dev/null
+++ b/caddytest/integration/autohttps_test.go
@@ -0,0 +1,22 @@
+package integration
+
+import (
+ "net/http"
+ "testing"
+
+ "github.com/caddyserver/caddy/v2/caddytest"
+)
+
+func TestAutoHTTPtoHTTPSRedirects(t *testing.T) {
+ tester := caddytest.NewTester(t)
+ tester.InitServer(`
+ {
+ http_port 9080
+ https_port 9443
+ }
+ localhost:9443
+ respond "Yahaha! You found me!"
+ `, "caddyfile")
+
+ tester.AssertRedirect("http://localhost:9080/", "https://localhost/", http.StatusPermanentRedirect)
+}