diff options
-rw-r--r-- | debian/.git-dpm | 4 | ||||
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | debian/patches/improve-unknown-interaction-mock.patch | 57 | ||||
-rw-r--r-- | debian/patches/series | 1 | ||||
-rw-r--r-- | macaroonbakery/tests/test_bakery.py | 13 |
5 files changed, 73 insertions, 3 deletions
diff --git a/debian/.git-dpm b/debian/.git-dpm index 96ae457..8a9d05a 100644 --- a/debian/.git-dpm +++ b/debian/.git-dpm @@ -1,6 +1,6 @@ # see git-dpm(1) from git-dpm package -00ab469a4ae426c346228bd68eabe0fd4e689e4c -00ab469a4ae426c346228bd68eabe0fd4e689e4c +ce949d55b30a9ac5a74439727aacf0fab004d6cf +ce949d55b30a9ac5a74439727aacf0fab004d6cf 9e4403035a9953c99117083e6373ae3c441a76b5 9e4403035a9953c99117083e6373ae3c441a76b5 py-macaroon-bakery_1.1.0.orig.tar.gz diff --git a/debian/changelog b/debian/changelog index 5f51f4f..d700e57 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ py-macaroon-bakery (1.1.0-2) UNRELEASED; urgency=medium * Move VCS to salsa.debian.org. + * Improve mock setup for 407-then-unknown test. -- Colin Watson <cjwatson@debian.org> Fri, 09 Feb 2018 18:43:36 +0000 diff --git a/debian/patches/improve-unknown-interaction-mock.patch b/debian/patches/improve-unknown-interaction-mock.patch new file mode 100644 index 0000000..0ba7a7e --- /dev/null +++ b/debian/patches/improve-unknown-interaction-mock.patch @@ -0,0 +1,57 @@ +From ce949d55b30a9ac5a74439727aacf0fab004d6cf 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 + +`test_407_then_unknown_interaction_methods` causes the client to fetch +the possible methods supported by the discharger (because it's told that +it only supports a non-window method). This is currently unmocked, +which causes the client to actually contact `http://example.com/visit`. +This fails in Launchpad builds because they run with a restrictive +network setup that doesn't even expose DNS lookups for non-permitted +hosts. + +There isn't really a good way to simulate this without setting up a +similar stunt DNS server (though perhaps installing an +`httmock.all_requests` fallback mock that raises an exception would be a +good idea?), but this seems to be the only failure at the moment. + +Forwarded: https://github.com/go-macaroon-bakery/py-macaroon-bakery/pull/45 +Last-Update: 2018-02-09 + +Patch-Name: improve-unknown-interaction-mock.patch +--- + macaroonbakery/tests/test_bakery.py | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/macaroonbakery/tests/test_bakery.py b/macaroonbakery/tests/test_bakery.py +index 72a6928..1883987 100644 +--- a/macaroonbakery/tests/test_bakery.py ++++ b/macaroonbakery/tests/test_bakery.py +@@ -146,6 +146,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': +@@ -245,7 +255,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/debian/patches/series b/debian/patches/series index 781b9ec..f8e7d6e 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ isolate-from-proxy.patch +improve-unknown-interaction-mock.patch diff --git a/macaroonbakery/tests/test_bakery.py b/macaroonbakery/tests/test_bakery.py index 72a6928..1883987 100644 --- a/macaroonbakery/tests/test_bakery.py +++ b/macaroonbakery/tests/test_bakery.py @@ -146,6 +146,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': @@ -245,7 +255,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, |