示例#1
0
 def test_ppolicy(self):
     """ Test password policy setting. """
     client = LDAPClient(self.url)
     self.assertRaises(TypeError, lambda: client.set_password_policy("F"))
     client.password_policy = True
     client.set_credentials("SIMPLE", ("cn=chuck,ou=nerdherd,dc=bonsai,dc=test",
                                       "p@ssword"))
     ret_val = client.connect()
     self.assertIsInstance(ret_val, tuple)
     self.assertIsInstance(ret_val[0], LDAPConnection)
     if ret_val[1] is None:
         pass
     elif type(ret_val[1]) == dict:
         self.assertIn("oid", ret_val[1].keys())
         self.assertIn("expire", ret_val[1].keys())
         self.assertIn("grace", ret_val[1].keys())
         self.assertEqual('1.3.6.1.4.1.42.2.27.8.5.1', ret_val[1]['oid'])
     else:
         self.fail("Invalid second object in the tuple.")
     ret_val[0].close()
示例#2
0
 def test_ppolicy(self):
     """ Test password policy setting. """
     client = LDAPClient(self.url)
     self.assertRaises(TypeError, lambda: client.set_password_policy("F"))
     client.password_policy = True
     client.set_credentials(
         "SIMPLE", ("cn=chuck,ou=nerdherd,dc=bonsai,dc=test", "p@ssword"))
     ret_val = client.connect()
     self.assertIsInstance(ret_val, tuple)
     self.assertIsInstance(ret_val[0], LDAPConnection)
     if ret_val[1] is None:
         pass
     elif type(ret_val[1]) == dict:
         self.assertIn("oid", ret_val[1].keys())
         self.assertIn("expire", ret_val[1].keys())
         self.assertIn("grace", ret_val[1].keys())
         self.assertEqual('1.3.6.1.4.1.42.2.27.8.5.1', ret_val[1]['oid'])
     else:
         self.fail("Invalid second object in the tuple.")
     ret_val[0].close()
示例#3
0
def test_ppolicy(url):
    """ Test password policy setting. """
    client = LDAPClient(url)
    with pytest.raises(TypeError):
        client.set_password_policy("F")
    client.password_policy = True
    client.set_credentials("SIMPLE", "cn=chuck,ou=nerdherd,dc=bonsai,dc=test",
                           "p@ssword")
    ret_val = client.connect()
    assert isinstance(ret_val, tuple)
    assert isinstance(ret_val[0], LDAPConnection)
    if ret_val[1] is None:
        pass  # Password policy is not supported.
    elif isinstance(ret_val[1], dict):
        assert "oid" in ret_val[1].keys()
        assert "expire" in ret_val[1].keys()
        assert "grace" in ret_val[1].keys()
        assert "1.3.6.1.4.1.42.2.27.8.5.1" == ret_val[1]["oid"]
    else:
        pytest.fail("Invalid second object in the tuple.")
    ret_val[0].close()