@@ -10,6 +10,7 @@ import (
1010 "testing"
1111 "text/template"
1212
13+ "github.com/google/go-cmp/cmp"
1314 "sigs.k8s.io/yaml"
1415
1516 corev1 "k8s.io/api/core/v1"
@@ -258,18 +259,10 @@ func validateGenericOperatorConfigTLSInjected(modified *corev1.ConfigMap, fieldN
258259 return fmt .Errorf ("servingInfo.cipherSuites not found" )
259260 }
260261
261- // Verify expected ciphers are present
262- for _ , expectedCipher := range expectedCiphers {
263- found := false
264- for _ , cipher := range cipherSuites {
265- if cipher == expectedCipher {
266- found = true
267- break
268- }
269- }
270- if ! found {
271- return fmt .Errorf ("expected cipher %s not found in cipherSuites: %v" , expectedCipher , cipherSuites )
272- }
262+ sort .Strings (expectedCiphers )
263+ sort .Strings (cipherSuites )
264+ if diff := cmp .Diff (expectedCiphers , cipherSuites ); diff != "" {
265+ return fmt .Errorf ("list of ciphers mismatch (-want +got):\n %s" , diff )
273266 }
274267
275268 return nil
@@ -519,11 +512,8 @@ servingInfo:
519512 apiServer : makeAPIServerConfig (withCustomTLSProfile (testOpenSSLCipherSuitesReversed , configv1 .VersionTLS13 )),
520513 expectError : false ,
521514 validateConfigMap : func (t * testing.T , original , modified * corev1.ConfigMap ) {
522- // Validate through pure string comparison
523- originalData := original .Data [genericOperatorConfigCMKey ]
524- modifiedData := modified .Data [genericOperatorConfigCMKey ]
525- if originalData != modifiedData {
526- t .Errorf ("ConfigMap data was modified when it should not have been.\n Original:\n %s\n Modified:\n %s" , originalData , modifiedData )
515+ if diff := cmp .Diff (original .Data [genericOperatorConfigCMKey ], modified .Data [genericOperatorConfigCMKey ]); diff != "" {
516+ t .Errorf ("ConfigMap YAML mismatch (-want +got):\n %s" , diff )
527517 }
528518 },
529519 },
0 commit comments