Exemplo n.º 1
0
def wsgi_app(inner_app_v2=None,
             fake_auth=True,
             fake_auth_context=None,
             use_no_auth=False,
             ext_mgr=None):
    if not inner_app_v2:
        inner_app_v2 = router.APIRouter(ext_mgr)

    if fake_auth:
        if fake_auth_context is not None:
            ctxt = fake_auth_context
        else:
            ctxt = context.RequestContext('fake', 'fake', auth_token=True)
        api_v2 = fault.FaultWrapper(auth.InjectContext(ctxt, inner_app_v2))
    elif use_no_auth:
        api_v2 = fault.FaultWrapper(
            auth.NoAuthMiddleware(limits.RateLimitingMiddleware(inner_app_v2)))
    else:
        api_v2 = fault.FaultWrapper(
            auth.AuthMiddleware(limits.RateLimitingMiddleware(inner_app_v2)))

    mapper = urlmap.URLMap()
    mapper['/v2'] = api_v2
    mapper['/'] = fault.FaultWrapper(versions.Versions())
    return mapper
Exemplo n.º 2
0
def wsgi_app(inner_app_v2=None,
             fake_auth=True,
             fake_auth_context=None,
             use_no_auth=False,
             ext_mgr=None,
             inner_app_v3=None):

    if not inner_app_v3:
        inner_app_v3 = router_v3.APIRouter(ext_mgr)

    if fake_auth:
        if fake_auth_context is not None:
            ctxt = fake_auth_context
        else:
            ctxt = context.RequestContext(fake.USER_ID,
                                          fake.PROJECT_ID,
                                          auth_token=True)
        api_v3 = fault.FaultWrapper(auth.InjectContext(ctxt, inner_app_v3))
    elif use_no_auth:
        api_v3 = fault.FaultWrapper(
            auth.NoAuthMiddleware(limits.RateLimitingMiddleware(inner_app_v3)))
    else:
        api_v3 = fault.FaultWrapper(
            auth.AuthMiddleware(limits.RateLimitingMiddleware(inner_app_v3)))

    mapper = urlmap.URLMap()
    mapper['/v3'] = api_v3
    mapper['/'] = fault.FaultWrapper(versions.VersionsController())
    return mapper
Exemplo n.º 3
0
 def __init__(self, application):
     LOG.warn(
         _('cinder.api.openstack:FaultWrapper is deprecated. Please '
           'use cinder.api.middleware.fault:FaultWrapper instead.'))
     # Avoid circular imports from here. Can I just remove this class?
     from cinder.api.middleware import fault
     super(FaultWrapper, self).__init__(fault.FaultWrapper(application))
Exemplo n.º 4
0
 def _wsgi_app(self, inner_app):
     # NOTE(luisg): In order to test localization, we need to
     # make sure the lazy _() is installed in the 'fault' module
     # also we don't want to install the _() system-wide and
     # potentially break other test cases, so we do it here for this
     # test suite only.
     from cinder.api.middleware import fault
     return fault.FaultWrapper(inner_app)
Exemplo n.º 5
0
 def _wsgi_app(self, inner_app):
     return fault.FaultWrapper(inner_app)