aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChelsea Winfree <chelsea.winfree@gmail.com>2016-06-02 21:15:54 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2016-06-02 21:15:54 -0700
commite295f3ab615775c3549b7bc2e051af5cff801619 (patch)
tree29b7faa37c505eb9493bb2d30cd97a731ae81351 /tests
parent57515157fc0ecc0dd661dea523d1f1346c547c0c (diff)
downloadcryptography-e295f3ab615775c3549b7bc2e051af5cff801619.tar.gz
cryptography-e295f3ab615775c3549b7bc2e051af5cff801619.tar.bz2
cryptography-e295f3ab615775c3549b7bc2e051af5cff801619.zip
Add alias for Certificate serial as serial number (#2950)
* Add alias for Certificate serial as serial number * Adding deprecation to utils * Now with catch warnings and proper vers
Diffstat (limited to 'tests')
-rw-r--r--tests/test_x509.py35
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index aaeefae9..ebe6dc50 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -8,6 +8,7 @@ import binascii
import datetime
import ipaddress
import os
+import warnings
from pyasn1.codec.der import decoder
@@ -486,11 +487,35 @@ class TestRSACertificate(object):
backend
)
assert isinstance(cert, x509.Certificate)
- assert cert.serial == 11559813051657483483
+ assert cert.serial_number == 11559813051657483483
fingerprint = binascii.hexlify(cert.fingerprint(hashes.SHA1()))
assert fingerprint == b"2b619ed04bfc9c3b08eb677d272192286a0947a8"
assert isinstance(cert.signature_hash_algorithm, hashes.SHA1)
+ def test_cert_serial_number(self, backend):
+ cert = _load_cert(
+ os.path.join("x509", "PKITS_data", "certs", "GoodCACert.crt"),
+ x509.load_der_x509_certificate,
+ backend
+ )
+
+ with warnings.catch_warnings():
+ warnings.simplefilter("always", utils.DeprecatedIn10)
+ assert cert.serial == 2
+ assert cert.serial_number == 2
+
+ def test_cert_serial_warning(self, backend):
+ cert = _load_cert(
+ os.path.join("x509", "PKITS_data", "certs", "GoodCACert.crt"),
+ x509.load_der_x509_certificate,
+ backend
+ )
+
+ with warnings.catch_warnings():
+ warnings.simplefilter("always", utils.DeprecatedIn10)
+ with pytest.deprecated_call():
+ cert.serial
+
def test_load_der_cert(self, backend):
cert = _load_cert(
os.path.join("x509", "PKITS_data", "certs", "GoodCACert.crt"),
@@ -498,7 +523,7 @@ class TestRSACertificate(object):
backend
)
assert isinstance(cert, x509.Certificate)
- assert cert.serial == 2
+ assert cert.serial_number == 2
fingerprint = binascii.hexlify(cert.fingerprint(hashes.SHA1()))
assert fingerprint == b"6f49779533d565e8b7c1062503eab41492c38e4d"
assert isinstance(cert.signature_hash_algorithm, hashes.SHA256)
@@ -734,7 +759,7 @@ class TestRSACertificate(object):
assert cert.not_valid_before == datetime.datetime(2010, 1, 1, 8, 30)
assert cert.not_valid_after == datetime.datetime(2030, 12, 31, 8, 30)
- assert cert.serial == 2
+ assert cert.serial_number == 2
public_key = cert.public_key()
assert isinstance(public_key, rsa.RSAPublicKey)
assert cert.version is x509.Version.v3
@@ -909,7 +934,7 @@ class TestRSACertificate(object):
# We should recover what we had to start with.
assert cert.not_valid_before == datetime.datetime(2010, 1, 1, 8, 30)
assert cert.not_valid_after == datetime.datetime(2030, 12, 31, 8, 30)
- assert cert.serial == 2
+ assert cert.serial_number == 2
public_key = cert.public_key()
assert isinstance(public_key, rsa.RSAPublicKey)
assert cert.version is x509.Version.v3
@@ -932,7 +957,7 @@ class TestRSACertificate(object):
# We should recover what we had to start with.
assert cert.not_valid_before == datetime.datetime(2010, 1, 1, 8, 30)
assert cert.not_valid_after == datetime.datetime(2030, 12, 31, 8, 30)
- assert cert.serial == 2
+ assert cert.serial_number == 2
public_key = cert.public_key()
assert isinstance(public_key, rsa.RSAPublicKey)
assert cert.version is x509.Version.v3