Fix unit tests in Go 1.16.

pull/499/head
Mariano Cano 3 years ago
parent 8ead310d24
commit 5be86691c1

@ -156,7 +156,7 @@ func TestBootstrap(t *testing.T) {
}
gotTR := got.client.GetTransport().(*http.Transport)
wantTR := tt.want.client.GetTransport().(*http.Transport)
if !reflect.DeepEqual(gotTR.TLSClientConfig.RootCAs, wantTR.TLSClientConfig.RootCAs) {
if !equalPools(gotTR.TLSClientConfig.RootCAs, wantTR.TLSClientConfig.RootCAs) {
t.Errorf("Bootstrap() certPool = %v, want %v", gotTR.TLSClientConfig.RootCAs, wantTR.TLSClientConfig.RootCAs)
}
}

@ -189,7 +189,7 @@ func TestLoadClient(t *testing.T) {
wantTransport := tt.want.Client.Transport.(*http.Transport)
if gotTransport.TLSClientConfig.GetClientCertificate == nil {
t.Error("LoadClient() transport does not define GetClientCertificate")
} else if !reflect.DeepEqual(got.CaURL, tt.want.CaURL) || !reflect.DeepEqual(gotTransport.TLSClientConfig.RootCAs, wantTransport.TLSClientConfig.RootCAs) {
} else if !reflect.DeepEqual(got.CaURL, tt.want.CaURL) || !reflect.DeepEqual(gotTransport.TLSClientConfig.RootCAs.Subjects(), wantTransport.TLSClientConfig.RootCAs.Subjects()) {
t.Errorf("LoadClient() = %#v, want %#v", got, tt.want)
} else {
crt, err := gotTransport.TLSClientConfig.GetClientCertificate(nil)

@ -149,7 +149,7 @@ func TestAddRootCA(t *testing.T) {
t.Errorf("AddRootCA() error = %v", err)
return
}
if !reflect.DeepEqual(ctx.Config, tt.want) {
if !reflect.DeepEqual(ctx.Config, tt.want) && !equalPools(ctx.Config.RootCAs, tt.want.RootCAs) {
t.Errorf("AddRootCA() = %v, want %v", ctx.Config, tt.want)
}
})
@ -181,7 +181,7 @@ func TestAddClientCA(t *testing.T) {
t.Errorf("AddClientCA() error = %v", err)
return
}
if !reflect.DeepEqual(ctx.Config, tt.want) {
if !reflect.DeepEqual(ctx.Config, tt.want) && !equalPools(ctx.Config.ClientCAs, tt.want.ClientCAs) {
t.Errorf("AddClientCA() = %v, want %v", ctx.Config, tt.want)
}
})
@ -235,7 +235,7 @@ func TestAddRootsToRootCAs(t *testing.T) {
t.Errorf("AddRootsToRootCAs() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(ctx.Config.RootCAs, tt.want.RootCAs) {
if !equalPools(ctx.Config.RootCAs, tt.want.RootCAs) {
t.Errorf("AddRootsToRootCAs() = %v, want %v", ctx.Config, tt.want)
}
})
@ -289,7 +289,7 @@ func TestAddRootsToClientCAs(t *testing.T) {
t.Errorf("AddRootsToClientCAs() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(ctx.Config.ClientCAs, tt.want.ClientCAs) {
if !equalPools(ctx.Config.ClientCAs, tt.want.ClientCAs) {
t.Errorf("AddRootsToClientCAs() = %v, want %v", ctx.Config, tt.want)
}
})
@ -471,7 +471,7 @@ func TestAddRootsToCAs(t *testing.T) {
t.Errorf("AddRootsToCAs() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(ctx.Config.RootCAs, tt.want.RootCAs) || !reflect.DeepEqual(ctx.Config.ClientCAs, tt.want.ClientCAs) {
if !equalPools(ctx.Config.RootCAs, tt.want.RootCAs) || !equalPools(ctx.Config.ClientCAs, tt.want.ClientCAs) {
t.Errorf("AddRootsToCAs() = %v, want %v", ctx.Config, tt.want)
}
})
@ -543,6 +543,9 @@ func TestAddFederationToCAs(t *testing.T) {
}
func equalPools(a, b *x509.CertPool) bool {
if reflect.DeepEqual(a, b) {
return true
}
subjects := a.Subjects()
sA := make([]string, len(subjects))
for i := range subjects {

Loading…
Cancel
Save