aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-09-12 15:28:30 +0200
committerMichał Górny <mgorny@gentoo.org>2013-09-12 15:41:43 +0200
commitf77d2959e92c55441b92f527354365009c992e0a (patch)
treefe21e087f2a5f7a4324e1a7e0bef8cb6f4d302cf /okupy/tests
parentUse context managers to clean up settings.DATABASES after binds. (diff)
downloadidentity.gentoo.org-f77d2959e92c55441b92f527354365009c992e0a.tar.gz
identity.gentoo.org-f77d2959e92c55441b92f527354365009c992e0a.tar.bz2
identity.gentoo.org-f77d2959e92c55441b92f527354365009c992e0a.zip
Tests: check whether failed get_bound_ldapuser() doesn't pollute the db.
Diffstat (limited to 'okupy/tests')
-rw-r--r--okupy/tests/unit/test_ldapuser.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/okupy/tests/unit/test_ldapuser.py b/okupy/tests/unit/test_ldapuser.py
index 410e9f1..85097aa 100644
--- a/okupy/tests/unit/test_ldapuser.py
+++ b/okupy/tests/unit/test_ldapuser.py
@@ -90,6 +90,13 @@ class LDAPUserUnitTests(TestCase):
self.assertRaises(ldap.INVALID_CREDENTIALS, get_bound_ldapuser,
request, 'test')
+ def test_get_bound_ldapuser_invalid_password_cleans_up_settings(self):
+ request = set_request('/', user=vars.USER_ALICE)
+ self.assertRaises(ldap.INVALID_CREDENTIALS, get_bound_ldapuser,
+ request, 'test')
+ db_alias = 'ldap_%s' % request.session.cache_key
+ self.assertNotIn(db_alias, settings.DATABASES)
+
def test_get_bound_ldapuser_context_manager_cleans_up_settings(self):
secondary_password = Random.get_random_bytes(48)
secondary_password_crypt = ldap_md5_crypt.encrypt(b64encode(