def test_process_request(self): app = middleware.NoAuthContextMiddleware({}) request = FakeRequest() # Process the request app.process_request(request) self.assertIn('context', request.environ) ctxt = request.environ['context'] self.assertIsNone(ctxt.auth_token) self.assertEqual('noauth-user', ctxt.user_id) self.assertEqual('noauth-project', ctxt.project_id) self.assertEqual(['admin'], ctxt.roles)
def test_process_request(self): app = middleware.NoAuthContextMiddleware({}) request = FakeRequest() # Process the request app.process_request(request) self.assertIn('context', request.environ) context = request.environ['context'] self.assertTrue(context.is_admin) self.assertIsNone(context.auth_token) self.assertIsNone(context.user_id) self.assertIsNone(context.tenant_id) self.assertEqual([], context.roles)
def setUp(self): super(ApiV2TestCase, self).setUp() # Ensure the v2 API is enabled self.config(enable_api_v2=True, group='service:api') # Create the application self.app = api_v2.factory({}) # Inject the FaultWrapper middleware self.app = middleware.FaultWrapperMiddleware(self.app) # Inject the NoAuth middleware self.app = middleware.NoAuthContextMiddleware(self.app) # Obtain a test client self.client = TestApp(self.app) # Create and start an instance of the central service self.central_service = self.get_central_service() self.central_service.start()