aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat
diff options
context:
space:
mode:
authorGlyph <glyph@twistedmatrix.com>2015-06-30 16:46:29 -0700
committerGlyph <glyph@twistedmatrix.com>2015-06-30 16:46:29 -0700
commitb18fc3912682d39ba5a4addfab963e50736e689c (patch)
treeaf8b7af1bf8ba2f5158202051f9857dbc340e903 /tests/hazmat
parentfa40f9f1b42b27d0f0e3f7581cf8d1997e36f0b0 (diff)
downloadcryptography-b18fc3912682d39ba5a4addfab963e50736e689c.tar.gz
cryptography-b18fc3912682d39ba5a4addfab963e50736e689c.tar.bz2
cryptography-b18fc3912682d39ba5a4addfab963e50736e689c.zip
test libressl when there is no libressl
Diffstat (limited to 'tests/hazmat')
-rw-r--r--tests/hazmat/bindings/test_openssl.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py
index ff8bcca6..f3f2eaf4 100644
--- a/tests/hazmat/bindings/test_openssl.py
+++ b/tests/hazmat/bindings/test_openssl.py
@@ -11,6 +11,20 @@ import pytest
from cryptography.hazmat.bindings.openssl.binding import Binding
+def skip_if_libre_ssl(openssl_version):
+ if b'LibreSSL' in openssl_version:
+ pytest.skip("LibreSSL hard-codes RAND_bytes to use arc4random.")
+
+
+class TestLibreSkip(object):
+ def test_skip_no(self):
+ assert skip_if_libre_ssl(b"OpenSSL 0.9.8zf 19 Mar 2015") is None
+
+ def test_skip_yes(self):
+ with pytest.raises(pytest.skip.Exception):
+ skip_if_libre_ssl(b"LibreSSL 2.1.6")
+
+
class TestOpenSSL(object):
def test_binding_loads(self):
binding = Binding()
@@ -96,8 +110,7 @@ class TestOpenSSL(object):
def test_actual_osrandom_bytes(self, monkeypatch):
b = Binding()
- if b'LibreSSL' in b.ffi.string(b.lib.OPENSSL_VERSION_TEXT):
- pytest.skip("LibreSSL hard-codes RAND_bytes to use arc4random.")
+ skip_if_libre_ssl(b.ffi.string(b.lib.OPENSSL_VERSION_TEXT))
sample_data = (b"\x01\x02\x03\x04" * 4)
length = len(sample_data)