Ejemplo n.º 1
0
    def test_context(self):
        original_context = {
            'auth_token': str(uuid.uuid4()),
            'user': str(uuid.uuid4()),
            'tenant': str(uuid.uuid4()),
            'domain': str(uuid.uuid4()),
            'user_domain': str(uuid.uuid4()),
            'project_domain': str(uuid.uuid4()),
            'is_admin': False,
            'read_only': False,
            'show_deleted': False,
            'request_id': str(uuid.uuid4()),
            'resource_uuid': str(uuid.uuid4()),
            'roles': str(uuid.uuid4()),
            'is_public_api': False,
            'domain_id': str(uuid.uuid4()),
            'domain_name': str(uuid.uuid4())
        }

        req_context = context.RequestContext(**original_context)
        context_dict = req_context.to_dict()

        # user_identity is an attribute generated by oslo_context based on
        # inputs received at context construction time, rather than duplicate
        # that logic here to verify it, don't check it
        del context_dict['user_identity']

        self.assertDictEqual(original_context, context_dict)
Ejemplo n.º 2
0
 def get_context(self, **kwargs):
     auth_token = kwargs.get('auth_token', "auth_xxx")
     user = kwargs.get("user", "user")
     tenant = kwargs.get("tenant", "tenant-a")
     return cue_context.RequestContext(
         auth_token=auth_token,
         user=user,
         tenant=tenant,
     )
Ejemplo n.º 3
0
    def before(self, state):
        user_id = state.request.headers.get('X-User-Id')
        tenant_id = state.request.headers.get('X-Project-Id')
        domain_id = state.request.headers.get('X-Domain-Id')
        domain_name = state.request.headers.get('X-Domain-Name')
        auth_token = state.request.headers.get('X-Auth-Token')

        is_public_api = state.request.environ.get('is_public_api', False)

        state.request.context = context.RequestContext(
            auth_token=auth_token,
            user=user_id,
            tenant=tenant_id,
            domain_id=domain_id,
            domain_name=domain_name,
            is_public_api=is_public_api)
Ejemplo n.º 4
0
 def test_user_id(self):
     user_id = str(uuid.uuid4())
     req_context = context.RequestContext()
     req_context.user_id = user_id
     self.assertEqual(user_id, req_context.user_id)
Ejemplo n.º 5
0
 def test_tenant_id(self):
     tenant_id = str(uuid.uuid4())
     req_context = context.RequestContext()
     req_context.tenant_id = tenant_id
     self.assertEqual(tenant_id, req_context.tenant_id)
Ejemplo n.º 6
0
 def __init__(self):
     self.context = context.RequestContext(is_admin=True)
     self.context.request_id = 'cue-manage'
 def __init__(self):
     super(BrokerCommands, self).__init__()
     self.context = cue_context.RequestContext()