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

    if use_no_auth:
        api_v21 = openstack_api.FaultWrapper(
            auth.NoAuthMiddlewareV3(
                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
    return mapper
示例#2
0
    def test_blacklist_overrides_whitelist(self):
        # NOTE(maurosr): just to avoid to get an exception raised for not
        # loading all core api.
        v21_core = openstack.API_V3_CORE_EXTENSIONS
        openstack.API_V3_CORE_EXTENSIONS = set(['servers'])
        self.addCleanup(self._set_v21_core, v21_core)

        app = compute.APIRouterV21()
        self.assertIn('os-hosts', app._loaded_extension_info.extensions)
        CONF.set_override('extensions_whitelist', ['servers', 'os-hosts'],
                          'osapi_v3')
        CONF.set_override('extensions_blacklist', ['os-hosts'], 'osapi_v3')
        app = compute.APIRouterV21()
        self.assertNotIn('os-hosts', app._loaded_extension_info.extensions)
        self.assertIn('servers', app._loaded_extension_info.extensions)
        self.assertEqual(1, len(app._loaded_extension_info.extensions))
示例#3
0
def wsgi_app_v21(fake_auth_context=None, v2_compatible=False,
                 custom_routes=None):
    # NOTE(efried): Keep this (roughly) in sync with api-paste.ini

    def wrap(app, use_context=False):
        if v2_compatible:
            app = openstack_api.LegacyV2CompatibleWrapper(app)

        if use_context:
            if fake_auth_context is not None:
                ctxt = fake_auth_context
            else:
                ctxt = context.RequestContext(
                    'fake', FAKE_PROJECT_ID, auth_token=True)
            app = api_auth.InjectContext(ctxt, app)

        app = openstack_api.FaultWrapper(app)

        return app

    inner_app_v21 = compute.APIRouterV21(custom_routes=custom_routes)

    mapper = urlmap.URLMap()
    mapper['/'] = wrap(versions.Versions())
    mapper['/v2'] = wrap(versions.VersionsV2())
    mapper['/v2.1'] = wrap(versions.VersionsV2())
    mapper['/v2/+'] = wrap(inner_app_v21, use_context=True)
    mapper['/v2.1/+'] = wrap(inner_app_v21, use_context=True)
    return mapper
 def setUp(self):
     super(TestNoAuthMiddleware, self).setUp()
     fakes.stub_out_networking(self)
     api_v21 = openstack_api.FaultWrapper(
         self.auth_middleware(compute.APIRouterV21()))
     self.wsgi_app = urlmap.URLMap()
     self.wsgi_app['/v2.1'] = api_v21
     self.req_url = '/v2.1'
示例#5
0
 def test_core_extensions_present(self):
     self.stubs.Set(stevedore.enabled, 'EnabledExtensionManager',
                    fake_stevedore_enabled_extensions)
     self.stubs.Set(plugins, 'LoadedExtensionInfo',
                    fake_loaded_extension_info)
     v21_core = openstack.API_V3_CORE_EXTENSIONS
     openstack.API_V3_CORE_EXTENSIONS = set(['core1', 'core2'])
     self.addCleanup(self._set_v21_core, v21_core)
     # if no core API extensions are missing then an exception will
     # not be raised when creating an instance of compute.APIRouterV21
     compute.APIRouterV21()
示例#6
0
    def test_extensions_inherit(self, mock_register):
        app = compute.APIRouterV21()
        self.assertIn('servers', app._loaded_extension_info.extensions)
        self.assertIn('os-volumes', app._loaded_extension_info.extensions)

        mock_register.assert_called_with(mock.ANY, mock.ANY)
        ext_no_inherits = mock_register.call_args_list[0][0][0]
        ext_has_inherits = mock_register.call_args_list[1][0][0]
        # os-volumes inherits from servers
        name_list = [ext.obj.alias for ext in ext_has_inherits]
        self.assertIn('os-volumes', name_list)
        name_list = [ext.obj.alias for ext in ext_no_inherits]
        self.assertIn('servers', name_list)
示例#7
0
def wsgi_app_v21(fake_auth_context=None, v2_compatible=False):

    inner_app_v21 = compute.APIRouterV21()

    if v2_compatible:
        inner_app_v21 = openstack_api.LegacyV2CompatibleWrapper(inner_app_v21)

    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, inner_app_v21))
    mapper = urlmap.URLMap()
    mapper['/v2'] = api_v21
    mapper['/v2.1'] = api_v21
    mapper['/'] = openstack_api.FaultWrapper(versions.Versions())
    return mapper
示例#8
0
 def test_extensions_blacklist(self):
     app = compute.APIRouterV21()
     self.assertIn('os-hosts', app._loaded_extension_info.extensions)
     CONF.set_override('extensions_blacklist', ['os-hosts'], 'osapi_v3')
     app = compute.APIRouterV21()
     self.assertNotIn('os-hosts', app._loaded_extension_info.extensions)
示例#9
0
 def test_extensions_loaded(self):
     app = compute.APIRouterV21()
     self.assertIn('servers', app._loaded_extension_info.extensions)
 def _set_up_router(self):
     self.app = compute.APIRouterV21(init_only=('servers',
                                                'os-scheduler-hints'))
 def _set_up_app(self):
     self.app = compute.APIRouterV21(init_only=('servers', 'images',
                                                'os-disk-config'))
示例#12
0
 def _set_up_app(self):
     self.app = compute.APIRouterV21()
示例#13
0
 def _setup_router(self):
     self.router = compute.APIRouterV21(init_only=('servers',
                                                   'os-server-diagnostics'))
示例#14
0
 def _setup_router(self):
     self.router = compute.APIRouterV21()