diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2018-12-07 11:43:38 +0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2018-12-06 22:43:38 -0500 |
commit | 7e422821b9f800f5345c37011c510dc9e76f552c (patch) | |
tree | 684836bedeb4ae9d898a014068f1555cd25c58aa /tests/x509 | |
parent | fec719b60441b1e69bcca26446b8025bb69ee1fd (diff) | |
download | cryptography-7e422821b9f800f5345c37011c510dc9e76f552c.tar.gz cryptography-7e422821b9f800f5345c37011c510dc9e76f552c.tar.bz2 cryptography-7e422821b9f800f5345c37011c510dc9e76f552c.zip |
remove idna as a primary dependency (#4624)
* remove idna as a primary dependency
* empty commit
* dynamodb test fix (thanks to Matt Bullock)
* review feedback
Diffstat (limited to 'tests/x509')
-rw-r--r-- | tests/x509/test_x509_ext.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py index bfa37847..152db964 100644 --- a/tests/x509/test_x509_ext.py +++ b/tests/x509/test_x509_ext.py @@ -20,6 +20,7 @@ from cryptography.hazmat.backends.interfaces import ( from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import ec from cryptography.x509 import DNSName, NameConstraints, SubjectAlternativeName +from cryptography.x509.general_name import _lazy_import_idna from cryptography.x509.oid import ( AuthorityInformationAccessOID, ExtendedKeyUsageOID, ExtensionOID, NameOID, ObjectIdentifier @@ -44,6 +45,17 @@ def _make_certbuilder(private_key): ) +def test_lazy_idna_import(): + try: + __import__("idna") + pytest.skip("idna is installed") + except ImportError: + pass + + with pytest.raises(ImportError): + _lazy_import_idna() + + class TestExtension(object): def test_not_an_oid(self): bc = x509.BasicConstraints(ca=False, path_length=None) @@ -1661,10 +1673,8 @@ class TestKeyUsageExtension(object): class TestDNSName(object): - def test_init(self): - name = x509.DNSName(u"*.xn--4ca7aey.example.com") - assert name.value == u"*.xn--4ca7aey.example.com" - + def test_init_deprecated(self): + pytest.importorskip("idna") with pytest.warns(utils.DeprecatedIn21): name = x509.DNSName(u".\xf5\xe4\xf6\xfc.example.com") assert name.value == u".xn--4ca7aey.example.com" @@ -1673,6 +1683,10 @@ class TestDNSName(object): name = x509.DNSName(u"\xf5\xe4\xf6\xfc.example.com") assert name.value == u"xn--4ca7aey.example.com" + def test_init(self): + name = x509.DNSName(u"*.xn--4ca7aey.example.com") + assert name.value == u"*.xn--4ca7aey.example.com" + with pytest.raises(TypeError): x509.DNSName(1.3) @@ -1788,6 +1802,7 @@ class TestRFC822Name(object): assert gn.value == u"administrator" def test_idna(self): + pytest.importorskip("idna") with pytest.warns(utils.DeprecatedIn21): gn = x509.RFC822Name(u"email@em\xe5\xefl.com") @@ -1827,6 +1842,7 @@ class TestUniformResourceIdentifier(object): assert gn.value == u"singlelabel:443/test" def test_idna_no_port(self): + pytest.importorskip("idna") with pytest.warns(utils.DeprecatedIn21): gn = x509.UniformResourceIdentifier( u"http://\u043f\u044b\u043a\u0430.cryptography" @@ -1835,6 +1851,7 @@ class TestUniformResourceIdentifier(object): assert gn.value == u"http://xn--80ato2c.cryptography" def test_idna_with_port(self): + pytest.importorskip("idna") with pytest.warns(utils.DeprecatedIn21): gn = x509.UniformResourceIdentifier( u"gopher://\u043f\u044b\u043a\u0430.cryptography:70/some/path" @@ -1849,6 +1866,7 @@ class TestUniformResourceIdentifier(object): assert gn.value == "ldap:///some-nonsense" def test_query_and_fragment(self): + pytest.importorskip("idna") with pytest.warns(utils.DeprecatedIn21): gn = x509.UniformResourceIdentifier( u"ldap://\u043f\u044b\u043a\u0430.cryptography:90/path?query=" |