RandomPasswordGeneratorTestCase.java revision ea1068c292e9b341af6d6b563cd8988a96be20a9
/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* 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.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* A set of test cases for the random password generator.
*/
public class RandomPasswordGeneratorTestCase
extends ExtensionsTestCase
{
/**
* Ensures that the Directory Server is running.
*
* @throws Exception If an unexpected problem occurs.
*/
public void startServer()
throws Exception
{
}
/**
* Tests the password generator with the default configuration.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testDefaultConfiguration()
throws Exception
{
"cn=config");
configEntry.getEntry());
}
/**
* Retrieves a set of LDIF representations for invalid configuration entries.
*
* @return A set of LDIF representations for invalid configuration entries.
*
* @throws Exception If an unexpected problem occurs.
*/
public Object[][] getInvalidConfigEntries()
throws Exception
{
"dn: cn=Random Password Generator,cn=Password Generators,cn=config",
"objectClass: top",
"objectClass: ds-cfg-password-generator",
"cn: Random Password Generator",
"ds-cfg-java-class: " +
"org.opends.server.extensions.RandomPasswordGenerator",
"ds-cfg-enabled: true",
"",
"dn: cn=Random Password Generator,cn=Password Generators,cn=config",
"objectClass: top",
"objectClass: ds-cfg-password-generator",
"objectClass: ds-cfg-random-password-generator",
"cn: Random Password Generator",
"ds-cfg-java-class: " +
"org.opends.server.extensions.RandomPasswordGenerator",
"ds-cfg-enabled: true",
"ds-cfg-password-character-set:",
"",
"dn: cn=Random Password Generator,cn=Password Generators,cn=config",
"objectClass: top",
"objectClass: ds-cfg-password-generator",
"objectClass: ds-cfg-random-password-generator",
"cn: Random Password Generator",
"ds-cfg-java-class: " +
"org.opends.server.extensions.RandomPasswordGenerator",
"ds-cfg-enabled: true",
"ds-cfg-password-character-set: foo:",
"ds-cfg-password-format: foo:8",
"",
"dn: cn=Random Password Generator,cn=Password Generators,cn=config",
"objectClass: top",
"objectClass: ds-cfg-password-generator",
"objectClass: ds-cfg-random-password-generator",
"cn: Random Password Generator",
"ds-cfg-java-class: " +
"org.opends.server.extensions.RandomPasswordGenerator",
"ds-cfg-enabled: true",
"ds-cfg-password-character-set: foo:abcd",
"ds-cfg-password-character-set: foo:efgh",
"ds-cfg-password-format: foo:8",
"",
"dn: cn=Random Password Generator,cn=Password Generators,cn=config",
"objectClass: top",
"objectClass: ds-cfg-password-generator",
"objectClass: ds-cfg-random-password-generator",
"cn: Random Password Generator",
"ds-cfg-java-class: " +
"org.opends.server.extensions.RandomPasswordGenerator",
"ds-cfg-enabled: true",
"ds-cfg-password-character-set: foo:abcd",
"",
"dn: cn=Random Password Generator,cn=Password Generators,cn=config",
"objectClass: top",
"objectClass: ds-cfg-password-generator",
"objectClass: ds-cfg-random-password-generator",
"cn: Random Password Generator",
"ds-cfg-java-class: " +
"org.opends.server.extensions.RandomPasswordGenerator",
"ds-cfg-enabled: true",
"ds-cfg-password-character-set: foo:abcd",
"ds-cfg-password-format: bar:8",
"",
"dn: cn=Random Password Generator,cn=Password Generators,cn=config",
"objectClass: top",
"objectClass: ds-cfg-password-generator",
"objectClass: ds-cfg-random-password-generator",
"cn: Random Password Generator",
"ds-cfg-java-class: " +
"org.opends.server.extensions.RandomPasswordGenerator",
"ds-cfg-enabled: true",
"ds-cfg-password-character-set: foo:abcd",
"ds-cfg-password-format: foo:abcd"
);
{
}
return entryObjects;
}
/**
* Tests with an invalid configuration entry.
*
* @param entry The invalid configuration entry to use for testing.
*
* @throws Exception If an unexpected problem occurs.
*/
expectedExceptions = { ConfigException.class,
InitializationException.class })
throws Exception
{
entry);
}
}