diff options
Diffstat (limited to 'tests/test_ssl.py')
-rw-r--r-- | tests/test_ssl.py | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/tests/test_ssl.py b/tests/test_ssl.py index 38511a4..986463a 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -410,18 +410,31 @@ class TestContext(object): assert "AES128-SHA" in conn.get_cipher_list() - @pytest.mark.parametrize("cipher_list,error", [ - (object(), TypeError), - ("imaginary-cipher", Error), - ]) - def test_set_cipher_list_wrong_args(self, context, cipher_list, error): + def test_set_cipher_list_wrong_type(self, context): """ `Context.set_cipher_list` raises `TypeError` when passed a non-string - argument and raises `OpenSSL.SSL.Error` when passed an incorrect cipher - list string. + argument. """ - with pytest.raises(error): - context.set_cipher_list(cipher_list) + with pytest.raises(TypeError): + context.set_cipher_list(object()) + + def test_set_cipher_list_no_cipher_match(self, context): + """ + `Context.set_cipher_list` raises `OpenSSL.SSL.Error` with a + `"no cipher match"` reason string regardless of the TLS + version. + """ + with pytest.raises(Error) as excinfo: + context.set_cipher_list(b"imaginary-cipher") + assert excinfo.value.args == ( + [ + ( + 'SSL routines', + 'SSL_CTX_set_cipher_list', + 'no cipher match', + ), + ], + ) def test_load_client_ca(self, context, ca_file): """ |