aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_x509.py
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2015-07-01 22:46:03 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2015-07-18 21:52:27 -0500
commitb3ed4849b632835f73e059d605738559c6839c03 (patch)
tree983e5aa9c8c03d4b07fd7832c187822322c8a1d4 /tests/test_x509.py
parent9bbfcea022820e9783e22f5a8f1fe959c9b245eb (diff)
downloadcryptography-b3ed4849b632835f73e059d605738559c6839c03.tar.gz
cryptography-b3ed4849b632835f73e059d605738559c6839c03.tar.bz2
cryptography-b3ed4849b632835f73e059d605738559c6839c03.zip
Make the CertificateBuilder interface more like the CSRBuilder
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r--tests/test_x509.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 92f40473..7719833c 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -787,33 +787,35 @@ class TestRSACertificateRequest(object):
backend=backend,
)
- builder = x509.CertificateBuilder()
- builder.set_version(x509.Version.v3)
- builder.set_serial_number(777)
- builder.set_issuer_name(x509.Name([
+ not_valid_before = datetime.datetime(2002, 1, 1, 12, 1)
+ not_valid_after = datetime.datetime(2030, 12, 31, 8, 30)
+
+ builder = x509.CertificateBuilder().version(
+ x509.Version.v3
+ ).serial_number(
+ 777
+ ).issuer_name(x509.Name([
x509.NameAttribute(x509.OID_COUNTRY_NAME, 'US'),
x509.NameAttribute(x509.OID_STATE_OR_PROVINCE_NAME, 'Texas'),
x509.NameAttribute(x509.OID_LOCALITY_NAME, 'Austin'),
x509.NameAttribute(x509.OID_ORGANIZATION_NAME, 'PyCA'),
x509.NameAttribute(x509.OID_COMMON_NAME, 'cryptography.io'),
- ]))
- builder.set_subject_name(x509.Name([
+ ])).subject_name(x509.Name([
x509.NameAttribute(x509.OID_COUNTRY_NAME, 'US'),
x509.NameAttribute(x509.OID_STATE_OR_PROVINCE_NAME, 'Texas'),
x509.NameAttribute(x509.OID_LOCALITY_NAME, 'Austin'),
x509.NameAttribute(x509.OID_ORGANIZATION_NAME, 'PyCA'),
x509.NameAttribute(x509.OID_COMMON_NAME, 'cryptography.io'),
- ]))
- builder.set_public_key(subject_private_key.public_key())
- builder.add_extension(x509.Extension(
- x509.OID_BASIC_CONSTRAINTS,
- True,
- x509.BasicConstraints(False, None),
- ))
- not_valid_before = datetime.datetime(2002, 1, 1, 12, 1)
- not_valid_after = datetime.datetime(2030, 12, 31, 8, 30)
- builder.set_not_valid_before(not_valid_before)
- builder.set_not_valid_after(not_valid_after)
+ ])).public_key(
+ subject_private_key.public_key()
+ ).add_extension(
+ x509.BasicConstraints(False, None), True,
+ ).not_valid_before(
+ not_valid_before
+ ).not_valid_after(
+ not_valid_after
+ )
+
cert = builder.sign(backend, issuer_private_key, hashes.SHA1())
assert cert.version is x509.Version.v3