aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-07-13 20:50:25 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2015-07-13 20:50:25 -0400
commit677c3d55cdbb332723fd1e0e5fe8829465d90c50 (patch)
tree0285d190e24aa0aab40a0eccc81958bea5724c42 /tests
parentb4c72cd7cf78ee0f031f28ab010bf2d303582294 (diff)
parente28d6c47eb73ab3d3297745873a25e0f6c0eae8e (diff)
downloadcryptography-677c3d55cdbb332723fd1e0e5fe8829465d90c50.tar.gz
cryptography-677c3d55cdbb332723fd1e0e5fe8829465d90c50.tar.bz2
cryptography-677c3d55cdbb332723fd1e0e5fe8829465d90c50.zip
Merge pull request #2149 from reaperhulk/better-uri
expand UniformResourceIdentifier to parse and internally IDNA encode
Diffstat (limited to 'tests')
-rw-r--r--tests/test_x509_ext.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index 84a40995..7b135828 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -1105,6 +1105,38 @@ class TestRFC822Name(object):
assert gn._encoded == b"email@xn--eml-vla4c.com"
+class TestUniformResourceIdentifier(object):
+ def test_no_parsed_hostname(self):
+ gn = x509.UniformResourceIdentifier(u"singlelabel")
+ assert gn.value == u"singlelabel"
+
+ def test_with_port(self):
+ gn = x509.UniformResourceIdentifier(u"singlelabel:443/test")
+ assert gn.value == u"singlelabel:443/test"
+
+ def test_idna_no_port(self):
+ gn = x509.UniformResourceIdentifier(
+ u"http://\u043f\u044b\u043a\u0430.cryptography"
+ )
+ assert gn.value == u"http://\u043f\u044b\u043a\u0430.cryptography"
+ assert gn._encoded == b"http://xn--80ato2c.cryptography"
+
+ def test_idna_with_port(self):
+ gn = x509.UniformResourceIdentifier(
+ u"gopher://\u043f\u044b\u043a\u0430.cryptography:70/some/path"
+ )
+ assert gn.value == (
+ u"gopher://\u043f\u044b\u043a\u0430.cryptography:70/some/path"
+ )
+ assert gn._encoded == b"gopher://xn--80ato2c.cryptography:70/some/path"
+
+ def test_query_and_fragment(self):
+ gn = x509.UniformResourceIdentifier(
+ u"ldap://cryptography:90/path?query=true#somedata"
+ )
+ assert gn.value == u"ldap://cryptography:90/path?query=true#somedata"
+
+
class TestRegisteredID(object):
def test_not_oid(self):
with pytest.raises(TypeError):