summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuriy Taraday <yorik.sar@gmail.com>2011-08-23 17:22:02 +0400
committerDolph Mathews <dolph.mathews@gmail.com>2011-09-12 11:49:06 -0500
commitfc6dfe4768641cf6bebca305718c30cb17a90ce3 (patch)
treef0563d4d1e618c2c961706c1560dd0cd6808e0af
parent95f49529a1999802e208f6d4c292395462e4b7be (diff)
downloadkeystone-fc6dfe4768641cf6bebca305718c30cb17a90ce3.tar.gz
keystone-fc6dfe4768641cf6bebca305718c30cb17a90ce3.tar.xz
keystone-fc6dfe4768641cf6bebca305718c30cb17a90ce3.zip
Add ability to run fakeldap in memory.
Tests speedup. Change-Id: I6c1df5990cf2b6c45ea7cab03905c89b92749c9c
-rw-r--r--keystone/backends/ldap/fakeldap.py18
-rwxr-xr-xkeystone/test/etc/ldap.conf.template2
2 files changed, 18 insertions, 2 deletions
diff --git a/keystone/backends/ldap/fakeldap.py b/keystone/backends/ldap/fakeldap.py
index 559850cd..30d1bde4 100644
--- a/keystone/backends/ldap/fakeldap.py
+++ b/keystone/backends/ldap/fakeldap.py
@@ -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."""
diff --git a/keystone/test/etc/ldap.conf.template b/keystone/test/etc/ldap.conf.template
index c4f42b64..4785def8 100755
--- a/keystone/test/etc/ldap.conf.template
+++ b/keystone/test/etc/ldap.conf.template
@@ -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']