summaryrefslogtreecommitdiff
path: root/macaroonbakery/tests/test_utils.py
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2018-08-20 17:53:45 +0100
committerColin Watson <cjwatson@debian.org>2018-08-20 17:53:45 +0100
commit2105a515d749b74eef9a6bb6af008aa6a842e313 (patch)
treee1f3e72483f3d81c6f00a5c0abddb59a85ae47f2 /macaroonbakery/tests/test_utils.py
parent4379a501141f75557e535f9c2ef3b58ef362259c (diff)
New upstream version 1.1.4
Diffstat (limited to 'macaroonbakery/tests/test_utils.py')
-rw-r--r--macaroonbakery/tests/test_utils.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/macaroonbakery/tests/test_utils.py b/macaroonbakery/tests/test_utils.py
index 65edeb4..4ed3e81 100644
--- a/macaroonbakery/tests/test_utils.py
+++ b/macaroonbakery/tests/test_utils.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
# Copyright 2017 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.
@@ -26,6 +28,26 @@ class CookieTest(TestCase):
ValueError, cookie, 'http://example.com', 'test', 'value',
expires=timestamp)
+ def test_cookie_with_hostname_not_fqdn(self):
+ c = cookie('http://myhost', 'test', 'value')
+ self.assertEqual(c.domain, 'myhost.local')
+
+ def test_cookie_with_hostname_ipv4(self):
+ c = cookie('http://1.2.3.4', 'test', 'value')
+ self.assertEqual(c.domain, '1.2.3.4')
+
+ def test_cookie_with_hostname_ipv6(self):
+ c = cookie('http://[dead::beef]', 'test', 'value')
+ self.assertEqual(c.domain, 'dead::beef')
+
+ def test_cookie_with_hostname_like_ipv4(self):
+ c = cookie('http://1.2.3.4.com', 'test', 'value')
+ self.assertEqual(c.domain, '1.2.3.4.com')
+
+ def test_cookie_with_hostname_not_ascii(self):
+ c = cookie('http://κουλουράκι', 'test', 'value')
+ self.assertEqual(c.domain, 'κουλουράκι.local')
+
class TestB64Decode(TestCase):
def test_decode(self):