d9c6b50a3a
keystone.common.config is 1200+ lines of super dense, merge-conflict prone, difficult to navigate, and finicky to maintain code. Let's follow nova's lead and break it down into more manageable modules. This patch creates a new Python package, keystone.conf, and moves all of our configuration options into it, mirroring nova's nova.conf package. There are a couple special modules in keystone.conf introduced here as well: - keystone.conf.__init__: This causes all of Keystone options to be registered on import, so consumers of keystone.conf don't have races with config initialization code while trying to use oslo_config.cfg.CONF directly (keystone.conf replaces all uses for oslo_config.cfg.CONF in keystone). - keystone.conf.base: Keystone's [DEFAULT] group options. I'd prefer this to be called 'default.py', but I'm just copying nova's lead here. - keystone.conf.opts: The entry point for oslo.config itself. - keystone.conf.constants: There are a few constants (deprecation messages, default paths, etc) that are used by multiple configuration modules, so they need to live in a common place. Change-Id: Ia3daffe3fef111b42de203762e966cd14d8927e2
126 lines
4.6 KiB
Python
126 lines
4.6 KiB
Python
# Copyright 2013 OpenStack Foundation
|
|
#
|
|
# 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.
|
|
|
|
import uuid
|
|
|
|
from six.moves import range
|
|
|
|
import keystone.conf
|
|
|
|
|
|
CONF = keystone.conf.CONF
|
|
|
|
|
|
class FilterTests(object):
|
|
|
|
# Provide support for checking if a batch of list items all
|
|
# exist within a contiguous range in a total list
|
|
def _match_with_list(self, this_batch, total_list,
|
|
batch_size=None,
|
|
list_start=None, list_end=None):
|
|
if batch_size is None:
|
|
batch_size = len(this_batch)
|
|
if list_start is None:
|
|
list_start = 0
|
|
if list_end is None:
|
|
list_end = len(total_list)
|
|
for batch_item in range(0, batch_size):
|
|
found = False
|
|
for list_item in range(list_start, list_end):
|
|
if this_batch[batch_item]['id'] == total_list[list_item]['id']:
|
|
found = True
|
|
self.assertTrue(found)
|
|
|
|
def _create_entity(self, entity_type):
|
|
"""Find the create_<entity_type> method.
|
|
|
|
Searches through the [identity_api, resource_api, assignment_api]
|
|
managers for a method called create_<entity_type> and returns the first
|
|
one.
|
|
|
|
"""
|
|
f = getattr(self.identity_api, 'create_%s' % entity_type, None)
|
|
if f is None:
|
|
f = getattr(self.resource_api, 'create_%s' % entity_type, None)
|
|
if f is None:
|
|
f = getattr(self.assignment_api, 'create_%s' % entity_type)
|
|
return f
|
|
|
|
def _delete_entity(self, entity_type):
|
|
"""Find the delete_<entity_type> method.
|
|
|
|
Searches through the [identity_api, resource_api, assignment_api]
|
|
managers for a method called delete_<entity_type> and returns the first
|
|
one.
|
|
|
|
"""
|
|
f = getattr(self.identity_api, 'delete_%s' % entity_type, None)
|
|
if f is None:
|
|
f = getattr(self.resource_api, 'delete_%s' % entity_type, None)
|
|
if f is None:
|
|
f = getattr(self.assignment_api, 'delete_%s' % entity_type)
|
|
return f
|
|
|
|
def _list_entities(self, entity_type):
|
|
"""Find the list_<entity_type> method.
|
|
|
|
Searches through the [identity_api, resource_api, assignment_api]
|
|
managers for a method called list_<entity_type> and returns the first
|
|
one.
|
|
|
|
"""
|
|
f = getattr(self.identity_api, 'list_%ss' % entity_type, None)
|
|
if f is None:
|
|
f = getattr(self.resource_api, 'list_%ss' % entity_type, None)
|
|
if f is None:
|
|
f = getattr(self.assignment_api, 'list_%ss' % entity_type)
|
|
return f
|
|
|
|
def _create_one_entity(self, entity_type, domain_id, name):
|
|
new_entity = {'name': name,
|
|
'domain_id': domain_id}
|
|
if entity_type in ['user', 'group']:
|
|
# The manager layer creates the ID for users and groups
|
|
new_entity = self._create_entity(entity_type)(new_entity)
|
|
else:
|
|
new_entity['id'] = '0000' + uuid.uuid4().hex
|
|
self._create_entity(entity_type)(new_entity['id'], new_entity)
|
|
return new_entity
|
|
|
|
def _create_test_data(self, entity_type, number, domain_id=None,
|
|
name_dict=None):
|
|
"""Create entity test data.
|
|
|
|
:param entity_type: type of entity to create, e.g. 'user', group' etc.
|
|
:param number: number of entities to create,
|
|
:param domain_id: if not defined, all users will be created in the
|
|
default domain.
|
|
:param name_dict: optional dict containing entity number and name pairs
|
|
|
|
"""
|
|
entity_list = []
|
|
if domain_id is None:
|
|
domain_id = CONF.identity.default_domain_id
|
|
name_dict = name_dict or {}
|
|
for x in range(number):
|
|
# If this index has a name defined in the name_dict, then use it
|
|
name = name_dict.get(x, uuid.uuid4().hex)
|
|
new_entity = self._create_one_entity(entity_type, domain_id, name)
|
|
entity_list.append(new_entity)
|
|
return entity_list
|
|
|
|
def _delete_test_data(self, entity_type, entity_list):
|
|
for entity in entity_list:
|
|
self._delete_entity(entity_type)(entity['id'])
|