summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2018-02-28 17:08:17 +0000
committerColin Watson <cjwatson@debian.org>2018-02-28 17:09:32 +0000
commit6afbd6cfb2ceae0444b1ad15f143117315c0b8e2 (patch)
tree294ffe7ca0d12231dfff2a3d8dd7011aaf824cbc
parentfa31bef2ea6d7c2207dec570119291fa83e6675d (diff)
parentd918563db4de954c3df719d06a31bdd3aec3a8fc (diff)
New upstream release (1.1.3)
-rw-r--r--debian/.git-dpm14
-rw-r--r--debian/changelog6
-rw-r--r--debian/control1
-rw-r--r--debian/patches/improve-unknown-interaction-mock.patch2
-rw-r--r--debian/patches/isolate-from-proxy.patch4
-rwxr-xr-xdocs/conf.py2
-rw-r--r--macaroonbakery/checkers/_checkers.py9
-rw-r--r--macaroonbakery/httpbakery/_browser.py5
-rw-r--r--macaroonbakery/httpbakery/_client.py7
-rw-r--r--macaroonbakery/tests/common.py4
-rw-r--r--macaroonbakery/tests/test_checkers.py3
-rw-r--r--macaroonbakery/tests/test_client.py5
-rw-r--r--macaroonbakery/tests/test_httpbakery.py16
-rw-r--r--macaroonbakery/tests/test_utils.py4
-rw-r--r--requirements.txt1
-rwxr-xr-xsetup.py3
16 files changed, 57 insertions, 29 deletions
diff --git a/debian/.git-dpm b/debian/.git-dpm
index 77259fe..ffca26b 100644
--- a/debian/.git-dpm
+++ b/debian/.git-dpm
@@ -1,11 +1,11 @@
# see git-dpm(1) from git-dpm package
-c1850c8a10886894255100fae185c450e800564a
-c1850c8a10886894255100fae185c450e800564a
-dfa331b7d67b5d89f2fdbe0406374810aaf33b57
-dfa331b7d67b5d89f2fdbe0406374810aaf33b57
-py-macaroon-bakery_1.1.2.orig.tar.gz
-62cbacb048ef5de21894228e3fa8934eae960591
-82228
+d918563db4de954c3df719d06a31bdd3aec3a8fc
+d918563db4de954c3df719d06a31bdd3aec3a8fc
+4379a501141f75557e535f9c2ef3b58ef362259c
+4379a501141f75557e535f9c2ef3b58ef362259c
+py-macaroon-bakery_1.1.3.orig.tar.gz
+0531fe0fcaa20b9554b17347b36a1b3c4cb84e06
+82450
debianTag="debian/%e%v"
patchedTag="patched/%e%v"
upstreamTag="upstream/%e%u"
diff --git a/debian/changelog b/debian/changelog
index dfe9b9e..60371fe 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+py-macaroon-bakery (1.1.3-1) UNRELEASED; urgency=medium
+
+ * New upstream release.
+
+ -- Colin Watson <cjwatson@debian.org> Wed, 28 Feb 2018 17:09:10 +0000
+
py-macaroon-bakery (1.1.2-1) unstable; urgency=medium
* New upstream release.
diff --git a/debian/control b/debian/control
index 5d18578..de763c1 100644
--- a/debian/control
+++ b/debian/control
@@ -16,7 +16,6 @@ Build-Depends: debhelper (>= 9~),
python3-rfc3339 (>= 1.0),
python3-setuptools,
python3-six (>= 1.11.0),
- python3-tz (>= 2017.2)
Standards-Version: 4.1.1
X-Python3-Version: >= 3.5
Vcs-Git: https://salsa.debian.org/python-team/modules/py-macaroon-bakery
diff --git a/debian/patches/improve-unknown-interaction-mock.patch b/debian/patches/improve-unknown-interaction-mock.patch
index c885b7a..746662a 100644
--- a/debian/patches/improve-unknown-interaction-mock.patch
+++ b/debian/patches/improve-unknown-interaction-mock.patch
@@ -1,4 +1,4 @@
-From c1850c8a10886894255100fae185c450e800564a Mon Sep 17 00:00:00 2001
+From d918563db4de954c3df719d06a31bdd3aec3a8fc Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@debian.org>
Date: Fri, 9 Feb 2018 21:54:21 +0000
Subject: Improve mock setup for 407-then-unknown test
diff --git a/debian/patches/isolate-from-proxy.patch b/debian/patches/isolate-from-proxy.patch
index 2648b94..3a4c18c 100644
--- a/debian/patches/isolate-from-proxy.patch
+++ b/debian/patches/isolate-from-proxy.patch
@@ -1,4 +1,4 @@
-From 68863455145e5ca2ff2091c1e5c31b2a6bf05140 Mon Sep 17 00:00:00 2001
+From 920e53a9172a6a76d6f1abcef56be2edf4301596 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@debian.org>
Date: Mon, 6 Nov 2017 10:27:10 +0000
Subject: Isolate client tests from any HTTP proxy
@@ -41,7 +41,7 @@ index a6c3e58..72a6928 100644
def assert_cookie_security(self, cookies, name, secure):
for cookie in cookies:
diff --git a/macaroonbakery/tests/test_client.py b/macaroonbakery/tests/test_client.py
-index ab20c3b..04e2f2b 100644
+index bfc7807..baafeed 100644
--- a/macaroonbakery/tests/test_client.py
+++ b/macaroonbakery/tests/test_client.py
@@ -3,6 +3,7 @@
diff --git a/docs/conf.py b/docs/conf.py
index 7985e17..3e35fbd 100755
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -63,7 +63,7 @@ copyright = u'2017, Juju UI Team'
# the built documents.
#
# The short X.Y version and the full version.
-version = release = '1.1.2'
+version = release = '1.1.3'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/macaroonbakery/checkers/_checkers.py b/macaroonbakery/checkers/_checkers.py
index 71cb56f..11a41b9 100644
--- a/macaroonbakery/checkers/_checkers.py
+++ b/macaroonbakery/checkers/_checkers.py
@@ -5,7 +5,6 @@ from collections import namedtuple
from datetime import datetime
import pyrfc3339
-import pytz
from ._caveat import parse_caveat
from ._conditions import (
COND_ALLOW,
@@ -166,12 +165,16 @@ class CheckerInfo(namedtuple('CheckInfo', 'prefix name ns check')):
def _check_time_before(ctx, cond, arg):
clock = ctx.get(TIME_KEY)
if clock is None:
- now = pytz.UTC.localize(datetime.utcnow())
+ now = datetime.utcnow()
else:
now = clock.utcnow()
try:
- if pyrfc3339.parse(arg) <= now:
+ # Note: pyrfc3339 returns a datetime with a timezone, which
+ # we need to remove before we can compare it with the naive
+ # datetime object returned by datetime.utcnow.
+ expiry = pyrfc3339.parse(arg, utc=True).replace(tzinfo=None)
+ if now >= expiry:
return 'macaroon has expired'
except ValueError:
return 'cannot parse "{}" as RFC 3339'.format(arg)
diff --git a/macaroonbakery/httpbakery/_browser.py b/macaroonbakery/httpbakery/_browser.py
index a1ccbb0..c8a5586 100644
--- a/macaroonbakery/httpbakery/_browser.py
+++ b/macaroonbakery/httpbakery/_browser.py
@@ -85,5 +85,6 @@ class WebBrowserInteractionInfo(namedtuple('WebBrowserInteractionInfo',
@param info_dict The deserialized JSON object
@return a new WebBrowserInteractionInfo object.
'''
- return WebBrowserInteractionInfo(visit_url=info_dict.get('VisitURL'),
- wait_token_url=info_dict('WaitURL'))
+ return WebBrowserInteractionInfo(
+ visit_url=info_dict.get('VisitURL'),
+ wait_token_url=info_dict.get('WaitTokenURL'))
diff --git a/macaroonbakery/httpbakery/_client.py b/macaroonbakery/httpbakery/_client.py
index d877140..4fe0ab1 100644
--- a/macaroonbakery/httpbakery/_client.py
+++ b/macaroonbakery/httpbakery/_client.py
@@ -320,8 +320,11 @@ def extract_macaroons(headers_or_request):
mss = []
def add_macaroon(data):
- data = utils.b64decode(data)
- data_as_objs = json.loads(data.decode('utf-8'))
+ try:
+ data = utils.b64decode(data)
+ data_as_objs = json.loads(data.decode('utf-8'))
+ except ValueError:
+ return
ms = [utils.macaroon_from_dict(x) for x in data_as_objs]
mss.append(ms)
diff --git a/macaroonbakery/tests/common.py b/macaroonbakery/tests/common.py
index cfbfc52..972b3ad 100644
--- a/macaroonbakery/tests/common.py
+++ b/macaroonbakery/tests/common.py
@@ -4,7 +4,6 @@ from datetime import datetime, timedelta
import macaroonbakery.bakery as bakery
import macaroonbakery.checkers as checkers
-import pytz
class _StoppedClock(object):
@@ -15,8 +14,7 @@ class _StoppedClock(object):
return self.t
-epoch = pytz.utc.localize(
- datetime(year=1900, month=11, day=17, hour=19, minute=00, second=13))
+epoch = datetime(year=1900, month=11, day=17, hour=19, minute=00, second=13)
ages = epoch + timedelta(days=1)
test_context = checkers.context_with_clock(checkers.AuthContext(),
diff --git a/macaroonbakery/tests/test_checkers.py b/macaroonbakery/tests/test_checkers.py
index 28da06e..2628153 100644
--- a/macaroonbakery/tests/test_checkers.py
+++ b/macaroonbakery/tests/test_checkers.py
@@ -4,7 +4,6 @@ from datetime import datetime, timedelta
from unittest import TestCase
import macaroonbakery.checkers as checkers
-import pytz
import six
from pymacaroons import MACAROON_V2, Macaroon
@@ -15,7 +14,7 @@ NOW = datetime(
class TestClock():
def utcnow(self):
- return pytz.UTC.localize(NOW)
+ return NOW
class TestCheckers(TestCase):
diff --git a/macaroonbakery/tests/test_client.py b/macaroonbakery/tests/test_client.py
index 04e2f2b..baafeed 100644
--- a/macaroonbakery/tests/test_client.py
+++ b/macaroonbakery/tests/test_client.py
@@ -353,6 +353,11 @@ class TestClient(TestCase):
value=encode_macaroon(m2),
url='http://example.com',
))
+ jar.set_cookie(utils.cookie(
+ name='macaroon-empty',
+ value='',
+ url='http://example.com',
+ ))
jar.add_cookie_header(req)
macaroons = httpbakery.extract_macaroons(req)
diff --git a/macaroonbakery/tests/test_httpbakery.py b/macaroonbakery/tests/test_httpbakery.py
new file mode 100644
index 0000000..4aac850
--- /dev/null
+++ b/macaroonbakery/tests/test_httpbakery.py
@@ -0,0 +1,16 @@
+from unittest import TestCase
+
+from macaroonbakery.httpbakery import WebBrowserInteractionInfo
+
+
+class TestWebBrowserInteractionInfo(TestCase):
+
+ def test_from_dict(self):
+ info_dict = {
+ 'VisitURL': 'https://example.com/visit',
+ 'WaitTokenURL': 'https://example.com/wait'}
+ interaction_info = WebBrowserInteractionInfo.from_dict(info_dict)
+ self.assertEqual(
+ interaction_info.visit_url, 'https://example.com/visit')
+ self.assertEqual(
+ interaction_info.wait_token_url, 'https://example.com/wait')
diff --git a/macaroonbakery/tests/test_utils.py b/macaroonbakery/tests/test_utils.py
index fcc8839..65edeb4 100644
--- a/macaroonbakery/tests/test_utils.py
+++ b/macaroonbakery/tests/test_utils.py
@@ -7,7 +7,6 @@ from unittest import TestCase
import macaroonbakery.bakery as bakery
import pymacaroons
-import pytz
from macaroonbakery._utils import cookie
from pymacaroons.serializers import json_serializer
@@ -21,7 +20,8 @@ class CookieTest(TestCase):
c.expires, int((timestamp - datetime(1970, 1, 1)).total_seconds()))
def test_cookie_expires_with_timezone(self):
- timestamp = datetime.now(pytz.UTC)
+ from datetime import tzinfo
+ timestamp = datetime.utcnow().replace(tzinfo=tzinfo())
self.assertRaises(
ValueError, cookie, 'http://example.com', 'test', 'value',
expires=timestamp)
diff --git a/requirements.txt b/requirements.txt
index 06cc66e..889c512 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,4 +7,3 @@ pymacaroons>=0.12.0,<1.0
six>=1.11.0,<2.0
protobuf>=3.4.0,<4.0
pyRFC3339>=1.0,<2.0
-pytz>=2017.2,<2018.0
diff --git a/setup.py b/setup.py
index 265b5f8..8beaad3 100755
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ from setuptools import (
PROJECT_NAME = 'macaroonbakery'
-VERSION = (1, 1, 2)
+VERSION = (1, 1, 3)
def get_version():
@@ -30,7 +30,6 @@ requirements = [
'six>=1.11.0,<2.0',
'protobuf>=3.0.0,<4.0',
'pyRFC3339>=1.0,<2.0',
- 'pytz>=2017.2,<2018.0'
]
test_requirements = [