Fix unit tests.
This commit is contained in:
parent
c5234e9c61
commit
e414d0c8ea
1 changed files with 4 additions and 21 deletions
|
@ -181,13 +181,8 @@ func TestClient_GetServerTLSConfig_http(t *testing.T) {
|
||||||
t.Errorf("Client.GetClientTLSConfig() error = %v", err)
|
t.Errorf("Client.GetClientTLSConfig() error = %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
tr, err := getDefaultTransport(tlsConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("getDefaultTransport() error = %v", err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &http.Client{
|
return &http.Client{
|
||||||
Transport: tr,
|
Transport: getDefaultTransport(tlsConfig),
|
||||||
}
|
}
|
||||||
}, map[string]bool{srvTLS.URL: false, srvMTLS.URL: false}},
|
}, map[string]bool{srvTLS.URL: false, srvMTLS.URL: false}},
|
||||||
{"with no ClientCert", func(t *testing.T, client *Client, sr *api.SignResponse, pk crypto.PrivateKey) *http.Client {
|
{"with no ClientCert", func(t *testing.T, client *Client, sr *api.SignResponse, pk crypto.PrivateKey) *http.Client {
|
||||||
|
@ -199,14 +194,8 @@ func TestClient_GetServerTLSConfig_http(t *testing.T) {
|
||||||
tlsConfig := getDefaultTLSConfig(sr)
|
tlsConfig := getDefaultTLSConfig(sr)
|
||||||
tlsConfig.RootCAs = x509.NewCertPool()
|
tlsConfig.RootCAs = x509.NewCertPool()
|
||||||
tlsConfig.RootCAs.AddCert(root)
|
tlsConfig.RootCAs.AddCert(root)
|
||||||
|
|
||||||
tr, err := getDefaultTransport(tlsConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("getDefaultTransport() error = %v", err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &http.Client{
|
return &http.Client{
|
||||||
Transport: tr,
|
Transport: getDefaultTransport(tlsConfig),
|
||||||
}
|
}
|
||||||
}, map[string]bool{srvTLS.URL + "/no-cert": false, srvMTLS.URL + "/no-cert": true}},
|
}, map[string]bool{srvTLS.URL + "/no-cert": false, srvMTLS.URL + "/no-cert": true}},
|
||||||
{"fail with default", func(t *testing.T, client *Client, sr *api.SignResponse, pk crypto.PrivateKey) *http.Client {
|
{"fail with default", func(t *testing.T, client *Client, sr *api.SignResponse, pk crypto.PrivateKey) *http.Client {
|
||||||
|
@ -288,10 +277,7 @@ func TestClient_GetServerTLSConfig_renew(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Client.GetClientTLSConfig() error = %v", err)
|
t.Fatalf("Client.GetClientTLSConfig() error = %v", err)
|
||||||
}
|
}
|
||||||
tr2, err := getDefaultTransport(tlsConfig)
|
tr2 := getDefaultTransport(tlsConfig)
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("getDefaultTransport() error = %v", err)
|
|
||||||
}
|
|
||||||
// No client cert
|
// No client cert
|
||||||
root, err := RootCertificate(sr)
|
root, err := RootCertificate(sr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -300,10 +286,7 @@ func TestClient_GetServerTLSConfig_renew(t *testing.T) {
|
||||||
tlsConfig = getDefaultTLSConfig(sr)
|
tlsConfig = getDefaultTLSConfig(sr)
|
||||||
tlsConfig.RootCAs = x509.NewCertPool()
|
tlsConfig.RootCAs = x509.NewCertPool()
|
||||||
tlsConfig.RootCAs.AddCert(root)
|
tlsConfig.RootCAs.AddCert(root)
|
||||||
tr3, err := getDefaultTransport(tlsConfig)
|
tr3 := getDefaultTransport(tlsConfig)
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("getDefaultTransport() error = %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable keep alives to force TLS handshake
|
// Disable keep alives to force TLS handshake
|
||||||
tr1.DisableKeepAlives = true
|
tr1.DisableKeepAlives = true
|
||||||
|
|
Loading…
Reference in a new issue