diff options
author | Colin Watson <cjwatson@debian.org> | 2018-08-20 17:53:45 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2018-08-20 17:53:45 +0100 |
commit | 2105a515d749b74eef9a6bb6af008aa6a842e313 (patch) | |
tree | e1f3e72483f3d81c6f00a5c0abddb59a85ae47f2 /macaroonbakery/tests/test_client.py | |
parent | 4379a501141f75557e535f9c2ef3b58ef362259c (diff) |
New upstream version 1.1.4
Diffstat (limited to 'macaroonbakery/tests/test_client.py')
-rw-r--r-- | macaroonbakery/tests/test_client.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/macaroonbakery/tests/test_client.py b/macaroonbakery/tests/test_client.py index bfc7807..4061a8a 100644 --- a/macaroonbakery/tests/test_client.py +++ b/macaroonbakery/tests/test_client.py @@ -55,6 +55,41 @@ class TestClient(TestCase): finally: httpd.shutdown() + def test_cookie_domain_host_not_fqdn(self): + # See + # https://github.com/go-macaroon-bakery/py-macaroon-bakery/issues/53 + + b = new_bakery('loc', None, None) + + def handler(*args): + GetHandler(b, None, None, None, None, AGES, *args) + try: + httpd = HTTPServer(('', 0), handler) + thread = threading.Thread(target=httpd.serve_forever) + thread.start() + srv_macaroon = b.oven.macaroon( + version=bakery.LATEST_VERSION, expiry=AGES, + caveats=None, ops=[TEST_OP]) + self.assertEquals(srv_macaroon.macaroon.location, 'loc') + client = httpbakery.Client() + # Note: by using "localhost" instead of the presumably numeric address held + # in httpd.server_address, we're triggering the no-FQDN logic in the cookie + # code. + resp = requests.get( + url='http://localhost:' + str(httpd.server_address[1]), + cookies=client.cookies, auth=client.auth()) + resp.raise_for_status() + self.assertEquals(resp.text, 'done') + except httpbakery.BakeryException: + pass # interacion required exception is expected + finally: + httpd.shutdown() + + # the cookie has the .local domain appended + [cookie] = client.cookies + self.assertEqual(cookie.name, 'macaroon-test') + self.assertEqual(cookie.domain, 'localhost.local') + def test_single_party_with_header(self): b = new_bakery('loc', None, None) |