summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-04-16 10:24:34 +0300
committerLars Wirzenius <liw@liw.fi>2017-04-16 10:24:34 +0300
commit94c85cdb98945f475cc5db7b8869357f75c7ff43 (patch)
tree56d780f674f38fc823c535053a36225c265fd37a
parentf7d161fcb6f111d0dc36b8d6252c0d7061bbc5ae (diff)
downloaddistixapi-94c85cdb98945f475cc5db7b8869357f75c7ff43.tar.gz
Add test for not Basic Auth header
-rw-r--r--distixapi/authn_tests.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/distixapi/authn_tests.py b/distixapi/authn_tests.py
index 2a220ab..a32ccce 100644
--- a/distixapi/authn_tests.py
+++ b/distixapi/authn_tests.py
@@ -6,6 +6,25 @@ import distixapi
class GetCredentialsTests(unittest.TestCase):
def test_raises_error_if_no_Authentication_header(self):
- request = {}
+ request = DummyRequest()
with self.assertRaises(distixapi.AuthenticationError):
distixapi.get_credentials(request)
+
+ def test_raises_error_if_not_BasicAuth_header(self):
+ request = DummyRequest()
+ request.add_header('Authorization', 'Bearer token')
+ with self.assertRaises(distixapi.AuthenticationError):
+ distixapi.get_credentials(request)
+
+
+
+class DummyRequest(object):
+
+ def __init__(self):
+ self._headers = {}
+
+ def add_header(self, header, value):
+ self._headers[header] = value
+
+ def get_header(self, header):
+ return self._headers.get(header)