aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Chatzimichos <tampakrap@gentoo.org>2013-08-17 18:40:08 +0200
committerTheo Chatzimichos <tampakrap@gentoo.org>2013-08-17 18:40:08 +0200
commit74d786945e2765244f3e0023038dd6b4f4345130 (patch)
tree84ee07e7aaaedf4c1876a7838b07f855186fa567 /okupy/tests
parentReplace get_ldap_connection with LDAPUser (diff)
downloadidentity.gentoo.org-74d786945e2765244f3e0023038dd6b4f4345130.tar.gz
identity.gentoo.org-74d786945e2765244f3e0023038dd6b4f4345130.tar.bz2
identity.gentoo.org-74d786945e2765244f3e0023038dd6b4f4345130.zip
Remove get_ldap_connection completely
Diffstat (limited to 'okupy/tests')
-rw-r--r--okupy/tests/unit/connection.py60
1 files changed, 0 insertions, 60 deletions
diff --git a/okupy/tests/unit/connection.py b/okupy/tests/unit/connection.py
deleted file mode 100644
index b3247c1..0000000
--- a/okupy/tests/unit/connection.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# vim:fileencoding=utf8:et:ts=4:sts=4:sw=4:ft=python
-
-from django.conf import settings
-from django.contrib.auth.models import User
-from django.test import TestCase
-from mockldap import MockLdap
-from passlib.hash import ldap_md5_crypt
-
-from ...common.ldap_helpers import get_ldap_connection
-from ...common.test_helpers import set_request
-
-import edpwd
-import ldap
-
-
-class ConnectionTests(TestCase):
- settings.DIRECTORY[settings.AUTH_LDAP_USER_DN_TEMPLATE % {'user':
- 'alice'}]['userPassword'].append(ldap_md5_crypt.encrypt('ldaptest2'))
-
- @classmethod
- def setUpClass(cls):
- cls.mockldap = MockLdap(settings.DIRECTORY)
-
- def setUp(self):
- self.mockldap.start()
- self.ldapobject = self.mockldap[settings.AUTH_LDAP_SERVER_URI]
-
- def tearDown(self):
- self.mockldap.stop()
-
- def test_connection_options(self):
- anon_ldap_user = get_ldap_connection()
- self.assertEqual(self.ldapobject.get_option(ldap.OPT_X_TLS_DEMAND), True)
- self.assertEqual(self.ldapobject.get_option(ldap.OPT_REFERRALS), 1)
-
- def test_called_functions(self):
- anon_ldap_user = get_ldap_connection()
- self.assertEqual(self.ldapobject.methods_called(), ['initialize', 'set_option', 'set_option', 'start_tls_s', 'simple_bind_s'])
-
- def test_get_anon_user(self):
- anon_ldap_user = get_ldap_connection()
- self.assertEqual(self.ldapobject.bound_as, 'cn=anon,o=test')
-
- def test_get_admin_user(self):
- admin_ldap_user = get_ldap_connection(admin=True)
- self.assertEqual(self.ldapobject.bound_as, 'cn=Manager,o=test')
-
- def test_get_defined_user(self):
- alice = get_ldap_connection(username='alice', password='ldaptest')
- self.assertEqual(self.ldapobject.bound_as, 'uid=alice,ou=people,o=test')
-
- def test_many_users_defined(self):
- self.assertRaises(TypeError, get_ldap_connection, username='alice', password='ldaptest', admin=True)
-
- def test_get_logged_in_user(self):
- alice = User.objects.create_user(username='alice', password='ldaptest')
- request = set_request(uri='/', user=alice)
- request.session['secondary_password'] = edpwd.encrypt(settings.SECRET_KEY, 'ldaptest2')
- alice = get_ldap_connection(request=request)
- self.assertEqual(self.ldapobject.bound_as, 'uid=alice,ou=people,o=test')