PasswordValidatorTestCase.java revision 24d6db06810f2ea747f6dff60d483e4fca3aaa13
/*
* 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
*
*
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
/**
* A set of generic test cases for password validators.
*/
public class PasswordValidatorTestCase
extends APITestCase
{
/**
* Ensures that the Directory Server is running.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
public void startServer()
throws Exception
{
}
/**
* Drops static references to allow garbage collection.
*/
public void shutdown()
{
}
/**
* Gets simple test coverage for the default
* PasswordValidator.finalizePasswordValidator method.
*/
@Test()
public void testFinalizePasswordValidator()
{
}
/**
* Performs a test to ensure that the password validation will be successful
* under the base conditions for the password modify extended operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSuccessfulValidationPasswordModifyExtOp()
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");
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-c", "password",
"-n", "newPassword"
};
0);
}
/**
* Performs a test to ensure that the password validation will fail if the
* test validator is configured to make it fail for the password modify
* extended operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testFailedValidationPasswordModifyExtOp()
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");
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-c", "password",
"-n", "newPassword"
};
null);
}
/**
* Performs a test to make sure that the clear-text password will not be
* provided if the user has a non-reversible scheme and does not provide the
* current password for a password modify extended operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testCurrentPasswordNotAvailablePasswordModifyExtOp()
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");
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-n", "newPassword"
};
0);
}
/**
* Performs a test to make sure that the clear-text password will be provided
* if the user has a non-reversible scheme but provides the current password
* for a password modify extended operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testCurrentPasswordAvailablePasswordModifyExtOp()
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");
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-c", "password",
"-n", "newPassword"
};
0);
}
/**
* Performs a test to make sure that the clear-text password will be provided
* if the user has a reversible scheme and does not provide the current
* password for a password modify extended operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testStoredPasswordAvailablePasswordModifyExtOp()
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",
"ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
"cn=Password Policies,cn=config");
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-n", "newPassword"
};
0);
}
/**
* Performs a test to make sure that the clear-text password will be provided
* if the user has a reversible scheme and also provides the current password
* for a password modify extended operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testStoredAndCurrentPasswordAvailablePasswordModifyExtOp()
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",
"ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
"cn=Password Policies,cn=config");
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-c", "password",
"-n", "newPassword"
};
0);
}
/**
* Performs a test to ensure that the password validation will be successful
* under the base conditions for the modify operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSuccessfulValidationModify()
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");
ASN1Reader r = new ASN1Reader(s);
ASN1Writer w = new ASN1Writer(s);
r.setIOTimeout(3000);
new ASN1OctetString("uid=test.user,o=test"),
}
/**
* Performs a test to ensure that the password validation will fail if the
* test validator is configured to make it fail for the modify operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testFailedValidationModify()
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");
ASN1Reader r = new ASN1Reader(s);
ASN1Writer w = new ASN1Writer(s);
r.setIOTimeout(3000);
new ASN1OctetString("uid=test.user,o=test"),
}
/**
* Performs a test to make sure that the clear-text password will be provided
* if the user has a non-reversible scheme but provides the current password
* for a modify operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testCurrentPasswordAvailableModify()
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");
ASN1Reader r = new ASN1Reader(s);
ASN1Writer w = new ASN1Writer(s);
r.setIOTimeout(3000);
new ASN1OctetString("uid=test.user,o=test"),
}
/**
* Performs a test to make sure that the clear-text password will be provided
* if the user has a reversible scheme and does not provide the current
* password for a modify operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testStoredPasswordAvailableModify()
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-privilege-name: bypass-acl",
"ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
"cn=Password Policies,cn=config");
ASN1Reader r = new ASN1Reader(s);
ASN1Writer w = new ASN1Writer(s);
r.setIOTimeout(3000);
new ASN1OctetString("uid=test.user,o=test"),
}
/**
* Performs a test to make sure that the clear-text password will be provided
* if the user has a reversible scheme and also provides the current password
* for a modify operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testStoredAndCurrentPasswordAvailableModify()
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-privilege-name: bypass-acl",
"ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
"cn=Password Policies,cn=config");
ASN1Reader r = new ASN1Reader(s);
ASN1Writer w = new ASN1Writer(s);
r.setIOTimeout(3000);
new ASN1OctetString("uid=test.user,o=test"),
}
}