
This step in the process duplicates the auth-token code to keystoneclient but, for the moment, leaves a copy in its origional location in keystone. Testing for auth-token is also copied across, as is the cms support file. Although no other project will yet pick up the code here in the client, since the paste.ini files haev not yet been updated, it would work if anyone did reference it. Once the client code is in, the next step is to update all the other project paste files, and then finally retire the code from keystone. Change-Id: I88853a373d406020d54b61cba5a5e887380e3b3e
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
# Copyright 2012 OpenStack LLC
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
#
|
|
# Test support for middleware authentication
|
|
#
|
|
|
|
import os
|
|
import sys
|
|
|
|
|
|
ROOTDIR = os.path.dirname(os.path.abspath(os.curdir))
|
|
|
|
|
|
def rootdir(*p):
|
|
return os.path.join(ROOTDIR, *p)
|
|
|
|
|
|
class NoModule(object):
|
|
"""A mixin class to provide support for unloading/disabling modules."""
|
|
|
|
def __init__(self, *args, **kw):
|
|
super(NoModule, self).__init__(*args, **kw)
|
|
self._finders = []
|
|
self._cleared_modules = {}
|
|
|
|
def tearDown(self):
|
|
super(NoModule, self).tearDown()
|
|
for finder in self._finders:
|
|
sys.meta_path.remove(finder)
|
|
sys.modules.update(self._cleared_modules)
|
|
|
|
def clear_module(self, module):
|
|
cleared_modules = {}
|
|
for fullname in sys.modules.keys():
|
|
if fullname == module or fullname.startswith(module + '.'):
|
|
cleared_modules[fullname] = sys.modules.pop(fullname)
|
|
return cleared_modules
|
|
|
|
def disable_module(self, module):
|
|
"""Ensure ImportError for the specified module."""
|
|
|
|
# Clear 'module' references in sys.modules
|
|
self._cleared_modules.update(self.clear_module(module))
|
|
|
|
# Disallow further imports of 'module'
|
|
class NoModule(object):
|
|
def find_module(self, fullname, path):
|
|
if fullname == module or fullname.startswith(module + '.'):
|
|
raise ImportError
|
|
|
|
finder = NoModule()
|
|
self._finders.append(finder)
|
|
sys.meta_path.insert(0, finder)
|