@@ -487,6 +487,24 @@ class TestContext:
487
487
Unit tests for `OpenSSL.SSL.Context`.
488
488
"""
489
489
490
+ @pytest .mark .parametrize (
491
+ "cipher_string" ,
492
+ [
493
+ b"hello world:TLS_AES_128_GCM_SHA256" ,
494
+ "hello world:TLS_AES_128_GCM_SHA256" ,
495
+ ],
496
+ )
497
+ def test_set_ciphersuites (self , context , cipher_string ):
498
+ """
499
+ `Context.set_ciphersuites` accepts both byte and unicode strings
500
+ for naming the ciphers which connections created with the context
501
+ object will be able to choose from.
502
+ """
503
+ context .set_ciphersuites (cipher_string )
504
+ conn = Connection (context , None )
505
+
506
+ assert "TLS_AES_128_GCM_SHA256" in conn .get_cipher_list ()
507
+
490
508
@pytest .mark .parametrize (
491
509
"cipher_string" ,
492
510
[b"hello world:AES128-SHA" , "hello world:AES128-SHA" ],
@@ -502,13 +520,16 @@ def test_set_cipher_list(self, context, cipher_string):
502
520
503
521
assert "AES128-SHA" in conn .get_cipher_list ()
504
522
505
- def test_set_cipher_list_wrong_type (self , context ):
523
+ @pytest .mark .parametrize (
524
+ "set_cipher_method" , ["set_cipher_list" , "set_ciphersuites" ]
525
+ )
526
+ def test_set_cipher_wrong_type (self , context , set_cipher_method ):
506
527
"""
507
- `Context.set_cipher_list` raises `TypeError` when passed a non-string
508
- argument.
528
+ `Context.set_cipher_list` and `Context.set_ciphersuites`
529
+ raises `TypeError` when passed a non-string argument.
509
530
"""
510
531
with pytest .raises (TypeError ):
511
- context . set_cipher_list (object ())
532
+ getattr ( context , set_cipher_method ) (object ())
512
533
513
534
@flaky .flaky
514
535
def test_set_cipher_list_no_cipher_match (self , context ):
0 commit comments