Add ability to run fakeldap in memory.

Tests speedup.

Change-Id: I6c1df5990cf2b6c45ea7cab03905c89b92749c9c
This commit is contained in:
Yuriy Taraday 2011-08-23 17:22:02 +04:00 committed by Dolph Mathews
parent 95f49529a1
commit fc6dfe4768
2 changed files with 18 additions and 2 deletions

View File

@ -123,12 +123,28 @@ def _subs(value):
server_fail = False
class FakeShelve(dict):
@classmethod
def get_instance(cls):
try:
return cls.__instance
except AttributeError:
cls.__instance = cls()
return cls.__instance
def sync(self):
pass
class FakeLDAP(object):
"""Fake LDAP connection."""
def __init__(self, url):
LOG.debug("FakeLDAP initialize url=%s" % (url,))
self.db = shelve.open(url[7:])
if url == 'fake://memory':
self.db = FakeShelve.get_instance()
else:
self.db = shelve.open(url[7:])
def simple_bind_s(self, dn, password):
"""This method is ignored, but provided for compatibility."""

View File

@ -21,7 +21,7 @@ sql_idle_timeout = 30
backend_entities = ['Endpoints', 'Credentials', 'EndpointTemplates', 'Token', 'Service']
[keystone.backends.ldap]
ldap_url = fake://%(test_dir)s/ldap.db
ldap_url = fake://memory
ldap_user = cn=Admin
ldap_password = password
backend_entities = ['Tenant', 'User', 'UserRoleAssociation', 'Role']