Ejemplo n.º 1
0
    def __init__(self,
                 auth_tok=None,
                 user=None,
                 tenant=None,
                 roles=None,
                 is_admin=False,
                 read_only=False,
                 show_deleted=False,
                 owner_is_tenant=True,
                 service_catalog=None,
                 policy_enforcer=None):
        self.auth_tok = auth_tok
        self.user = user
        self.tenant = tenant
        self.roles = roles or []
        self.read_only = read_only
        # TODO(jwood): self._show_deleted = show_deleted
        # (mkbhanda) possibly domain could be owner
        # brings us to the key scope question
        self.owner_is_tenant = owner_is_tenant
        self.request_id = uuidutils.generate_uuid()
        self.service_catalog = service_catalog
        self.policy_enforcer = policy_enforcer or policy.Enforcer()
        self.is_admin = is_admin
        # TODO(jwood): Is this needed?
        #        if not self.is_admin:
        #            self.is_admin = \
        #                self.policy_enforcer.check_is_admin(self)

        if not hasattr(local.store, 'context'):
            self.update_store()
Ejemplo n.º 2
0
from barbican.api.controllers import consumers
from barbican.api.controllers import orders
from barbican.api.controllers import secrets
from barbican.api.controllers import versions
from barbican import context
from barbican.openstack.common import policy
from barbican.tests import utils


CONF = cfg.CONF

# Point to the policy.json file located in source control.
TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                            '../../../etc', 'barbican'))

ENFORCER = policy.Enforcer()


class TestableResource(object):

    def __init__(self, *args, **kwargs):
        self.controller = self.controller_cls(*args, **kwargs)

    def on_get(self, req, resp, *args, **kwargs):
        with mock.patch('pecan.request', req):
            with mock.patch('pecan.response', resp):
                return self.controller.on_get(*args, **kwargs)

    def on_post(self, req, resp, *args, **kwargs):
        with mock.patch('pecan.request', req):
            with mock.patch('pecan.response', resp):
Ejemplo n.º 3
0
 def __init__(self, app):
     self.policy_enforcer = policy.Enforcer()
     super(ContextMiddleware, self).__init__(app)