summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PKG-INFO2
-rw-r--r--macaroonbakery.egg-info/PKG-INFO2
-rw-r--r--macaroonbakery.egg-info/requires.txt14
-rw-r--r--macaroonbakery/checkers/_auth_context.py7
-rw-r--r--macaroonbakery/tests/test_bakery.py13
-rw-r--r--macaroonbakery/tests/test_client.py14
-rwxr-xr-xsetup.py27
7 files changed, 50 insertions, 29 deletions
diff --git a/PKG-INFO b/PKG-INFO
index c0150fc..7e4987e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: macaroonbakery
-Version: 1.2.3
+Version: 1.3.0
Summary: A Python library port for bakery, higher level operation to work with macaroons
Home-page: https://github.com/go-macaroon-bakery/py-macaroon-bakery
Author: Juju UI Team
diff --git a/macaroonbakery.egg-info/PKG-INFO b/macaroonbakery.egg-info/PKG-INFO
index c0150fc..7e4987e 100644
--- a/macaroonbakery.egg-info/PKG-INFO
+++ b/macaroonbakery.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: macaroonbakery
-Version: 1.2.3
+Version: 1.3.0
Summary: A Python library port for bakery, higher level operation to work with macaroons
Home-page: https://github.com/go-macaroon-bakery/py-macaroon-bakery
Author: Juju UI Team
diff --git a/macaroonbakery.egg-info/requires.txt b/macaroonbakery.egg-info/requires.txt
index e715881..52b6944 100644
--- a/macaroonbakery.egg-info/requires.txt
+++ b/macaroonbakery.egg-info/requires.txt
@@ -1,7 +1,15 @@
-requests<3.0,>=2.18.1
PyNaCl<2.0,>=1.1.2
-pymacaroons<1.0,>=0.12.0
-six<2.0,>=1.11.0
protobuf<4.0,>=3.0.0
pyRFC3339<2.0,>=1.0
+pymacaroons<1.0,>=0.12.0
+requests<3.0,>=2.18.1
+six<2.0,>=1.11.0
+
+[:python_full_version < "2.7.9"]
+cryptography==1.3.2
+ndg_httpsclient==0.3.3
+pyOpenSSL==16.0.0
+pyasn1==0.1.9
+
+[:python_version < "3"]
ipaddress
diff --git a/macaroonbakery/checkers/_auth_context.py b/macaroonbakery/checkers/_auth_context.py
index dceb015..2ca5168 100644
--- a/macaroonbakery/checkers/_auth_context.py
+++ b/macaroonbakery/checkers/_auth_context.py
@@ -1,9 +1,12 @@
# Copyright 2017 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.
-import collections
+try:
+ from collections.abc import Mapping
+except ImportError:
+ from collections import Mapping
-class AuthContext(collections.Mapping):
+class AuthContext(Mapping):
''' Holds a set of keys and values relevant to authorization.
It is passed as an argument to authorization checkers, so that the checkers
diff --git a/macaroonbakery/tests/test_bakery.py b/macaroonbakery/tests/test_bakery.py
index a6c3e58..d242b2a 100644
--- a/macaroonbakery/tests/test_bakery.py
+++ b/macaroonbakery/tests/test_bakery.py
@@ -145,6 +145,16 @@ def discharge_401(url, request):
}
+@urlmatch(path='.*/visit')
+def visit_200(url, request):
+ return {
+ 'status_code': 200,
+ 'content': {
+ 'interactive': '/visit'
+ }
+ }
+
+
@urlmatch(path='.*/wait')
def wait_after_401(url, request):
if request.url != 'http://example.com/wait':
@@ -239,7 +249,8 @@ class TestBakery(TestCase):
def kind(self):
return 'unknown'
client = httpbakery.Client(interaction_methods=[UnknownInteractor()])
- with HTTMock(first_407_then_200), HTTMock(discharge_401):
+ with HTTMock(first_407_then_200), HTTMock(discharge_401),\
+ HTTMock(visit_200):
with self.assertRaises(httpbakery.InteractionError) as exc:
requests.get(
ID_PATH,
diff --git a/macaroonbakery/tests/test_client.py b/macaroonbakery/tests/test_client.py
index b03bafa..6437a54 100644
--- a/macaroonbakery/tests/test_client.py
+++ b/macaroonbakery/tests/test_client.py
@@ -4,7 +4,6 @@ import base64
import datetime
import json
import threading
-from unittest import TestCase
import macaroonbakery.bakery as bakery
import macaroonbakery.checkers as checkers
@@ -13,6 +12,10 @@ import pymacaroons
import requests
import macaroonbakery._utils as utils
+from fixtures import (
+ EnvironmentVariable,
+ TestWithFixtures,
+)
from httmock import HTTMock, urlmatch
from six.moves.urllib.parse import parse_qs
from six.moves.urllib.request import Request
@@ -26,7 +29,14 @@ AGES = datetime.datetime.utcnow() + datetime.timedelta(days=1)
TEST_OP = bakery.Op(entity='test', action='test')
-class TestClient(TestCase):
+class TestClient(TestWithFixtures):
+ def setUp(self):
+ super(TestClient, self).setUp()
+ # http_proxy would cause requests to talk to the proxy, which is
+ # unlikely to know how to talk to the test server.
+ self.useFixture(EnvironmentVariable('http_proxy'))
+ self.useFixture(EnvironmentVariable('HTTP_PROXY'))
+
def test_single_service_first_party(self):
b = new_bakery('loc', None, None)
diff --git a/setup.py b/setup.py
index f098e76..d549aa5 100755
--- a/setup.py
+++ b/setup.py
@@ -2,9 +2,6 @@
# Copyright 2017 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.
-import sys
-import platform
-
from setuptools import (
find_packages,
setup,
@@ -13,8 +10,8 @@ from setuptools import (
PROJECT_NAME = 'macaroonbakery'
-# version 1.2.3
-VERSION = (1, 2, 3)
+# version 1.3.0
+VERSION = (1, 3, 0)
def get_version():
@@ -32,27 +29,19 @@ requirements = [
'six>=1.11.0,<2.0',
'protobuf>=3.0.0,<4.0',
'pyRFC3339>=1.0,<2.0',
+ 'ipaddress;python_version<"3"',
+ 'cryptography==1.3.2;python_full_version<"2.7.9"',
+ 'ndg_httpsclient==0.3.3;python_full_version<"2.7.9"',
+ 'pyasn1==0.1.9;python_full_version<"2.7.9"',
+ 'pyOpenSSL==16.0.0;python_full_version<"2.7.9"',
]
test_requirements = [
'tox',
+ 'fixtures',
'httmock==1.2.5',
]
-distribution = platform.dist()
-if len(distribution) == 3 and distribution[2] == 'trusty':
- # Injected into urllib3 to fix insecure Python 2.
- requirements.extend([
- 'cryptography==1.3.2',
- 'pyOpenSSL==16.0.0',
- 'pyasn1==0.1.9',
- 'ndg_httpsclient==0.3.3',
- ])
-
-if sys.version_info.major == 2:
- requirements.append('ipaddress')
-
-
setup(
name=PROJECT_NAME,
version=get_version(),