diff --git a/transport/http/server/server_test.go b/transport/http/server/server_test.go index d86f8e924..20c5f0f3b 100644 --- a/transport/http/server/server_test.go +++ b/transport/http/server/server_test.go @@ -527,20 +527,24 @@ func TestRunServer_MultipleTLS(t *testing.T) { t.Error(err) return } - resp, err = client.Get(fmt.Sprintf("https://127.0.0.1:%d", port)) + _, err = client.Get(fmt.Sprintf("https://127.0.0.1:%d", port)) // should fail, because it will be served with cert.pem if err == nil || strings.Contains(err.Error(), "bad certificate") { t.Error("expected to have 'bad certificate' error") return } - req, _ := http.NewRequest("GET", fmt.Sprintf("https://example.com:%d", port), nil) - OverrideHostTransport(client) + req, _ := http.NewRequest("GET", fmt.Sprintf("https://example.com:%d", port), http.NoBody) + overrideHostTransport(client) resp, err = client.Do(req) if err != nil { t.Error(err) return } + if resp.StatusCode != 200 { + t.Errorf("unexpected status code: %d", resp.StatusCode) + return + } cancel() if err = <-done; err != nil { @@ -548,9 +552,9 @@ func TestRunServer_MultipleTLS(t *testing.T) { } } -// OverrideHostTransport subtitutes the actual address that the request will +// overrideHostTransport subtitutes the actual address that the request will // connecto (overriding the dns resolution). -func OverrideHostTransport(client *http.Client) { +func overrideHostTransport(client *http.Client) { t := http.DefaultTransport.(*http.Transport).Clone() if client.Transport != nil { if tt, ok := client.Transport.(*http.Transport); ok { diff --git a/transport/http/server/tls_test.go b/transport/http/server/tls_test.go index d40f954c5..6fb7c3938 100644 --- a/transport/http/server/tls_test.go +++ b/transport/http/server/tls_test.go @@ -23,7 +23,7 @@ type certDef struct { } func (c certDef) Org() string { - if len(c.Prefix) == 0 { + if c.Prefix == "" { return "Acme Co" } return c.Prefix + " " + "Acme Co" @@ -84,9 +84,7 @@ func generateNamedCert(hostCert certDef) error { template.IPAddresses = append(template.IPAddresses, ip) } } - for _, dname := range hostCert.DNSNames { - template.DNSNames = append(template.DNSNames, dname) - } + template.DNSNames = append(template.DNSNames, hostCert.DNSNames...) template.IsCA = true template.KeyUsage |= x509.KeyUsageCertSign