Skip to content

Commit 8bd4e1b

Browse files
Henrywu573aojea
andcommitted
Update test/integration/serving/serving_test.go
Co-authored-by: Antonio Ojea <[email protected]>
1 parent 5a8d77a commit 8bd4e1b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/integration/serving/serving_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"crypto/x509"
2323
"fmt"
2424
"io"
25+
"net"
2526
"net/http"
2627
"os"
2728
"path"
@@ -382,8 +383,13 @@ users:
382383
if want, got := tt.wantSecureCode != nil, secureInfo != nil; want != got {
383384
t.Errorf("SecureServing enabled: expected=%v got=%v", want, got)
384385
} else if want {
385-
url := fmt.Sprintf("https://%s%s", secureInfo.Listener.Addr().String(), tt.path)
386-
url = strings.ReplaceAll(url, "[::]", "127.0.0.1") // switch to IPv4 because the self-signed cert does not support [::]
386+
// only interested on the port, because we are using always localhost
387+
_, port, err := net.SplitHostPort(secureInfo.Listener.Addr().String())
388+
if err != nil {
389+
t.Fatalf("could not get host and port from %s : %v", secureInfo.Listener.Addr().String(), err)
390+
}
391+
// use IPv4 because the self-signed cert does not support [::]
392+
url := fmt.Sprintf("https://127.0.0.1:%s%s", port, tt.path)
387393

388394
// read self-signed server cert disk
389395
pool := x509.NewCertPool()

0 commit comments

Comments
 (0)