summaryrefslogtreecommitdiff
path: root/distixapi/authn_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'distixapi/authn_tests.py')
-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)