blob: 6f9c9d256794efd1235e305abfc9bfc61ee206d3 [file] [log] [blame]
Alex Gaynorbfc06bc2013-08-06 19:36:19 -07001# Licensed under the Apache License, Version 2.0 (the "License");
2# you may not use this file except in compliance with the License.
3# You may obtain a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10# implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
Alex Gaynora4da1d22013-10-16 19:07:33 -070014import pytest
15
Paul Kehrerdb37d0e2013-10-22 20:13:06 -050016from cryptography.bindings.openssl.backend import backend
Alex Gaynora4da1d22013-10-16 19:07:33 -070017from cryptography.primitives.block.ciphers import AES
18from cryptography.primitives.block.modes import CBC
Alex Gaynorc62e91f2013-08-06 19:25:52 -070019
20
Hynek Schlawack196515a2013-08-08 08:40:47 +020021class TestOpenSSL(object):
Paul Kehrerdb37d0e2013-10-22 20:13:06 -050022 def test_backend_exists(self):
23 assert backend
Paul Kehrer733404a2013-09-09 15:26:26 -050024
25 def test_openssl_version_text(self):
Paul Kehrerc1a218d2013-09-09 17:45:52 -050026 """
27 This test checks the value of OPENSSL_VERSION_TEXT.
Paul Kehrereb49db12013-09-09 17:12:29 -050028
29 Unfortunately, this define does not appear to have a
30 formal content definition, so for now we'll test to see
31 if it starts with OpenSSL as that appears to be true
32 for every OpenSSL.
33 """
Paul Kehrerdb37d0e2013-10-22 20:13:06 -050034 assert backend.openssl_version_text().startswith("OpenSSL")
Paul Kehrerdff22d42013-09-27 13:43:06 -050035
Paul Kehrerf2ce1ae2013-10-03 21:54:05 -050036 def test_supports_cipher(self):
Paul Kehrer14c3a352013-10-22 21:45:16 -050037 assert backend.ciphers.supported(None, None) is False
Alex Gaynora4da1d22013-10-16 19:07:33 -070038
39 def test_register_duplicate_cipher_adapter(self):
40 with pytest.raises(ValueError):
Paul Kehrer14c3a352013-10-22 21:45:16 -050041 backend.ciphers.register_cipher_adapter(AES, CBC, None)