Skip to content

Commit

Permalink
Testcase added for TLS1.3 cipherlist handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Nowak committed Feb 5, 2024
1 parent 586a780 commit 6a15b4d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions tests/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,24 @@ class TestContext:
Unit tests for `OpenSSL.SSL.Context`.
"""

@pytest.mark.parametrize(
"cipher_string",
[
b"hello world:TLS_AES_128_GCM_SHA256",
"hello world:TLS_AES_128_GCM_SHA256",
],
)
def test_set_ciphersuites(self, context, cipher_string):
"""
`Context.set_ciphersuites` accepts both byte and unicode strings
for naming the ciphers which connections created with the context
object will be able to choose from.
"""
context.set_ciphersuites(cipher_string)
conn = Connection(context, None)

assert "TLS_AES_128_GCM_SHA256" in conn.get_cipher_list()

@pytest.mark.parametrize(
"cipher_string",
[b"hello world:AES128-SHA", "hello world:AES128-SHA"],
Expand All @@ -502,13 +520,16 @@ def test_set_cipher_list(self, context, cipher_string):

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

def test_set_cipher_list_wrong_type(self, context):
@pytest.mark.parametrize(
"set_cipher_method", ["set_cipher_list", "set_ciphersuites"]
)
def test_set_cipher_wrong_type(self, context, set_cipher_method):
"""
`Context.set_cipher_list` raises `TypeError` when passed a non-string
argument.
`Context.set_cipher_list` and `Context.set_ciphersuites`
raises `TypeError` when passed a non-string argument.
"""
with pytest.raises(TypeError):
context.set_cipher_list(object())
getattr(context, set_cipher_method)(object())

@flaky.flaky
def test_set_cipher_list_no_cipher_match(self, context):
Expand Down

0 comments on commit 6a15b4d

Please sign in to comment.