예제 #1
0
 def setUp(self):
     self.middleware = Middleware()
     self.backend = FostBackend()
     self.request = MockRequest()
예제 #2
0
 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)
예제 #3
0
 def setUp(self):
     self.request = MockRequest()
     self.request.GET['_k'] = 'key'
     self.request.GET['_e'] = 'expires'
     self.request.GET['_s'] = 'signature'
     self.m = Middleware()
예제 #4
0
 def test_with_authorization_header(self):
     r = MockRequest('BASIC user:pass')
     u = self.m.get_mechanism(r)
     self.assertEquals(u, ['BASIC', 'user:pass'])
예제 #5
0
 def test_no_authorization_header(self):
     r = MockRequest(None)
     u = self.m.get_mechanism(r)
     self.assertEquals(u, [None, None])
예제 #6
0
 def test_signed_headers(self):
     request = MockRequest()
     self.m.process_request(request)
     self.assertTrue(hasattr(request, 'SIGNED'))
예제 #7
0
 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=')
예제 #8
0
 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=')