/*
* 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.
*/
/**
* A set of test cases for the EncodePassword tool.
*/
public class EncodePasswordTestCase
extends ToolsTestCase
{
// The path to the Directory Server configuration file.
// The path to the temporary file containing a clear-text password.
// The path to the temporary file containing an encoded password.
/**
* Ensures that the Directory Server is running and gets the config file path.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
public void startServer()
throws Exception
{
}
/**
* Retrieves sets of invalid arguments that may not be used to initialize
* the EncodePassword tool.
*
* @return Sets of invalid arguments that may not be used to initialize the
* EncodePassword tool.
*/
{
{
"-C",
};
{
"-f",
};
{
"-c",
};
{
"-F",
};
{
"-e",
};
{
"-E",
};
{
"-s",
};
{
"-I"
};
{
"--invalidLongArgument"
};
{
"--configFile", configFilePath
};
{
"--configFile", configFilePath,
"--clearPassword", "password"
};
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--clearPasswordFile", passwordFilePath,
"--storageScheme", "SSHA"
};
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--encodedPassword", "password",
"--encodedPasswordFile", passwordFilePath
};
{
}
return returnArray;
}
/**
* Tests the EncodePassword tool with sets of invalid arguments.
*
* @param args The set of arguments to use for the ListBackends
* tool.
* @param invalidReason The reason the provided set of arguments is invalid.
*/
{
"Should have been invalid because: " + invalidReason);
}
/**
* Tests the EncodePassword tool with the --listSchemes argument.
*/
@Test()
public void testListSchemes()
{
{
"--configFile", configFilePath,
"--listSchemes"
};
}
/**
* Tests the EncodePassword tool with the --listSchemes and
* --authPasswordSyntax arguments.
*/
@Test()
public void testListAuthSchemes()
{
{
"--configFile", configFilePath,
"--listSchemes",
"--authPasswordSyntax"
};
}
/**
* Tests the EncodePassword tool with the --clearPassword and --storageScheme
* arguments.
*/
@Test()
public void testEncodeClearPassword()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--storageScheme", "SSHA"
};
}
/**
* Tests the EncodePassword tool with the --clearPassword, --storageScheme,
* and --authPasswordSyntax arguments.
*/
@Test()
public void testEncodeClearAuthPassword()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--storageScheme", "SHA1",
"--authPasswordSyntax"
};
}
/**
* Tests the EncodePassword tool with the --clearPasswordFile and
* --storageScheme arguments.
*/
@Test()
public void testEncodeClearPasswordFromFile()
{
{
"--configFile", configFilePath,
"--clearPasswordFile", passwordFilePath,
"--storageScheme", "SSHA"
};
}
/**
* Tests the EncodePassword tool with the --clearPasswordFile, --storageScheme,
* and --authPasswordSyntax arguments.
*/
@Test()
public void testEncodeClearAuthPasswordFromFile()
{
{
"--configFile", configFilePath,
"--clearPasswordFile", passwordFilePath,
"--storageScheme", "SHA1",
"--authPasswordSyntax"
};
}
/**
* Tests the EncodePassword tool with the --clearPassword and --storageScheme
* arguments using an invalid storage scheme.
*/
@Test()
public void testEncodeClearPasswordWithInvalidScheme()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--storageScheme", "invalid"
};
}
/**
* Tests the EncodePassword tool with the --clearPassword, --storageScheme,
* and --authPasswordSyntax arguments using an invalid storage scheme.
*/
@Test()
public void testEncodeClearPasswordWithInvalidAuthScheme()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--storageScheme", "invalid",
"--authPasswordSyntax"
};
}
/**
* Tests the EncodePassword tool with the --clearPasswordFile and
* --storageScheme arguments using an a password file that doesn't exist.
*/
@Test()
public void testEncodeClearPasswordFromMissingFile()
{
{
"--configFile", configFilePath,
"--storageScheme", "invalid"
};
}
/**
* Tests the EncodePassword tool with the --clearPasswordFile,
* --storageScheme, and --authPasswordSyntax arguments using an a password
* file that doesn't exist.
*/
@Test()
public void testEncodeClearAuthPasswordFromMissingFile()
{
{
"--configFile", configFilePath,
"--storageScheme", "invalid",
"--authPasswordSyntax"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a valid matching encoded password.
*/
@Test()
public void testCompareMatchingPasswordsNoScheme()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--encodedPassword", "{CLEAR}password"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a valid matching encoded password.
*/
@Test()
public void testCompareMatchingPasswordsWithScheme()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--storageScheme", "CLEAR",
"--encodedPassword", "password"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a valid matching encoded password.
*/
@Test()
public void testCompareMatchingEncodedPasswordsFromFile()
{
{
"--configFile", configFilePath,
"--clearPasswordFile", passwordFilePath,
"--encodedPasswordFile", encodedPasswordFilePath
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a valid matching auth password.
*/
@Test()
public void testCompareMatchingAuthPasswords()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--encodedPassword", "SHA1$dcKtMsOgc30=$MtHvXqXXJIRgxxw4xRXIY6ZLkQo=",
"--authPasswordSyntax"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a non-matching encoded password.
*/
@Test()
public void testCompareNonMatchingPasswordsNoScheme()
{
{
"--configFile", configFilePath,
"--clearPassword", "wrongpassword",
"--encodedPassword", "{CLEAR}password"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a non-matching encoded password.
*/
@Test()
public void testCompareNonMatchingPasswordsWithScheme()
{
{
"--configFile", configFilePath,
"--clearPassword", "wrongpassword",
"--storageScheme", "CLEAR",
"--encodedPassword", "password"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a non-matching auth password.
*/
@Test()
public void testCompareNonMatchingAuthPasswords()
{
{
"--configFile", configFilePath,
"--clearPassword", "wrongpassword",
"--encodedPassword", "SHA1$dcKtMsOgc30=$MtHvXqXXJIRgxxw4xRXIY6ZLkQo=",
"--authPasswordSyntax"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a valid matching encoded password using the LDAP compare result as an
* exit code.
*/
@Test()
public void testCompareMatchingPasswordsNoSchemeCompareResult()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--encodedPassword", "{CLEAR}password",
"--useCompareResultCode"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a valid matching encoded password using the LDAP compare result as an
* exit code.
*/
@Test()
public void testCompareMatchingPasswordsWithSchemeCompareResult()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--storageScheme", "CLEAR",
"--encodedPassword", "password",
"--useCompareResultCode"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a valid matching auth password using the LDAP compare result as an
* exit code.
*/
@Test()
public void testCompareMatchingAuthPasswordsCompareResult()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--encodedPassword", "SHA1$dcKtMsOgc30=$MtHvXqXXJIRgxxw4xRXIY6ZLkQo=",
"--authPasswordSyntax",
"--useCompareResultCode"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a non-matching encoded password using the LDAP compare result as an
* exit code.
*/
@Test()
public void testCompareNonMatchingPasswordsNoSchemeCompareResult()
{
{
"--configFile", configFilePath,
"--clearPassword", "wrongpassword",
"--encodedPassword", "{CLEAR}password",
"--useCompareResultCode"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a non-matching encoded password using the LDAP compare result as an
* exit code.
*/
@Test()
public void testCompareNonMatchingPasswordsWithSchemeCompareResult()
{
{
"--configFile", configFilePath,
"--clearPassword", "wrongpassword",
"--storageScheme", "CLEAR",
"--encodedPassword", "password",
"--useCompareResultCode"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a non-matching auth password using the LDAP compare result as an
* exit code.
*/
@Test()
public void testCompareNonMatchingAuthPasswordsCompareResult()
{
{
"--configFile", configFilePath,
"--clearPassword", "wrongpassword",
"--encodedPassword", "SHA1$dcKtMsOgc30=$MtHvXqXXJIRgxxw4xRXIY6ZLkQo=",
"--authPasswordSyntax",
"--useCompareResultCode"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with a malformed encoded auth password.
*/
@Test()
public void testCompareInvalidEncodedAuthPassword()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--encodedPassword", "malformedencodedauthpassword",
"--authPasswordSyntax"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with an encoded password that uses an unknown scheme.
*/
@Test()
public void testCompareEncodedPasswordWithUnknownScheme()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--encodedPassword", "{UNKNOWN}unknownscheme"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with an encoded password that uses an unknown scheme.
*/
@Test()
public void testCompareEncodedPasswordWithUnknownSeparateScheme()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--storageScheme", "unknown",
"--encodedPassword", "unknownscheme"
};
}
/**
* Tests the EncodePassword tool by performing a comparison of clear-text
* with an encoded auth password that uses an unknown scheme.
*/
@Test()
public void testCompareEncodedAuthPasswordWithUnknownScheme()
{
{
"--configFile", configFilePath,
"--clearPassword", "password",
"--encodedPassword", "UNKNOWN$AUTH$SCHEME",
"--authPasswordSyntax"
};
}
/**
* Tests the EncodePassword tool with the help options.
*/
@Test()
public void testHelp()
{
}
}