aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorredshiftzero <jen@freedom.press>2019-04-15 22:46:57 -0700
committerPaul Kehrer <paul.l.kehrer@gmail.com>2019-04-16 13:46:57 +0800
commit276f5c49d55b5ff7694f2f35ae538282ec360e7d (patch)
tree9694366e1abaa7a8ab5e693b55d3221e3454c015 /tests
parent19db013fa66fb4eb38e105e7fd46599aad51bf30 (diff)
downloadcryptography-276f5c49d55b5ff7694f2f35ae538282ec360e7d.tar.gz
cryptography-276f5c49d55b5ff7694f2f35ae538282ec360e7d.tar.bz2
cryptography-276f5c49d55b5ff7694f2f35ae538282ec360e7d.zip
4810 bugfix: avoid UnicodeEncodeError on python 2 (#4846)
* test: regression test for UnicodeEncodeError in x509 name in #4810 added utf8 encoding at the top of the file due to PEP 263 * bugfix: #4810 resolve UnicodeEncodeError in x509 name
Diffstat (limited to 'tests')
-rw-r--r--tests/x509/test_x509.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py
index afca9c5b..a4cd70bc 100644
--- a/tests/x509/test_x509.py
+++ b/tests/x509/test_x509.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
@@ -4128,13 +4129,27 @@ class TestName(object):
name2 = x509.Name([x509.RelativeDistinguishedName([rdn1, rdn2])])
assert name2.rdns == [x509.RelativeDistinguishedName([rdn1, rdn2])]
- def test_repr(self):
+ @pytest.mark.parametrize(
+ ("common_name", "org_name", "expected_repr"),
+ [
+ (
+ u'cryptography.io',
+ u'PyCA',
+ "<Name(CN=cryptography.io,O=PyCA)>",
+ ),
+ (
+ u'Certificación',
+ u'Certificación',
+ "<Name(CN=Certificación,O=Certificación)>",
+ ),
+ ])
+ def test_repr(self, common_name, org_name, expected_repr):
name = x509.Name([
- x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
- x509.NameAttribute(NameOID.ORGANIZATION_NAME, u'PyCA'),
+ x509.NameAttribute(NameOID.COMMON_NAME, common_name),
+ x509.NameAttribute(NameOID.ORGANIZATION_NAME, org_name),
])
- assert repr(name) == "<Name(CN=cryptography.io,O=PyCA)>"
+ assert repr(name) == expected_repr
def test_rfc4514_string(self):
n = x509.Name([