summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert JW Regeer <bertjw@regeer.org>2017-06-30 14:25:01 -0600
committerBert JW Regeer <bertjw@regeer.org>2017-06-30 15:06:24 -0600
commitf61b01656ff89d645e1a69616e914ee9559c5209 (patch)
tree0c01b14b5886333f764ffb455a3dbf912fa275de
parentc4cee625e5b0b0f410e22ca60f701eff98f288d0 (diff)
downloadwebob-f61b01656ff89d645e1a69616e914ee9559c5209.tar.gz
Add some IPv6 HTTP_HOST tests
-rw-r--r--tests/test_request.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_request.py b/tests/test_request.py
index 357a724..c444d61 100644
--- a/tests/test_request.py
+++ b/tests/test_request.py
@@ -1588,6 +1588,16 @@ class TestBaseRequest(object):
req = self._makeOne(environ)
assert req.domain == 'example.com'
+ def test_domain_with_ipv6(self):
+ environ = {'HTTP_HOST': '[2001:DB8::1]:6453'}
+ req = self._makeOne(environ)
+ assert req.domain == '[2001:DB8::1]'
+
+ def test_domain_with_ipv6_no_port(self):
+ environ = {'HTTP_HOST': '[2001:DB8::1]'}
+ req = self._makeOne(environ)
+ assert req.domain == '[2001:DB8::1]'
+
def test_encget_raises_without_default(self):
inst = self._makeOne({})
with pytest.raises(KeyError):
@@ -1926,6 +1936,18 @@ class TestLegacyRequest(object):
req = self._makeOne(environ)
assert req.host_port == '4333'
+ def test_host_port_ipv6(self):
+ environ = {'HTTP_HOST': '[2001:DB8::1]:6453'}
+ req = self._makeOne(environ)
+ assert req.host_port == '6453'
+
+ def test_host_port_ipv6(self):
+ environ = {'wsgi.url_scheme': 'https',
+ 'HTTP_HOST': '[2001:DB8::1]'
+ }
+ req = self._makeOne(environ)
+ assert req.host_port == '443'
+
def test_host_url_w_http_host_and_no_port(self):
environ = {'wsgi.url_scheme': 'http',
'HTTP_HOST': 'example.com',
@@ -1976,6 +1998,20 @@ class TestLegacyRequest(object):
req = self._makeOne(environ)
assert req.host_url == 'https://example.com:4333'
+ def test_host_url_http_ipv6_host(self):
+ environ = {'wsgi.url_scheme': 'https',
+ 'HTTP_HOST': '[2001:DB8::1]:6453'
+ }
+ req = self._makeOne(environ)
+ assert req.host_url == 'https://[2001:DB8::1]:6453'
+
+ def test_host_url_http_ipv6_host_no_port(self):
+ environ = {'wsgi.url_scheme': 'https',
+ 'HTTP_HOST': '[2001:DB8::1]'
+ }
+ req = self._makeOne(environ)
+ assert req.host_url == 'https://[2001:DB8::1]'
+
def test_application_url(self):
inst = self._blankOne('/%C3%AB')
inst.script_name = b'/\xc3\xab'