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.VersionsController()) return mapper
def test_all_versions_excludes_disabled(self): version = '3.0' self.fixture = self.useFixture(config_fixture.Config(CONF)) self.fixture.config(enable_v3_api=False) vc = versions.VersionsController() req = self.build_request(base_url='http://localhost') resp = vc.all(req) all_versions = [x['id'] for x in resp['versions']] self.assertNotIn('v' + version, all_versions)