aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/hypothesis/__init__.py5
-rw-r--r--tests/hypothesis/test_fernet.py11
-rw-r--r--tests/test_x509.py24
3 files changed, 40 insertions, 0 deletions
diff --git a/tests/hypothesis/__init__.py b/tests/hypothesis/__init__.py
new file mode 100644
index 00000000..4b540884
--- /dev/null
+++ b/tests/hypothesis/__init__.py
@@ -0,0 +1,5 @@
+# This file is dual licensed under the terms of the Apache License, Version
+# 2.0, and the BSD License. See the LICENSE file in the root of this repository
+# for complete details.
+
+from __future__ import absolute_import, division, print_function
diff --git a/tests/hypothesis/test_fernet.py b/tests/hypothesis/test_fernet.py
new file mode 100644
index 00000000..fd243803
--- /dev/null
+++ b/tests/hypothesis/test_fernet.py
@@ -0,0 +1,11 @@
+from hypothesis import given
+from hypothesis.strategies import binary
+
+from cryptography.fernet import Fernet
+
+
+@given(binary())
+def test_fernet(data):
+ f = Fernet(Fernet.generate_key())
+ ct = f.encrypt(data)
+ assert f.decrypt(ct) == data
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 220e71a5..0c022df1 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -1601,6 +1601,30 @@ class TestCertificateBuilder(object):
decipher_only=False
)
+ @pytest.mark.requires_backend_interface(interface=RSABackend)
+ @pytest.mark.requires_backend_interface(interface=X509Backend)
+ def test_build_ca_request_with_path_length_none(self, backend):
+ private_key = RSA_KEY_2048.private_key(backend)
+
+ request = x509.CertificateSigningRequestBuilder().subject_name(
+ x509.Name([
+ x509.NameAttribute(NameOID.ORGANIZATION_NAME,
+ u'PyCA'),
+ ])
+ ).add_extension(
+ x509.BasicConstraints(ca=True, path_length=None), critical=True
+ ).sign(private_key, hashes.SHA1(), backend)
+
+ loaded_request = x509.load_pem_x509_csr(
+ request.public_bytes(encoding=serialization.Encoding.PEM), backend
+ )
+ subject = loaded_request.subject
+ assert isinstance(subject, x509.Name)
+ basic_constraints = request.extensions.get_extension_for_oid(
+ ExtensionOID.BASIC_CONSTRAINTS
+ )
+ assert basic_constraints.value.path_length is None
+
@pytest.mark.requires_backend_interface(interface=X509Backend)
class TestCertificateSigningRequestBuilder(object):