Exemple #1
0
 def setUp(self):
     self.client = LDAPClient("ldap://192.168.1.83")
     self.client.connect("cn=admin,dc=local", "p@ssword")
     self.entry = LDAPEntry("cn=test,dc=local", self.client)
     self.entry['objectclass'] = [
         'top', 'inetOrgPerson', 'person', 'organizationalPerson'
     ]
     self.entry['sn'] = "Test"
Exemple #2
0
 def test_bind_digest(self):
     client = LDAPClient(self.url)
     try:
         client.connect(mechanism="DIGEST-MD5", 
                        username="******",
                        password="******")
     except (pyLDAP.errors.ConnectionError, pyLDAP.errors.AuthenticationError):
         self.fail()
     client.close()
Exemple #3
0
class LDAPClientTest(unittest.TestCase):
    def setUp(self):
        self.url = "ldap://192.168.1.83/dc=local?cn?sub"
        self.client = LDAPClient(self.url)
        self.client.connect("cn=admin,dc=local", "p@ssword")
        
    def tearDown(self):
        self.client.close()
        del self.client
        
    def test_bind_digest(self):
        client = LDAPClient(self.url)
        try:
            client.connect(mechanism="DIGEST-MD5", 
                           username="******",
                           password="******")
        except (pyLDAP.errors.ConnectionError, pyLDAP.errors.AuthenticationError):
            self.fail()
        client.close()
        
    def test_search(self):
        o = self.client.search("dc=local", 2)
        self.assertIsNotNone(o)
        self.assertEqual(o, self.client.search())
        
    def test_rootdse(self):
        self.assertEqual(self.client.get_rootDSE()['supportedLDAPVersion'], ["3"])
 
    def test_getentry(self):
        o = self.client.get_entry("cn=admin,dc=local")
        self.assertIsInstance(o, LDAPEntry)
        
    def test_whoami(self):
        o = self.client.whoami()
        self.assertEqual(o, "dn:cn=admin,dc=local")
Exemple #4
0
class LDAPEntryTest(unittest.TestCase):
    def setUp(self):
        self.client = LDAPClient("ldap://192.168.1.83")
        self.client.connect("cn=admin,dc=local", "p@ssword")
        self.entry = LDAPEntry("cn=test,dc=local", self.client)
        self.entry['objectclass'] = [
            'top', 'inetOrgPerson', 'person', 'organizationalPerson'
        ]
        self.entry['sn'] = "Test"

    def tearDown(self):
        self.client.close()
        del self.entry

    def test_operations(self):
        try:
            self.entry.add()
        except:
            self.fail("Add failed")
        self.entry.rename("cn=test2,dc=local")
        self.assertEqual(str(self.entry.dn), "cn=test2,dc=local")
        o = self.client.get_entry("cn=test,dc=local")
        self.assertIsNone(o)
        self.entry['sn'] = "Test_modify"
        try:
            self.entry.modify()
        except:
            self.fail("Modify failed.")
        o = self.client.get_entry("cn=test2,dc=local")
        self.assertEqual(self.entry['sn'], o['sn'])
        try:
            self.entry.delete()
        except:
            self.fail("Delete failed.")

    def get_mail(self):
        return self.entry['mail']

    def set_same(self):
        self.entry['GivenName'].extend(['teSt', "test3"])

    def test_update(self):
        self.entry.update({"GivenName": "test2", "mail": "test@mail"})
        self.entry.update([("sn", "test")])
        self.assertEqual(self.entry['mail'], ['test@mail'])
        self.assertEqual(self.entry['givenname'], ['test2'])
        self.assertEqual(self.entry['sn'][0], 'test')

    def test_ci(self):
        self.entry['givenName'] = "test"
        self.entry['mail'] = "test@mail"
        self.assertEqual(self.entry['GiVenName'], self.entry['givenname'])
        del self.entry['mAil']
        self.assertRaises(KeyError, self.get_mail)

    def test_append(self):
        self.entry['givenName'] = "test"
        self.entry['givenname'].append("test2")
        self.assertEqual(self.entry['givenname'], ["test", "test2"])
        self.assertRaises(TypeError, self.set_same)
Exemple #5
0
class LDAPEntryTest(unittest.TestCase):
    def setUp(self):
        self.client = LDAPClient("ldap://192.168.1.83")
        self.client.connect("cn=admin,dc=local", "p@ssword")
        self.entry = LDAPEntry("cn=test,dc=local", self.client)
        self.entry["objectclass"] = ["top", "inetOrgPerson", "person", "organizationalPerson"]
        self.entry["sn"] = "Test"

    def tearDown(self):
        self.client.close()
        del self.entry

    def test_operations(self):
        try:
            self.entry.add()
        except:
            self.fail("Add failed")
        self.entry.rename("cn=test2,dc=local")
        self.assertEqual(str(self.entry.dn), "cn=test2,dc=local")
        o = self.client.get_entry("cn=test,dc=local")
        self.assertIsNone(o)
        self.entry["sn"] = "Test_modify"
        try:
            self.entry.modify()
        except:
            self.fail("Modify failed.")
        o = self.client.get_entry("cn=test2,dc=local")
        self.assertEqual(self.entry["sn"], o["sn"])
        try:
            self.entry.delete()
        except:
            self.fail("Delete failed.")

    def get_mail(self):
        return self.entry["mail"]

    def set_same(self):
        self.entry["GivenName"].extend(["teSt", "test3"])

    def test_update(self):
        self.entry.update({"GivenName": "test2", "mail": "test@mail"})
        self.entry.update([("sn", "test")])
        self.assertEqual(self.entry["mail"], ["test@mail"])
        self.assertEqual(self.entry["givenname"], ["test2"])
        self.assertEqual(self.entry["sn"][0], "test")

    def test_ci(self):
        self.entry["givenName"] = "test"
        self.entry["mail"] = "test@mail"
        self.assertEqual(self.entry["GiVenName"], self.entry["givenname"])
        del self.entry["mAil"]
        self.assertRaises(KeyError, self.get_mail)

    def test_append(self):
        self.entry["givenName"] = "test"
        self.entry["givenname"].append("test2")
        self.assertEqual(self.entry["givenname"], ["test", "test2"])
        self.assertRaises(TypeError, self.set_same)
Exemple #6
0
 def test_bind_digest(self):
     client = LDAPClient(self.url)
     try:
         client.connect(mechanism="DIGEST-MD5",
                        username="******",
                        password="******")
     except (pyLDAP.errors.ConnectionError,
             pyLDAP.errors.AuthenticationError):
         self.fail()
     client.close()
Exemple #7
0
class LDAPClientTest(unittest.TestCase):
    def setUp(self):
        self.url = "ldap://192.168.1.83/dc=local?cn?sub"
        self.client = LDAPClient(self.url)
        self.client.connect("cn=admin,dc=local", "p@ssword")

    def tearDown(self):
        self.client.close()
        del self.client

    def test_bind_digest(self):
        client = LDAPClient(self.url)
        try:
            client.connect(mechanism="DIGEST-MD5",
                           username="******",
                           password="******")
        except (pyLDAP.errors.ConnectionError,
                pyLDAP.errors.AuthenticationError):
            self.fail()
        client.close()

    def test_search(self):
        o = self.client.search("dc=local", 2)
        self.assertIsNotNone(o)
        self.assertEqual(o, self.client.search())

    def test_rootdse(self):
        self.assertEqual(self.client.get_rootDSE()['supportedLDAPVersion'],
                         ["3"])

    def test_getentry(self):
        o = self.client.get_entry("cn=admin,dc=local")
        self.assertIsInstance(o, LDAPEntry)

    def test_whoami(self):
        o = self.client.whoami()
        self.assertEqual(o, "dn:cn=admin,dc=local")
Exemple #8
0
class LDAPEntryTest(unittest.TestCase):
    def setUp(self):
        self.client = LDAPClient("ldap://192.168.1.83")
        self.client.connect("cn=admin,dc=local", "p@ssword")
        self.entry = LDAPEntry("cn=test,dc=local", self.client)
        self.entry['objectclass'] = ['top', 'inetOrgPerson', 'person', 'organizationalPerson']
        self.entry['sn'] = "Test"
        
    def tearDown(self):
        self.client.close()
        del self.entry
        
    def test_operations(self):
        try:
            self.entry.add()
        except:
            self.fail("Add failed")
        self.entry.rename("cn=test2,dc=local")
        self.assertEqual(str(self.entry.dn), "cn=test2,dc=local")
        o = self.client.get_entry("cn=test,dc=local")
        self.assertIsNone(o)
        self.entry['sn'] = "Test_modify"
        try:
            self.entry.modify()
        except:
            self.fail("Modify failed.")
        o = self.client.get_entry("cn=test2,dc=local")
        self.assertEqual(self.entry['sn'], o['sn'])
        try:
            self.entry.delete()
        except:
            self.fail("Delete failed.")
            
    def test_ci(self):
        self.entry['givenName'] = "test"
        self.assertEqual(self.entry['GiVenName'], self.entry['givenname'])
Exemple #9
0
 def setUp(self):
     self.client = LDAPClient("ldap://192.168.1.83")
     self.client.connect("cn=admin,dc=local", "p@ssword")
     self.entry = LDAPEntry("cn=test,dc=local", self.client)
     self.entry["objectclass"] = ["top", "inetOrgPerson", "person", "organizationalPerson"]
     self.entry["sn"] = "Test"
Exemple #10
0
 def setUp(self):
     self.url = "ldap://192.168.1.83/dc=local?cn?sub"
     self.client = LDAPClient(self.url)
     self.client.connect("cn=admin,dc=local", "p@ssword")
Exemple #11
0
 def setUp(self):
     self.url = "ldap://192.168.1.83/dc=local?cn?sub"
     self.client = LDAPClient(self.url)
     self.client.connect("cn=admin,dc=local", "p@ssword")
Exemple #12
0
 def setUp(self):
     self.client = LDAPClient("ldap://192.168.1.83")
     self.client.connect("cn=admin,dc=local", "p@ssword")
     self.entry = LDAPEntry("cn=test,dc=local", self.client)
     self.entry['objectclass'] = ['top', 'inetOrgPerson', 'person', 'organizationalPerson']
     self.entry['sn'] = "Test"