Skip to content

Commit 6a15b4d

Browse files
author
Wojciech Nowak
committed
Testcase added for TLS1.3 cipherlist handling
1 parent 586a780 commit 6a15b4d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

tests/test_ssl.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,24 @@ class TestContext:
487487
Unit tests for `OpenSSL.SSL.Context`.
488488
"""
489489

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+
490508
@pytest.mark.parametrize(
491509
"cipher_string",
492510
[b"hello world:AES128-SHA", "hello world:AES128-SHA"],
@@ -502,13 +520,16 @@ def test_set_cipher_list(self, context, cipher_string):
502520

503521
assert "AES128-SHA" in conn.get_cipher_list()
504522

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):
506527
"""
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.
509530
"""
510531
with pytest.raises(TypeError):
511-
context.set_cipher_list(object())
532+
getattr(context, set_cipher_method)(object())
512533

513534
@flaky.flaky
514535
def test_set_cipher_list_no_cipher_match(self, context):

0 commit comments

Comments
 (0)