aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_x509.py
diff options
context:
space:
mode:
authorMajor Hayden <major@mhtx.net>2015-06-17 14:02:26 -0500
committerMajor Hayden <major@mhtx.net>2015-06-21 10:09:24 -0500
commitf315af2ae6e396431cd1ace953ae480f062b5ba5 (patch)
treef216d01ea3beb6daaa7a1280e58cd4b986d90623 /tests/test_x509.py
parentab94b90c077674031bda9c249c2b0eab5ddca5c4 (diff)
downloadcryptography-f315af2ae6e396431cd1ace953ae480f062b5ba5.tar.gz
cryptography-f315af2ae6e396431cd1ace953ae480f062b5ba5.tar.bz2
cryptography-f315af2ae6e396431cd1ace953ae480f062b5ba5.zip
Added a repr() method to x509._Certificate
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r--tests/test_x509.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 547aa58e..cf3499bf 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -450,6 +450,39 @@ class TestRSACertificate(object):
serialized = cert.public_bytes(encoding)
assert serialized == cert_bytes
+ def test_certificate_repr(self, backend):
+ cert = _load_cert(
+ os.path.join(
+ "x509", "cryptography.io.pem"
+ ),
+ x509.load_pem_x509_certificate,
+ backend
+ )
+ if six.PY3:
+ assert repr(cert) == (
+ "<Certificate(subject=<Name([<NameAttribute(oid=<ObjectIdentif"
+ "ier(oid=2.5.4.11, name=organizationalUnitName)>, value='GT487"
+ "42965')>, <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.11, "
+ "name=organizationalUnitName)>, value='See www.rapidssl.com/re"
+ "sources/cps (c)14')>, <NameAttribute(oid=<ObjectIdentifier(oi"
+ "d=2.5.4.11, name=organizationalUnitName)>, value='Domain Cont"
+ "rol Validated - RapidSSL(R)')>, <NameAttribute(oid=<ObjectIde"
+ "ntifier(oid=2.5.4.3, name=commonName)>, value='www.cryptograp"
+ "hy.io')>])>, ...)>"
+ )
+ else:
+ assert repr(cert) == (
+ "<Certificate(subject=<Name([<NameAttribute(oid=<ObjectIdentif"
+ "ier(oid=2.5.4.11, name=organizationalUnitName)>, value=u'GT48"
+ "742965')>, <NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.11,"
+ " name=organizationalUnitName)>, value=u'See www.rapidssl.com/"
+ "resources/cps (c)14')>, <NameAttribute(oid=<ObjectIdentifier("
+ "oid=2.5.4.11, name=organizationalUnitName)>, value=u'Domain C"
+ "ontrol Validated - RapidSSL(R)')>, <NameAttribute(oid=<Object"
+ "Identifier(oid=2.5.4.3, name=commonName)>, value=u'www.crypto"
+ "graphy.io')>])>, ...)>"
+ )
+
@pytest.mark.requires_backend_interface(interface=RSABackend)
@pytest.mark.requires_backend_interface(interface=X509Backend)