LDAPPasswordModifyTestCase.java revision 2efcb9667318c099d8723dd578f198c16b4a22c4
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
*/
/**
* A set of test cases for the LDAPPasswordModify tool.
*/
public class LDAPPasswordModifyTestCase
extends ToolsTestCase
{
// The path to a file containing the current bind password.
private String currentPasswordFile;
// The path to a file containing the new password.
private String newPasswordFile;
/**
* Ensures that the Directory Server is running and performs other necessary
* setup.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
public void startServerAndCreatePasswordFiles()
throws Exception
{
fileWriter.close();
fileWriter.close();
}
/**
* Retrieves sets of invalid arguments that may not be used to initialize
* the LDAPModify tool.
*
* @return Sets of invalid arguments that may not be used to initialize the
* LDAPModify tool.
*/
public Object[][] getInvalidArgumentLists()
{
{
"-h"
};
{
"-p"
};
{
"-D"
};
{
"-w"
};
{
"-j"
};
{
"-a"
};
{
"-n"
};
{
"-N"
};
{
"-c"
};
{
"-C"
};
{
"-K"
};
{
"-W"
};
{
"--keyStorePasswordFile"
};
{
"-P"
};
{
"--trustStorePassword"
};
{
"--trustStorePasswordFile"
};
{
"-D", "cn=Directory Manager",
"-j", "no.such.file"
};
{
"-D", "cn=Directory Manager",
"-w", "password",
"-j", currentPasswordFile
};
{
"-D", "cn=Directory Manager",
"-c", "password",
"-C", currentPasswordFile
};
{
"-D", "cn=Directory Manager",
"-n", "password",
"-N", newPasswordFile
};
{
"-Z",
"-q"
};
{
"-p", "nonnumeric"
};
{
"-p", "999999"
};
{
"-D", "cn=Directory Manager"
};
{
"-w", "password"
};
{
"-j", currentPasswordFile
};
{
"-a", "u:test.user"
};
{
"-A"
};
{
}
return returnArray;
}
/**
* Tests the LDAPModify tool with sets of invalid arguments.
*
* @param args The set of arguments to use for the LDAPModify tool.
* @param invalidReason The reason the provided arguments were invalid.
*/
{
null) == 0,
"Should have been invalid because: " + invalidReason);
}
/**
* Add a test user.
*/
private static void addTestUser() throws Exception
{
"dn: uid=test.user,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"ds-privilege-name: bypass-acl",
"userPassword: password");
}
/**
* Tests the ability to perform a self change including both the current and
* new passwords.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSelfChangeCurrentPasswordNewPassword()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-c", "password",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform a self change including a new password but no
* current password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSelfChangeNoCurrentPasswordNewPassword()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform a self change including the current password
* but no new password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSelfChangeCurrentPasswordNoNewPassword()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-c", "password",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform a self change including neither the current
* nor new passwords.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSelfChangeNoCurrentPasswordNoNewPassword()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform an authenticated self change including an
* explicit authorization ID, a current password, and a new password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testAuthenticatedSelfExplicitAuthzIDCurrentNew()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-a", "u:test.user",
"-c", "password",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform an authenticated self change including an
* implicit authorization ID, a current password, and a new password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testAuthenticatedSelfImplicitAuthzIDCurrentNew()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-A",
"-c", "password",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform an authenticated self change including an
* implicit authorization ID, an implicit current password, and an explicit
* new password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testAuthenticatedSelfImplicitAuthzIDNoCurrentNew()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-A",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform an unauthenticated self change with a new
* password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testUnauthenticatedSelfChangeNewPassword()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-a", "dn:uid=test.user,o=test",
"-c", "password",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform an unauthenticated self change with no new
* password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testUnauthenticatedSelfChangeNoNewPassword()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-a", "dn:uid=test.user,o=test",
"-c", "password",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform an administrative reset with a new password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testAdminResetNewPassword()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-a", "dn:uid=test.user,o=test",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform an administrative reset with no new password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testAdminResetNoNewPassword()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-a", "dn:uid=test.user,o=test",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform a password change over SSL with blind trust.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSSLBlindTrust()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-Z",
"-X",
"-a", "dn:uid=test.user,o=test",
"-c", "password",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform a password change over SSL with a trust store.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSSLTrustStore()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-Z",
"-P", trustStorePath,
"-a", "dn:uid=test.user,o=test",
"-c", "password",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform a password change using StartTLS with blind
* trust.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testStartTLSBlindTrust()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-q",
"-X",
"-a", "dn:uid=test.user,o=test",
"-c", "password",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform a password change using StartTLS with a trust
* store.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testStartTLSTrustStore()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-q",
"-P", trustStorePath,
"-a", "dn:uid=test.user,o=test",
"-c", "password",
"-n", "newPassword",
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform a password reset when reading the bind and new
* passwords from a file.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testBindAndNewPasswordsFromFile()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-j", currentPasswordFile,
"-a", "dn:uid=test.user,o=test",
"-N", newPasswordFile,
"--noPropertiesFile"
};
0);
}
/**
* Tests the ability to perform a password change when reading the current and
* new passwords from a file.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testCurrentAndNewPasswordsFromFile()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-a", "u:test.user",
"-C", currentPasswordFile,
"-N", newPasswordFile,
"--noPropertiesFile"
};
0);
}
/**
* Tests a failure when attempting an administrative reset with an invalid DN
* in the authorization ID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testResetWithInvalidAuthzDN()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-a", "dn:invalid",
"-n", "newPassword",
"--noPropertiesFile"
};
null) == 0);
}
/**
* Tests a failure when attempting an administrative reset on a user entry
* that doesn't exist.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testResetOnNonExistentUser()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-a", "dn:cn=Does Not Exist,o=test",
"-n", "newPassword",
"--noPropertiesFile"
};
null) == 0);
}
/**
* Tests a failure when attempting an administrative reset on a user entry
* that has been disabled. Also include the password policy control in the
* request.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testResetOnDisabledUser()
throws Exception
{
"dn: uid=test.user,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"userPassword: password",
"ds-pwp-account-disabled: true");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-a", "dn:uid=test.user,o=test",
"-n", "newPassword",
"-J", "pwpolicy:true",
"--noPropertiesFile"
};
null) == 0);
}
/**
* Tests the password modify extended operation in conjunction with a control
* that is marked critical but that is not supported by the server.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testUnsupportedCriticalControl()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-a", "dn:uid=test.user,o=test",
"-n", "newPassword",
"-J", "1.2.3.4:true",
"--noPropertiesFile"
};
== 0);
}
/**
* Tests the password modify extended operation in conjunction with the LDAP
* no-op control using the explicit OID for that control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLDAPNoOpExplicitOID()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-a", "dn:uid=test.user,o=test",
"-n", "newPassword",
"--noPropertiesFile"
};
}
/**
* Tests the password modify extended operation in conjunction with the LDAP
* no-op control using a more user-friendly name instead of an OID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLDAPNoOpImplicitOID()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-a", "dn:uid=test.user,o=test",
"-n", "newPassword",
"-J", "noop:true",
"--noPropertiesFile"
};
}
/**
* Tests the password modify extended operation in conjunction with multiple
* request controls.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLDAPMultipleControls()
throws Exception
{
addTestUser();
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-a", "dn:uid=test.user,o=test",
"-n", "newPassword",
"--noPropertiesFile"
};
}
/**
* Tests the LDAPModify tool with the "--help" option.
*/
@Test()
public void testHelp()
{
0);
0);
0);
}
}