def inject_context(req, resp, params): """Inject context value into request environment. :param req: request sent :type req: falcon.request.Request :param resp: response object :type resp: falcon.response.Response :param params: additional parameters passed to responders :type params: dict :rtype: None """ client_id = req.get_header('Client-ID') project_id = params.get('project_id', None) request_id = req.headers.get('X-Openstack-Request-ID'), auth_token = req.headers.get('X-AUTH-TOKEN') user = req.headers.get('X-USER-ID') tenant = req.headers.get('X-TENANT-ID') roles = req.headers.get('X-ROLES') roles = roles and roles.split(',') or [] ctxt = context.RequestContext(project_id=project_id, client_id=client_id, request_id=request_id, auth_token=auth_token, user=user, tenant=tenant, roles=roles) req.env['zaqar.context'] = ctxt
def inject_context(req, resp, params): """Inject context value into request environment. :param req: request sent :type req: falcon.request.Request :param resp: response object :type resp: falcon.response.Response :param params: additional parameters passed to responders :type params: dict :rtype: None """ client_id = req.get_header('Client-ID') project_id = params.get('project_id', None) ctxt = context.RequestContext(project_id=project_id, client_id=client_id) req.env['zaqar.context'] = ctxt
def setUp(self): super(TestAcl, self).setUp() ctx = context.RequestContext() request_class = namedtuple("Request", ("env", )) self.request = request_class({"zaqar.context": ctx})