コード例 #1
0
 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
コード例 #2
0
 def test_with_connection(self):
     conn = fakeldap.FakeLDAPConnection()
     LDAPAuthenticatorPlugin(conn, 'dc=example,dc=org')
コード例 #3
0
 def test_without_base_dn(self):
     conn = fakeldap.FakeLDAPConnection()
     self.assertRaises(TypeError, LDAPAuthenticatorPlugin, conn)
     self.assertRaises(ValueError, LDAPAuthenticatorPlugin, conn, None)
コード例 #4
0
 def test_connection_is_object(self):
     conn = fakeldap.FakeLDAPConnection()
     self.assertEqual(make_ldap_connection(conn), conn)