String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
String attr = "ds-cfg-require-secure-password-changes";
ArrayList<Modification> mods = new ArrayList<Modification>();
mods.add(new Modification(ModificationType.REPLACE,
Attributes.create(attr, "true")));
ModifyOperation modifyOperation =
conn.processModify(DN.decode(dnStr), mods);
assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
String[] args =
{
"--noPropertiesFile",
"-h", "127.0.0.1",
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "uid=test.user,o=test",
"-w", "password",
"-c", "password",
"-n", "newPassword"
};
int exitCode =
LDAPPasswordModify.mainPasswordModify(args, false, null, null);
assertEquals(exitCode, 13);
mods.clear();
mods.add(new Modification(ModificationType.REPLACE,
Attributes.create(attr, "false")));
modifyOperation = conn.processModify(DN.decode(dnStr), mods);
assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
}