From 3ea0caf9e043d356380c36fa2310f18746aea036 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Fri, 13 Sep 2013 12:59:47 +0200 Subject: Require the database cleanup only to remove USER and PASSWORD. Due to limitations in django, we can't really remove or replace settings dictionary once connection is instantiated. Therefore, all the code that's playing with it will simply modify the existing dict. As a result, removing the connection will only remove username & password, not the whole entry. --- okupy/tests/unit/test_ldapuser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/okupy/tests/unit/test_ldapuser.py b/okupy/tests/unit/test_ldapuser.py index 85097aa..7dd2b5f 100644 --- a/okupy/tests/unit/test_ldapuser.py +++ b/okupy/tests/unit/test_ldapuser.py @@ -95,7 +95,8 @@ class LDAPUserUnitTests(TestCase): self.assertRaises(ldap.INVALID_CREDENTIALS, get_bound_ldapuser, request, 'test') db_alias = 'ldap_%s' % request.session.cache_key - self.assertNotIn(db_alias, settings.DATABASES) + self.assertNotIn('USER', settings.DATABASES.get(db_alias, {})) + self.assertNotIn('PASSWORD', settings.DATABASES.get(db_alias, {})) def test_get_bound_ldapuser_context_manager_cleans_up_settings(self): secondary_password = Random.get_random_bytes(48) @@ -109,4 +110,5 @@ class LDAPUserUnitTests(TestCase): with get_bound_ldapuser(request) as user: # noqa pass db_alias = 'ldap_%s' % request.session.cache_key - self.assertNotIn(db_alias, settings.DATABASES) + self.assertNotIn('USER', settings.DATABASES.get(db_alias, {})) + self.assertNotIn('PASSWORD', settings.DATABASES.get(db_alias, {})) -- cgit v1.2.3-65-gdbad