Example #1
0
def wsgi_app_v21(inner_app_v21=None,
                 fake_auth_context=None,
                 use_no_auth=False,
                 ext_mgr=None,
                 init_only=None,
                 v2_compatible=False):
    if not inner_app_v21:
        inner_app_v21 = compute.APIRouterV21(init_only)

    if v2_compatible:
        inner_app_v21 = openstack_api.LegacyV2CompatibleWrapper(inner_app_v21)

    if use_no_auth:
        api_v21 = openstack_api.FaultWrapper(
            auth.NoAuthMiddleware(
                limits.RateLimitingMiddleware(inner_app_v21)))
    else:
        if fake_auth_context is not None:
            ctxt = fake_auth_context
        else:
            ctxt = context.RequestContext('fake', 'fake', auth_token=True)
        api_v21 = openstack_api.FaultWrapper(
            api_auth.InjectContext(
                ctxt, limits.RateLimitingMiddleware(inner_app_v21)))

    mapper = urlmap.URLMap()
    mapper['/v2'] = api_v21
    mapper['/v2.1'] = api_v21
    mapper['/'] = openstack_api.FaultWrapper(versions.Versions())
    return mapper
Example #2
0
 def setUp(self):
     """Prepare middleware for use through fake WSGI app."""
     super(LimitMiddlewareTest, self).setUp()
     _limits = '(GET, *, .*, 1, MINUTE)'
     self.app = limits.RateLimitingMiddleware(
         self._empty_app, _limits,
         "%s.MockLimiter" % self.__class__.__module__)