def setUp(self): # Connecting to a fake server with a fake account: conn = fakeldap.FakeLDAPConnection() conn.simple_bind_s('Manager', 'some password') # We must explicitly create the base_dn DIT components fakeldap.addTreeItems(base_dn) # Adding a fake user, which is used in the tests self.person_attr = { 'cn': [fakeuser['cn']], 'uid': fakeuser['uid'], 'userPassword': [fakeuser['hashedPassword']], 'telephone': [fakeuser['telephone']], 'objectClass': ['top'] } conn.add_s(fakeuser['dn'], modlist.addModlist(self.person_attr)) self.connection = conn
def test_with_connection(self): conn = fakeldap.FakeLDAPConnection() LDAPAuthenticatorPlugin(conn, 'dc=example,dc=org')
def test_without_base_dn(self): conn = fakeldap.FakeLDAPConnection() self.assertRaises(TypeError, LDAPAuthenticatorPlugin, conn) self.assertRaises(ValueError, LDAPAuthenticatorPlugin, conn, None)
def test_connection_is_object(self): conn = fakeldap.FakeLDAPConnection() self.assertEqual(make_ldap_connection(conn), conn)