def setUp(self): self.middleware = Middleware() self.backend = FostBackend() self.request = MockRequest()
def _do_test(self, header, gets_user=False): self.request = MockRequest(header) self.m.process_request(self.request) self.assertEquals(hasattr(self.request, 'user'), gets_user)
def setUp(self): self.request = MockRequest() self.request.GET['_k'] = 'key' self.request.GET['_e'] = 'expires' self.request.GET['_s'] = 'signature' self.m = Middleware()
def test_with_authorization_header(self): r = MockRequest('BASIC user:pass') u = self.m.get_mechanism(r) self.assertEquals(u, ['BASIC', 'user:pass'])
def test_no_authorization_header(self): r = MockRequest(None) u = self.m.get_mechanism(r) self.assertEquals(u, [None, None])
def test_signed_headers(self): request = MockRequest() self.m.process_request(request) self.assertTrue(hasattr(request, 'SIGNED'))
def test_signed_mock_request(self): request = MockRequest(method='GET', path='/') request.META['HTTP_X_FOST_TIMESTAMP'] = '2011-04-27 03:26:37.625618' request.sign_request('key-value', 'secret-value') self.assertEqual(request.META['HTTP_AUTHORIZATION'], 'FOST key-value:Ttq8K3g/jm7sOAVzCN+3k4FVAso=')
def test_signed_mock_request(self): request = MockRequest(method = 'GET', path = '/') request.META['HTTP_X_FOST_TIMESTAMP'] = '2011-04-27 03:26:37.625618' request.sign_request('key-value', 'secret-value') self.assertEqual(request.META['HTTP_AUTHORIZATION'], 'FOST key-value:Ttq8K3g/jm7sOAVzCN+3k4FVAso=')