summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2020-07-26 12:07:31 -0500
committerGitHub <noreply@github.com>2020-07-26 13:07:31 -0400
commitace8a92be9ab5f4b65d25191d25bb690be5e2338 (patch)
treeeb6b8621cb8e56bbfe15fbd690bd066fa8f1e170 /tests
parent442926c60cdf4343028e47d5bfd92d97b98e1429 (diff)
downloadcryptography-ace8a92be9ab5f4b65d25191d25bb690be5e2338.tar.gz
remove idna support finally (#5351)
* remove idna support finally * remove unused import
Diffstat (limited to 'tests')
-rw-r--r--tests/x509/test_x509_ext.py67
1 files changed, 10 insertions, 57 deletions
diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py
index b50a73895..a89c01dad 100644
--- a/tests/x509/test_x509_ext.py
+++ b/tests/x509/test_x509_ext.py
@@ -15,7 +15,7 @@ import pytest
import six
-from cryptography import utils, x509
+from cryptography import x509
from cryptography.hazmat.backends.interfaces import (
DSABackend,
EllipticCurveBackend,
@@ -26,7 +26,6 @@ from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.x509 import DNSName, NameConstraints, SubjectAlternativeName
from cryptography.x509.extensions import _key_identifier_from_public_key
-from cryptography.x509.general_name import _lazy_import_idna
from cryptography.x509.oid import (
AuthorityInformationAccessOID,
ExtendedKeyUsageOID,
@@ -56,17 +55,6 @@ 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)
@@ -1736,15 +1724,9 @@ class TestKeyUsageExtension(object):
class TestDNSName(object):
- def test_init_deprecated(self):
- pytest.importorskip("idna")
- with pytest.warns(utils.CryptographyDeprecationWarning):
- name = x509.DNSName(u".\xf5\xe4\xf6\xfc.example.com")
- assert name.value == u".xn--4ca7aey.example.com"
-
- with pytest.warns(utils.CryptographyDeprecationWarning):
- name = x509.DNSName(u"\xf5\xe4\xf6\xfc.example.com")
- assert name.value == u"xn--4ca7aey.example.com"
+ def test_non_a_label(self):
+ with pytest.raises(ValueError):
+ x509.DNSName(u".\xf5\xe4\xf6\xfc.example.com")
def test_init(self):
name = x509.DNSName(u"*.xn--4ca7aey.example.com")
@@ -1855,15 +1837,9 @@ class TestRFC822Name(object):
gn = x509.RFC822Name(u"administrator")
assert gn.value == u"administrator"
- def test_idna(self):
- pytest.importorskip("idna")
- with pytest.warns(utils.CryptographyDeprecationWarning):
- gn = x509.RFC822Name(u"email@em\xe5\xefl.com")
-
- assert gn.value == u"email@xn--eml-vla4c.com"
-
- gn2 = x509.RFC822Name(u"email@xn--eml-vla4c.com")
- assert gn2.value == u"email@xn--eml-vla4c.com"
+ def test_non_a_label(self):
+ with pytest.raises(ValueError):
+ x509.RFC822Name(u"email@em\xe5\xefl.com")
def test_hash(self):
g1 = x509.RFC822Name(u"email@host.com")
@@ -1895,39 +1871,16 @@ class TestUniformResourceIdentifier(object):
gn = x509.UniformResourceIdentifier(u"singlelabel:443/test")
assert gn.value == u"singlelabel:443/test"
- def test_idna_no_port(self):
- pytest.importorskip("idna")
- with pytest.warns(utils.CryptographyDeprecationWarning):
- gn = x509.UniformResourceIdentifier(
+ def test_non_a_label(self):
+ with pytest.raises(ValueError):
+ x509.UniformResourceIdentifier(
u"http://\u043f\u044b\u043a\u0430.cryptography"
)
- assert gn.value == u"http://xn--80ato2c.cryptography"
-
- def test_idna_with_port(self):
- pytest.importorskip("idna")
- with pytest.warns(utils.CryptographyDeprecationWarning):
- gn = x509.UniformResourceIdentifier(
- u"gopher://\u043f\u044b\u043a\u0430.cryptography:70/some/path"
- )
-
- assert gn.value == (u"gopher://xn--80ato2c.cryptography:70/some/path")
-
def test_empty_hostname(self):
gn = x509.UniformResourceIdentifier(u"ldap:///some-nonsense")
assert gn.value == "ldap:///some-nonsense"
- def test_query_and_fragment(self):
- pytest.importorskip("idna")
- with pytest.warns(utils.CryptographyDeprecationWarning):
- gn = x509.UniformResourceIdentifier(
- u"ldap://\u043f\u044b\u043a\u0430.cryptography:90/path?query="
- u"true#somedata"
- )
- assert gn.value == (
- u"ldap://xn--80ato2c.cryptography:90/path?query=true#somedata"
- )
-
def test_hash(self):
g1 = x509.UniformResourceIdentifier(u"http://host.com")
g2 = x509.UniformResourceIdentifier(u"http://host.com")