Skip to content

Commit

Permalink
Fix tls setup code in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed Mar 1, 2021
1 parent 1e6dbb1 commit 6d9747a
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,21 @@ func (c *caddyTestServer) server() *caddyhttp.Server {

// create the routes
var routes caddyhttp.RouteList
if c.tls {
// cheap hack for our tests to get TLS certs for the hostnames that
// it needs TLS certs for: create an empty route with a single host
// matcher for that hostname, and auto HTTPS will do the rest
hostMatcherJSON, err := json.Marshal(caddyhttp.MatchHost{host})
if err != nil {
panic(err)
}
matchersRaw := caddyhttp.RawMatcherSets{
caddy.ModuleMap{"host": hostMatcherJSON},
}
routes = append(routes, caddyhttp.Route{MatcherSetsRaw: matchersRaw})
}
if c.proxyHandler != nil {
if host != "" {
if c.tls {
// cheap hack for our tests to get TLS certs for the hostnames that
// it needs TLS certs for: create an empty route with a single host
// matcher for that hostname, and auto HTTPS will do the rest
hostMatcherJSON, err := json.Marshal(caddyhttp.MatchHost{host})
if err != nil {
panic(err)
}
matchersRaw := caddyhttp.RawMatcherSets{
caddy.ModuleMap{"host": hostMatcherJSON},
}
routes = append(routes, caddyhttp.Route{MatcherSetsRaw: matchersRaw})
}

// tell the proxy which hostname to serve the proxy on; this must
// be distinct from the host matcher, since the proxy basically
// does its own host matching
Expand Down

0 comments on commit 6d9747a

Please sign in to comment.