mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 04:32:37 +00:00
Merge pull request #48104 from liggitt/tls-copy-bug
Automatic merge from submit-queue
Fix tls config copy in dial test
Fixes a bug introduced in 0d42da1b93 (diff-1748ffb7995a87b1f6bfd534dc5a51abL99)
that broke the mutation test check (it was checking an object against itself)
This commit is contained in:
@@ -21,6 +21,7 @@ go_test(
|
|||||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||||
"//vendor/github.com/stretchr/testify/require:go_default_library",
|
"//vendor/github.com/stretchr/testify/require:go_default_library",
|
||||||
"//vendor/golang.org/x/net/websocket:go_default_library",
|
"//vendor/golang.org/x/net/websocket:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/httpstream:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/httpstream:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
||||||
],
|
],
|
||||||
|
@@ -28,6 +28,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/util/diff"
|
||||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
utilnet "k8s.io/apimachinery/pkg/util/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -96,7 +97,10 @@ func TestDialURL(t *testing.T) {
|
|||||||
ts.TLS = &tls.Config{Certificates: []tls.Certificate{cert}}
|
ts.TLS = &tls.Config{Certificates: []tls.Certificate{cert}}
|
||||||
ts.StartTLS()
|
ts.StartTLS()
|
||||||
|
|
||||||
tlsConfigCopy := tc.TLSConfig
|
// Make a copy of the config
|
||||||
|
tlsConfigCopy := tc.TLSConfig.Clone()
|
||||||
|
// Clone() mutates the receiver (!), so also call it on the copy
|
||||||
|
tlsConfigCopy.Clone()
|
||||||
transport := &http.Transport{
|
transport := &http.Transport{
|
||||||
Dial: tc.Dial,
|
Dial: tc.Dial,
|
||||||
TLSClientConfig: tlsConfigCopy,
|
TLSClientConfig: tlsConfigCopy,
|
||||||
@@ -125,7 +129,7 @@ func TestDialURL(t *testing.T) {
|
|||||||
|
|
||||||
// Make sure dialing doesn't mutate the transport's TLSConfig
|
// Make sure dialing doesn't mutate the transport's TLSConfig
|
||||||
if !reflect.DeepEqual(tc.TLSConfig, tlsConfigCopy) {
|
if !reflect.DeepEqual(tc.TLSConfig, tlsConfigCopy) {
|
||||||
t.Errorf("%s: transport's copy of TLSConfig was mutated\n%#v\n\n%#v", k, tc.TLSConfig, tlsConfigCopy)
|
t.Errorf("%s: transport's copy of TLSConfig was mutated\n%s", k, diff.ObjectReflectDiff(tc.TLSConfig, tlsConfigCopy))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user