aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2015-06-16 21:35:24 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2015-06-16 22:11:49 -0500
commita908d691490818aa03fbdb0d3f96448e8edbb8cf (patch)
tree47b69841764b395dac69ffafffd4f8703a0ea95e /tests
parent82fc376961182fb31193373c2d28bc5fe6dd22b4 (diff)
downloadcryptography-a908d691490818aa03fbdb0d3f96448e8edbb8cf.tar.gz
cryptography-a908d691490818aa03fbdb0d3f96448e8edbb8cf.tar.bz2
cryptography-a908d691490818aa03fbdb0d3f96448e8edbb8cf.zip
Conditionally construct the repr of NameAttributes
Diffstat (limited to 'tests')
-rw-r--r--tests/test_x509.py36
-rw-r--r--tests/test_x509_ext.py26
2 files changed, 43 insertions, 19 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 53ddeb84..547aa58e 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -10,6 +10,8 @@ import os
import pytest
+import six
+
from cryptography import x509
from cryptography.exceptions import UnsupportedAlgorithm
from cryptography.hazmat.backends.interfaces import (
@@ -825,10 +827,16 @@ class TestNameAttribute(object):
def test_repr(self):
na = x509.NameAttribute(x509.ObjectIdentifier('2.5.4.3'), u'value')
- assert repr(na) == (
- "<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName"
- ")>, value=u'value')>"
- )
+ if six.PY3:
+ assert repr(na) == (
+ "<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commo"
+ "nName)>, value='value')>"
+ )
+ else:
+ assert repr(na) == (
+ "<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commo"
+ "nName)>, value=u'value')>"
+ )
class TestObjectIdentifier(object):
@@ -879,9 +887,17 @@ class TestName(object):
x509.NameAttribute(x509.OID_ORGANIZATION_NAME, u'PyCA'),
])
- assert repr(name) == (
- "<Name([<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=com"
- "monName)>, value=u'cryptography.io')>, <NameAttribute(oid=<Object"
- "Identifier(oid=2.5.4.10, name=organizationName)>, value=u'PyCA')>"
- "])>"
- )
+ if six.PY3:
+ assert repr(name) == (
+ "<Name([<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name"
+ "=commonName)>, value='cryptography.io')>, <NameAttribute(oid="
+ "<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, valu"
+ "e='PyCA')>])>"
+ )
+ else:
+ assert repr(name) == (
+ "<Name([<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name"
+ "=commonName)>, value=u'cryptography.io')>, <NameAttribute(oid"
+ "=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, val"
+ "ue=u'PyCA')>])>"
+ )
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index de8aea98..d836164b 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -633,7 +633,7 @@ class TestAuthorityKeyIdentifier(object):
assert repr(aki) == (
"<AuthorityKeyIdentifier(key_identifier=b'digest', authority_"
"cert_issuer=[<DirectoryName(value=<Name([<NameAttribute(oid="
- "<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value=u'myC"
+ "<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value='myC"
"N')>])>)>], authority_cert_serial_number=1234)>"
)
else:
@@ -1050,10 +1050,18 @@ class TestDirectoryName(object):
def test_repr(self):
name = x509.Name([x509.NameAttribute(x509.OID_COMMON_NAME, u'value1')])
gn = x509.DirectoryName(x509.Name([name]))
- assert repr(gn) == (
- "<DirectoryName(value=<Name([<Name([<NameAttribute(oid=<ObjectIden"
- "tifier(oid=2.5.4.3, name=commonName)>, value=u'value1')>])>])>)>"
- )
+ if six.PY3:
+ assert repr(gn) == (
+ "<DirectoryName(value=<Name([<Name([<NameAttribute(oid=<Object"
+ "Identifier(oid=2.5.4.3, name=commonName)>, value='value1')>])"
+ ">])>)>"
+ )
+ else:
+ assert repr(gn) == (
+ "<DirectoryName(value=<Name([<Name([<NameAttribute(oid=<Object"
+ "Identifier(oid=2.5.4.3, name=commonName)>, value=u'value1')>]"
+ ")>])>)>"
+ )
def test_eq(self):
name = x509.Name([
@@ -2017,10 +2025,10 @@ class TestDistributionPoint(object):
assert repr(dp) == (
"<DistributionPoint(full_name=None, relative_name=<Name([<Name"
"Attribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)"
- ">, value=u'myCN')>])>, reasons=frozenset({<ReasonFlags.ca_com"
- "promise: 'cACompromise'>}), crl_issuer=[<DirectoryName(value="
- "<Name([<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name"
- "=commonName)>, value=u'Important CA')>])>)>])>"
+ ">, value='myCN')>])>, reasons=frozenset({<ReasonFlags.ca_comp"
+ "romise: 'cACompromise'>}), crl_issuer=[<DirectoryName(value=<"
+ "Name([<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name="
+ "commonName)>, value='Important CA')>])>)>])>"
)
else:
assert repr(dp) == (