Beispiel #1
0
 def test_extensions_whitelist_accept(self):
     app = compute.APIRouterV3()
     self.assertIn('os-fixed-ips', app._loaded_extension_info.extensions)
     CONF.set_override('extensions_whitelist', 'servers,os-fixed-ips',
                       'osapi_v3')
     app = compute.APIRouterV3()
     self.assertIn('os-fixed-ips', app._loaded_extension_info.extensions)
Beispiel #2
0
 def test_blacklist_overrides_whitelist(self):
     app = compute.APIRouterV3()
     self.assertIn('os-fixed-ips', app._loaded_extension_info.extensions)
     CONF.set_override('extensions_whitelist', 'servers,os-fixed-ips',
                       'osapi_v3')
     CONF.set_override('extensions_blacklist', 'os-fixed-ips', 'osapi_v3')
     app = compute.APIRouterV3()
     self.assertNotIn('os-fixed-ips', app._loaded_extension_info.extensions)
     self.assertIn('servers', app._loaded_extension_info.extensions)
     self.assertEqual(len(app._loaded_extension_info.extensions), 1)
Beispiel #3
0
    def test_extensions_whitelist_block(self):
        # NOTE(maurosr): just to avoid to get an exception raised for not
        # loading all core api.
        v3_core = openstack.API_V3_CORE_EXTENSIONS
        openstack.API_V3_CORE_EXTENSIONS = set(['servers'])
        self.addCleanup(self._set_v3_core, v3_core)

        app = compute.APIRouterV3()
        self.assertIn('os-hosts', app._loaded_extension_info.extensions)
        CONF.set_override('extensions_whitelist', ['servers'], 'osapi_v3')
        app = compute.APIRouterV3()
        self.assertNotIn('os-hosts', app._loaded_extension_info.extensions)
Beispiel #4
0
def wsgi_app_v3(inner_app_v3=None,
                fake_auth_context=None,
                use_no_auth=False,
                ext_mgr=None,
                init_only=None):
    if not inner_app_v3:
        inner_app_v3 = compute.APIRouterV3(init_only)

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

    mapper = urlmap.URLMap()
    mapper['/v3'] = api_v3
    # TODO(cyeoh): bp nova-api-core-as-extensions
    # Still need to implement versions for v3 API
    #    mapper['/'] = openstack_api.FaultWrapper(versions.Versions())
    return mapper
    def setUp(self):
        super(ServerDiagnosticsTest, self).setUp()
        self.stubs.Set(compute_api.API, 'get_diagnostics',
                       fake_get_diagnostics)
        self.stubs.Set(compute_api.API, 'get', fake_instance_get)

        self.router = compute.APIRouterV3(init_only=('servers',
                                                     'os-server-diagnostics'))
Beispiel #6
0
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute_api.API, 'get', fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)
        self.app = compute.APIRouterV3(init_only=('servers',
                                                  'os-admin-actions'))
        self.uuid = uuidutils.generate_uuid()
Beispiel #7
0
 def setUp(self):
     super(TestNoAuthMiddlewareV3, self).setUp()
     api_router = compute.APIRouterV3()
     api_v3 = openstack_api.FaultWrapper(
         auth.NoAuthMiddlewareV3(api_router))
     self.wsgi_app = urlmap.URLMap()
     self.wsgi_app['/v3'] = api_v3
     self.req_url = '/v3'
     self.expected_url = "http://localhost/v3"
Beispiel #8
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)
     v3_core = openstack.API_V3_CORE_EXTENSIONS
     openstack.API_V3_CORE_EXTENSIONS = set(['core1', 'core2'])
     self.addCleanup(self._set_v3_core, v3_core)
     # if no core API extensions are missing then an exception will
     # not be raised when creating an instance of compute.APIRouterV3
     compute.APIRouterV3()
Beispiel #9
0
 def test_extensions_blacklist(self):
     app = compute.APIRouterV3()
     self.assertIn('os-hosts', app._loaded_extension_info.extensions)
     CONF.set_override('extensions_blacklist', ['os-hosts'], 'osapi_v3')
     app = compute.APIRouterV3()
     self.assertNotIn('os-hosts', app._loaded_extension_info.extensions)
Beispiel #10
0
 def test_extensions_loaded(self):
     app = compute.APIRouterV3()
     self.assertIn('servers', app._loaded_extension_info.extensions)
 def setUp(self):
     super(SchedulerHintsTestCase, self).setUp()
     self.fake_instance = fakes.stub_instance(1, uuid=FAKE_UUID)
     self.app = compute.APIRouterV3(init_only=('servers',
                                               'os-scheduler-hints'))
Beispiel #12
0
 def _set_up_router(self):
     self.app = compute.APIRouterV3(init_only=('servers',
                                               'os-scheduler-hints'))
Beispiel #13
0
 def _setup_router(self):
     self.router = compute.APIRouterV3(init_only=('servers',
                                                  'os-server-diagnostics'))
Beispiel #14
0
 def setUp(self):
     super(ServerDiagnosticsTest, self).setUp()
     self.router = compute.APIRouterV3(init_only=('servers',
                                                  'os-server-diagnostics'))