blob: a32ccce4b73cd37797440639e7823a5950053902 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import unittest
import distixapi
class GetCredentialsTests(unittest.TestCase):
def test_raises_error_if_no_Authentication_header(self):
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)
|