Esempio n. 1
0
 def setUp(self):
     super(ResourceOperatorManagerSecuritygroupTestCase, self).setUp()
     self.manager = operator_manager.ResourceOperator()
     self.exception = neutron_exceptions.\
         NeutronClientException(status_code=400, message="fake_msg")
     self.context = context.RequestContext('fake_user', 'fake_project')
     self.name = "securitygroup_name"
Esempio n. 2
0
    def base_call(self, req, project_id_in_path):
        remote_address = getattr(req, 'remote_address', '127.0.0.1')
        ctx = context.RequestContext(user_id='noauth',
                                     project_id='noauth',
                                     is_admin=True,
                                     remote_address=remote_address)

        req.environ['rack.context'] = ctx
        return self.application
Esempio n. 3
0
    def __call__(self, req):
        user_id = req.headers.get('X_USER')
        user_id = req.headers.get('X_USER_ID', user_id)
        if user_id is None:
            LOG.debug("Neither X_USER_ID nor X_USER found in request")
            return webob.exc.HTTPUnauthorized()

        roles = self._get_roles(req)

        if 'X_TENANT_ID' in req.headers:
            # This is the new header since Keystone went to ID/Name
            project_id = req.headers['X_TENANT_ID']
        else:
            # This is for legacy compatibility
            project_id = req.headers['X_TENANT']
        project_name = req.headers.get('X_TENANT_NAME')
        user_name = req.headers.get('X_USER_NAME')

        # Get the auth token
        auth_token = req.headers.get('X_AUTH_TOKEN',
                                     req.headers.get('X_STORAGE_TOKEN'))

        # Build a context, including the auth_token...
        remote_address = req.remote_addr
        if CONF.use_forwarded_for:
            remote_address = req.headers.get('X-Forwarded-For', remote_address)

        service_catalog = None
        if req.headers.get('X_SERVICE_CATALOG') is not None:
            try:
                catalog_header = req.headers.get('X_SERVICE_CATALOG')
                service_catalog = jsonutils.loads(catalog_header)
            except ValueError:
                raise webob.exc.HTTPInternalServerError(
                    _('Invalid service catalog json.'))

        ctx = context.RequestContext(user_id,
                                     project_id,
                                     user_name=user_name,
                                     project_name=project_name,
                                     roles=roles,
                                     auth_token=auth_token,
                                     remote_address=remote_address,
                                     service_catalog=service_catalog)

        req.environ['rack.context'] = ctx
        return self.application
Esempio n. 4
0
 def setUp(self):
     super(ResourceOperatorManagerKeypairTestCase, self).setUp()
     self.manager = operator_manager.ResourceOperator()
     self.context = context.RequestContext('fake_user', 'fake_project')