From 40cf145ee6f3f33a67c6a89fa8721322689ecd75 Mon Sep 17 00:00:00 2001 From: Todd Beets Date: Fri, 15 Sep 2023 13:13:24 -0700 Subject: [PATCH] Map both 127.0.0.1 and 127.0.1.1 to localhost for HTTPS server host validate --- server/auth_callout_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/auth_callout_test.go b/server/auth_callout_test.go index 3d2089b0..49a44b7b 100644 --- a/server/auth_callout_test.go +++ b/server/auth_callout_test.go @@ -155,7 +155,14 @@ func (at *authTest) Connect(clientOptions ...nats.Option) *nats.Conn { func (at *authTest) WSNewClient(clientOptions ...nats.Option) (*nats.Conn, error) { pi := at.srv.PortsInfo(10 * time.Millisecond) require_False(at.t, pi == nil) - conn, err := nats.Connect(strings.Replace(pi.WebSocket[0], "127.0.0.1", "localhost", 1), clientOptions...) + + // test cert is SAN to DNS localhost, not local IPs returned by server in test environments + wssUrl := strings.Replace(pi.WebSocket[0], "127.0.0.1", "localhost", 1) + + // Seeing 127.0.1.1 in some test environments... + wssUrl = strings.Replace(wssUrl, "127.0.1.1", "localhost", 1) + + conn, err := nats.Connect(wssUrl, clientOptions...) if err != nil { return nil, err }