@@ -248,7 +248,7 @@ func TestApplyTLSFlags(t *testing.T) {
248248 expectErr bool
249249 errorContains string
250250 expectedMinVer uint16
251- expectedCiphers [] string
251+ expectedCipherCount int
252252 }{
253253 {
254254 name : "valid min version override" ,
@@ -264,7 +264,7 @@ func TestApplyTLSFlags(t *testing.T) {
264264 name : "valid cipher suite override" ,
265265 cipherSuites : "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" ,
266266 expectedMinVer : tls .VersionTLS12 ,
267- expectedCiphers : [] string { "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" , "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" } ,
267+ expectedCipherCount : 2 ,
268268 },
269269 {
270270 name : "invalid min version" ,
@@ -283,7 +283,7 @@ func TestApplyTLSFlags(t *testing.T) {
283283 minVersion : "VersionTLS12" ,
284284 cipherSuites : "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ,
285285 expectedMinVer : tls .VersionTLS12 ,
286- expectedCiphers : [] string { "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" } ,
286+ expectedCipherCount : 1 ,
287287 },
288288 {
289289 name : "empty strings are no-ops" ,
@@ -296,7 +296,7 @@ func TestApplyTLSFlags(t *testing.T) {
296296 minVersion : "VersionTLS12" ,
297297 cipherSuites : "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" ,
298298 expectedMinVer : tls .VersionTLS12 ,
299- expectedCiphers : [] string { "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" } ,
299+ expectedCipherCount : 1 ,
300300 },
301301 }
302302
@@ -324,12 +324,9 @@ func TestApplyTLSFlags(t *testing.T) {
324324 t .Errorf ("expected TLSMinVersion %d, got %d" , tt .expectedMinVer , opts .TLSMinVersion )
325325 }
326326
327- if len (tt .expectedCiphers ) > 0 {
328- if len (opts .CipherSuites ) != len (tt .expectedCiphers ) {
329- t .Errorf ("expected %d cipher suites, got %d" , len (tt .expectedCiphers ), len (opts .CipherSuites ))
330- }
331- if len (opts .cipherSuiteIDs ) != len (tt .expectedCiphers ) {
332- t .Errorf ("expected %d parsed cipher IDs, got %d" , len (tt .expectedCiphers ), len (opts .cipherSuiteIDs ))
327+ if tt .expectedCipherCount > 0 {
328+ if len (opts .cipherSuiteIDs ) != tt .expectedCipherCount {
329+ t .Errorf ("expected %d parsed cipher IDs, got %d" , tt .expectedCipherCount , len (opts .cipherSuiteIDs ))
333330 }
334331 }
335332 })
@@ -340,7 +337,7 @@ func TestApplyTLSFlags_OverridesConfigFile(t *testing.T) {
340337 opts := NewGRPCServerOptions ()
341338 // Simulate config file values
342339 opts .TLSMinVersion = tls .VersionTLS12
343- opts .CipherSuites = [] string { "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" }
340+ opts .CipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
344341
345342 // Flags override
346343 err := opts .ApplyTLSFlags ("VersionTLS13" ,
@@ -352,9 +349,6 @@ func TestApplyTLSFlags_OverridesConfigFile(t *testing.T) {
352349 if opts .TLSMinVersion != tls .VersionTLS13 {
353350 t .Errorf ("expected TLSMinVersion TLS 1.3, got %d" , opts .TLSMinVersion )
354351 }
355- if len (opts .CipherSuites ) != 2 {
356- t .Errorf ("expected 2 cipher suites, got %d" , len (opts .CipherSuites ))
357- }
358352 if len (opts .cipherSuiteIDs ) != 2 {
359353 t .Errorf ("expected 2 parsed cipher IDs, got %d" , len (opts .cipherSuiteIDs ))
360354 }
0 commit comments