@@ -15,10 +15,13 @@ import (
1515 configv1 "github.com/openshift/api/config/v1"
1616 fakeconfigclientv1 "github.com/openshift/client-go/config/clientset/versioned/fake"
1717 "github.com/openshift/library-go/pkg/crypto"
18+
1819 corev1 "k8s.io/api/core/v1"
1920 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2021 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2122 "k8s.io/apimachinery/pkg/runtime"
23+
24+ "github.com/google/go-cmp/cmp"
2225)
2326
2427// makeGenericOperatorConfigYAML generates a GenericOperatorConfig YAML string
@@ -262,18 +265,10 @@ func validateGenericOperatorConfigTLSInjected(modified *corev1.ConfigMap, fieldN
262265 return fmt .Errorf ("servingInfo.cipherSuites not found" )
263266 }
264267
265- // Verify expected ciphers are present
266- for _ , expectedCipher := range expectedCiphers {
267- found := false
268- for _ , cipher := range cipherSuites {
269- if cipher == expectedCipher {
270- found = true
271- break
272- }
273- }
274- if ! found {
275- return fmt .Errorf ("expected cipher %s not found in cipherSuites: %v" , expectedCipher , cipherSuites )
276- }
268+ sort .Strings (expectedCiphers )
269+ sort .Strings (cipherSuites )
270+ if diff := cmp .Diff (expectedCiphers , cipherSuites ); diff != "" {
271+ return fmt .Errorf ("list of ciphers mismatch (-want +got):\n %s" , diff )
277272 }
278273
279274 return nil
@@ -523,11 +518,8 @@ servingInfo:
523518 apiServer : makeAPIServerConfig (withCustomTLSProfile (testOpenSSLCipherSuitesReversed , configv1 .VersionTLS13 )),
524519 expectError : false ,
525520 validateConfigMap : func (t * testing.T , original , modified * corev1.ConfigMap ) {
526- // Validate through pure string comparison
527- originalData := original .Data [genericOperatorConfigCMKey ]
528- modifiedData := modified .Data [genericOperatorConfigCMKey ]
529- if originalData != modifiedData {
530- t .Errorf ("ConfigMap data was modified when it should not have been.\n Original:\n %s\n Modified:\n %s" , originalData , modifiedData )
521+ if diff := cmp .Diff (original .Data [genericOperatorConfigCMKey ], modified .Data [genericOperatorConfigCMKey ]); diff != "" {
522+ t .Errorf ("ConfigMap YAML mismatch (-want +got):\n %s" , diff )
531523 }
532524 },
533525 },
0 commit comments