summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2018-02-09 21:54:21 +0000
committerColin Watson <cjwatson@debian.org>2018-02-28 17:08:17 +0000
commitd918563db4de954c3df719d06a31bdd3aec3a8fc (patch)
treecb4e07b0e1da829f3ad567063fedc6cf960f910c
parent920e53a9172a6a76d6f1abcef56be2edf4301596 (diff)
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
-rw-r--r--macaroonbakery/tests/test_bakery.py13
1 files changed, 12 insertions, 1 deletions
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,