aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_x509.py
diff options
context:
space:
mode:
authorAndre Caron <andre.l.caron@gmail.com>2015-06-06 20:04:44 -0400
committerIan Cordasco <graffatcolmingov@gmail.com>2015-06-24 13:35:49 -0500
commit472fd6991e05735e00fdca7fbe2573a44fdabd17 (patch)
tree69b03b302645f3ca7e24306cb67a392dabbbaded /tests/test_x509.py
parentd259ee51abae5a35e34f16ad74bfb1c62aa433d7 (diff)
downloadcryptography-472fd6991e05735e00fdca7fbe2573a44fdabd17.tar.gz
cryptography-472fd6991e05735e00fdca7fbe2573a44fdabd17.tar.bz2
cryptography-472fd6991e05735e00fdca7fbe2573a44fdabd17.zip
Changes builder extension API.
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r--tests/test_x509.py45
1 files changed, 14 insertions, 31 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index aadbed02..663b83b2 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -707,11 +707,9 @@ class TestCertificateSigningRequestBuilder(object):
x509.NameAttribute(x509.OID_ORGANIZATION_NAME, 'PyCA'),
x509.NameAttribute(x509.OID_COMMON_NAME, 'cryptography.io'),
])
- ).add_extension(x509.Extension(
- x509.OID_BASIC_CONSTRAINTS,
- True,
- x509.BasicConstraints(True, 2),
- )).sign(
+ ).add_extension(
+ x509.BasicConstraints(True, 2), critical=True
+ ).sign(
backend, private_key, hashes.SHA1()
)
@@ -748,11 +746,9 @@ class TestCertificateSigningRequestBuilder(object):
x509.NameAttribute(x509.OID_ORGANIZATION_NAME, 'PyCA'),
x509.NameAttribute(x509.OID_COMMON_NAME, 'cryptography.io'),
])
- ).add_extension(x509.Extension(
- x509.OID_BASIC_CONSTRAINTS,
- True,
- x509.BasicConstraints(False, None),
- )).sign(
+ ).add_extension(
+ x509.BasicConstraints(False, None), critical=True,
+ ).sign(
backend, private_key, hashes.SHA1()
)
@@ -776,23 +772,12 @@ class TestCertificateSigningRequestBuilder(object):
def test_add_duplicate_extension(self, backend):
builder = x509.CertificateSigningRequestBuilder().add_extension(
- x509.Extension(
- x509.OID_BASIC_CONSTRAINTS,
- True,
- x509.BasicConstraints(True, 2),
- )
+ x509.BasicConstraints(True, 2), critical=True,
)
with pytest.raises(ValueError):
- builder.add_extension(x509.Extension(
- x509.OID_BASIC_CONSTRAINTS,
- True,
- x509.BasicConstraints(True, 2),
- ))
-
- def test_add_invalid_extension(self, backend):
- builder = x509.CertificateSigningRequestBuilder()
- with pytest.raises(TypeError):
- builder.add_extension('NotAnExtension')
+ builder.add_extension(
+ x509.BasicConstraints(True, 2), critical=True,
+ )
def test_set_invalid_subject(self, backend):
builder = x509.CertificateSigningRequestBuilder()
@@ -813,13 +798,11 @@ class TestCertificateSigningRequestBuilder(object):
x509.NameAttribute(x509.OID_ORGANIZATION_NAME, u'PyCA'),
x509.NameAttribute(x509.OID_COMMON_NAME, u'cryptography.io'),
])
- ).add_extension(x509.Extension(
- x509.ObjectIdentifier('1.2.3.4'),
- False,
- 'value',
- ))
+ )
with pytest.raises(ValueError):
- builder.sign(backend, private_key, hashes.SHA1())
+ builder.add_extension(
+ x509.AuthorityKeyIdentifier('keyid', None, None)
+ )
@pytest.mark.requires_backend_interface(interface=DSABackend)