Beispiel #1
0
 def test_extended_dn(self):
     """ Test extended dn control. """
     client = LDAPClient(self.url)
     self.assertRaises(TypeError, lambda: client.set_extended_dn("A"))
     self.assertRaises(ValueError, lambda: client.set_extended_dn(2))
     client.extended_dn_format = 0
     self.assertEqual(client.extended_dn_format, 0)
     conn = client.connect()
     root_dse = client.get_rootDSE()
     result = conn.search("ou=nerdherd,dc=bonsai,dc=test", 0)[0]
     if '1.2.840.113556.1.4.529' in root_dse['supportedControl']:
         self.assertIsNotNone(result.extended_dn)
         self.assertEqual(result.extended_dn.split(';')[-1], str(result.dn))
     else:
         self.assertIsNone(result.extended_dn)
Beispiel #2
0
 def test_extended_dn(self):
     """ Test extended dn control. """
     client = LDAPClient(self.url)
     self.assertRaises(TypeError, lambda: client.set_extended_dn("A"))
     self.assertRaises(ValueError, lambda: client.set_extended_dn(2))
     client.extended_dn_format = 0
     self.assertEqual(client.extended_dn_format, 0)
     conn = client.connect()
     root_dse = client.get_rootDSE()
     result = conn.search("ou=nerdherd,dc=bonsai,dc=test", 0)[0]
     if '1.2.840.113556.1.4.529' in root_dse['supportedControl']:
         self.assertIsNotNone(result.extended_dn)
         self.assertEqual(result.extended_dn.split(';')[-1], str(result.dn))
     else:
         self.assertIsNone(result.extended_dn)
Beispiel #3
0
def test_extended_dn(url):
    """ Test extended dn control. """
    client = LDAPClient(url)
    with pytest.raises(TypeError):
        client.set_extended_dn("A")
    with pytest.raises(ValueError):
        client.set_extended_dn(2)
    client.extended_dn_format = 0
    assert client.extended_dn_format == 0
    conn = client.connect()
    root_dse = client.get_rootDSE()
    result = conn.search("ou=nerdherd,dc=bonsai,dc=test", 0)[0]
    if "1.2.840.113556.1.4.529" in root_dse["supportedControl"]:
        assert result.extended_dn is not None
        assert result.extended_dn.split(";")[-1] == str(result.dn)
    else:
        assert result.extended_dn is None