summaryrefslogtreecommitdiff
path: root/caddytest/caddytest.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-12-10 14:36:46 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2020-12-10 14:36:46 -0700
commit63bda6a0dc97e02d32865c31b5e46d2ead86ac7b (patch)
tree0b7124517527cf6487ba65d685f1960c081d2d1f /caddytest/caddytest.go
parentb8a799df9f58cf3ccc2577a37c2b561d2a3e72bd (diff)
caddyhttp: Clean up internal auto-HTTPS redirect code
Refactor redirect route creation into own function. Improve condition for appending port. Fixes a bug manifested through new test case: TestAutoHTTPRedirectsWithHTTPListenerFirstInAddresses
Diffstat (limited to 'caddytest/caddytest.go')
-rw-r--r--caddytest/caddytest.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/caddytest/caddytest.go b/caddytest/caddytest.go
index d3c70b6..5387da7 100644
--- a/caddytest/caddytest.go
+++ b/caddytest/caddytest.go
@@ -314,9 +314,13 @@ func (tc *Tester) AssertRedirect(requestURI string, expectedToLocation string, e
if err != nil {
tc.t.Errorf("requesting \"%s\" expected location: \"%s\" but got error: %s", requestURI, expectedToLocation, err)
}
-
- if expectedToLocation != loc.String() {
- tc.t.Errorf("requesting \"%s\" expected location: \"%s\" but got \"%s\"", requestURI, expectedToLocation, loc.String())
+ if loc == nil && expectedToLocation != "" {
+ tc.t.Errorf("requesting \"%s\" expected a Location header, but didn't get one", requestURI)
+ }
+ if loc != nil {
+ if expectedToLocation != loc.String() {
+ tc.t.Errorf("requesting \"%s\" expected location: \"%s\" but got \"%s\"", requestURI, expectedToLocation, loc.String())
+ }
}
return resp