public class AuthenticationTest extends BaseJDBCTestCase
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
apollo |
private static java.lang.String |
BUILTIN_ALGO_PROP |
private static java.lang.String |
BUILTIN_ITERATIONS_PROP |
private static java.lang.String |
BUILTIN_SALT_LENGTH_PROP |
private static java.lang.String |
NO_SUCH_ALGO |
private static java.lang.String |
PASSWORD_SUFFIX |
private static java.lang.String |
USER_PREFIX |
private static java.lang.String[] |
USERS |
private static java.lang.String |
zeus |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE| Constructor and Description |
|---|
AuthenticationTest(java.lang.String name)
Creates a new instance of the Test
|
| Modifier and Type | Method and Description |
|---|---|
void |
assertConnectionFail(java.lang.String dbName) |
protected void |
assertConnectionFail(java.lang.String expectedSqlState,
java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertConnectionOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertConnectionWOUPFail(java.lang.String expectedError,
java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertConnectionWOUPOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertFailSetDatabaseProperty(java.lang.String propertyName,
java.lang.String value,
java.sql.Connection conn) |
private void |
assertNormalUserName(java.lang.String normalUserName,
java.sql.Connection connUser)
Assert that the user name returned by various mechanisms
matches the normal user name.
|
protected void |
assertShutdownFail(java.lang.String expectedSqlState,
java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertShutdownOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertShutdownUsingConnAttrsOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertShutdownUsingSetShutdownOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertShutdownWOUPFail(java.lang.String expectedSqlState,
java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertShutdownWOUPOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertSystemShutdownFail(java.lang.String expectedError,
java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertSystemShutdownOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password) |
protected void |
assertUserValue(java.lang.String[] expected,
java.lang.String user,
java.lang.String sql) |
protected void |
assertUserValue(java.lang.String[] expected,
java.lang.String user,
java.lang.String password,
java.lang.String sql) |
static junit.framework.Test |
baseSuite(java.lang.String name) |
protected void |
initializeConnection(java.sql.Connection conn)
Ensure all connections are not in auto commit mode.
|
protected static void |
setBaseProps(junit.framework.TestSuite suite,
junit.framework.Test test) |
private static void |
setBaseProps(junit.framework.TestSuite suite,
junit.framework.Test test,
java.util.Properties extraDbProps) |
(package private) void |
setDatabaseProperty(java.lang.String propertyName,
java.lang.String value)
Set a database property in the default connection.
|
protected void |
setDatabaseProperty(java.lang.String propertyName,
java.lang.String value,
java.sql.Connection conn) |
protected void |
setUp() |
static junit.framework.Test |
suite() |
private boolean |
supportsAlgorithm(java.lang.String algorithm)
Check if a message digest algorithm is supported on this platform.
|
protected void |
tearDown()
Tear down this fixture, sub-classes should call
super.tearDown().
|
void |
testChangePasswordAndDatabasePropertiesOnly() |
void |
testConnectShutdownAuthentication() |
void |
testDefaultHashAlgorithm()
DERBY-4483: Test that the database by default has the configurable
hash authentication scheme enabled.
|
void |
testDerby5507PlaintextPassword()
DERBY-5507: Setting a user's password as a database property, when
that user's password is already set as a system property, used to make
the password getting stored in plaintext in the database.
|
void |
testGreekCharacters() |
void |
testInvalidAlgorithmName()
DERBY-4483: Test that we fail gracefully if an invalid algorithm name
is specified in
derby.authentication.builtin.algorithm. |
void |
testNoCollisionsWithConfigurableHash()
DERBY-4483: Test that slightly different passwords result in different
hashes, and also that using the same password for different users
results in a unique hashes with the configurable hash authentication
scheme.
|
void |
testNotFullAccessUsers() |
void |
testSystemShutdown() |
void |
testUserAccessRoutines()
Test the procedure and function that provide short-cuts
to setting and getting connection level access.
|
void |
testUserCasing()
Test how user names behave with casing.
|
void |
testUserFunctions() |
void |
testVariousBuiltinAlgorithms()
DERBY-4483: Test that setting the property
derby.authentication.builtin.algorithm changes which hash
algorithm is used to protect the stored password token. |
private void |
testVariousBuiltinAlgorithms(java.lang.String algo,
boolean keyStretching)
Worker method for
testVariousBuiltinAlgorithms(). |
private void |
userCasingTest(java.lang.String jdbcUserName,
java.lang.String normalUserName,
java.sql.Connection connUser) |
private void |
userCasingTest(java.lang.String jdbcUserName,
java.lang.String normalUserName,
java.lang.String password)
Test the user casing obtaining connections a variety of ways.
|
protected void |
useUserValue(int expectedUpdateCount,
java.lang.String user,
java.lang.String sql) |
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, emptyStatementCache, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbeddedalarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isJava8, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemProperty, sleep, sleepAtLeastOneTick, traceitassertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, toStringprivate static final java.lang.String PASSWORD_SUFFIX
private static final java.lang.String[] USERS
private static final java.lang.String zeus
private static final java.lang.String apollo
private static final java.lang.String BUILTIN_ALGO_PROP
private static final java.lang.String BUILTIN_SALT_LENGTH_PROP
private static final java.lang.String BUILTIN_ITERATIONS_PROP
private static final java.lang.String USER_PREFIX
private static final java.lang.String NO_SUCH_ALGO
public AuthenticationTest(java.lang.String name)
protected void initializeConnection(java.sql.Connection conn)
throws java.sql.SQLException
initializeConnection in class BaseJDBCTestCaseconn - Connection to be intializedjava.sql.SQLException - Error setting the initial state.public static junit.framework.Test suite()
public static junit.framework.Test baseSuite(java.lang.String name)
protected static void setBaseProps(junit.framework.TestSuite suite,
junit.framework.Test test)
private static void setBaseProps(junit.framework.TestSuite suite,
junit.framework.Test test,
java.util.Properties extraDbProps)
protected void setUp()
throws java.lang.Exception
setUp in class junit.framework.TestCasejava.lang.Exceptionprotected void tearDown()
throws java.lang.Exception
BaseJDBCTestCasetearDown in class BaseJDBCTestCasejava.lang.Exceptionpublic void testUserCasing()
throws java.sql.SQLException
java.sql.SQLExceptionprivate void userCasingTest(java.lang.String jdbcUserName,
java.lang.String normalUserName,
java.lang.String password)
throws java.sql.SQLException
jdbcUserName - User name to be used to obtain the connection via JDBCnormalUserName - Normalized form of the user connection.password - Password for the user.java.sql.SQLExceptionprivate void userCasingTest(java.lang.String jdbcUserName,
java.lang.String normalUserName,
java.sql.Connection connUser)
throws java.sql.SQLException
jdbcUserName - User name as passed into the JDBC connection request.normalUserName - Normalized user name.connUser - Connection for the user, closed by this method.java.sql.SQLExceptionprivate void assertNormalUserName(java.lang.String normalUserName,
java.sql.Connection connUser)
throws java.sql.SQLException
normalUserName - connUser - java.sql.SQLExceptionpublic void testConnectShutdownAuthentication()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testUserFunctions()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testChangePasswordAndDatabasePropertiesOnly()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testNotFullAccessUsers()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testUserAccessRoutines()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testGreekCharacters()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testSystemShutdown()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testDefaultHashAlgorithm()
throws java.sql.SQLException
java.sql.SQLExceptionprivate boolean supportsAlgorithm(java.lang.String algorithm)
algorithm - the algorithm to checkpublic void testVariousBuiltinAlgorithms()
throws java.sql.SQLException
derby.authentication.builtin.algorithm changes which hash
algorithm is used to protect the stored password token.java.sql.SQLExceptionprivate void testVariousBuiltinAlgorithms(java.lang.String algo,
boolean keyStretching)
throws java.sql.SQLException
testVariousBuiltinAlgorithms().algo - the name of the hash algorithm to testkeyStretching - whether or not to use the authentication scheme that
performs key stretchingjava.sql.SQLExceptionpublic void testNoCollisionsWithConfigurableHash()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testInvalidAlgorithmName()
throws java.sql.SQLException
derby.authentication.builtin.algorithm.java.sql.SQLExceptionpublic void testDerby5507PlaintextPassword()
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertFailSetDatabaseProperty(java.lang.String propertyName,
java.lang.String value,
java.sql.Connection conn)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void setDatabaseProperty(java.lang.String propertyName,
java.lang.String value,
java.sql.Connection conn)
throws java.sql.SQLException
java.sql.SQLExceptionvoid setDatabaseProperty(java.lang.String propertyName,
java.lang.String value)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void useUserValue(int expectedUpdateCount,
java.lang.String user,
java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertUserValue(java.lang.String[] expected,
java.lang.String user,
java.lang.String password,
java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertUserValue(java.lang.String[] expected,
java.lang.String user,
java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertConnectionOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertConnectionWOUPOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertConnectionFail(java.lang.String expectedSqlState,
java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertConnectionWOUPFail(java.lang.String expectedError,
java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertShutdownUsingSetShutdownOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertShutdownUsingConnAttrsOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertShutdownWOUPOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertShutdownFail(java.lang.String expectedSqlState,
java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertShutdownOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertShutdownWOUPFail(java.lang.String expectedSqlState,
java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertSystemShutdownOK(java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprotected void assertSystemShutdownFail(java.lang.String expectedError,
java.lang.String dbName,
java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionpublic void assertConnectionFail(java.lang.String dbName)
throws java.sql.SQLException
java.sql.SQLExceptionApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.