public class EncryptionAESTest extends BaseJDBCTestCase
Tests various connection sequences to further test AES encrypted databases. Top level testcases grp.
Modifier and Type | Field and Description |
---|---|
private static int[] |
DATA
Test data inserted into database and used for verification.
|
private static java.lang.String |
TABLE
Table holding the test data.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
EncryptionAESTest(java.lang.String name)
Configures a new setup by specifying the encryption properties.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assertNoDBCreated(java.lang.String expectedSQLState,
java.lang.String dbName,
java.lang.String algorithm,
java.lang.String[] otherAttributes)
Attempt to create a new database and expect a failure.
|
protected java.sql.Connection |
createAndPopulateDB(java.lang.String dbName,
java.lang.String algorithm,
java.lang.String[] otherAttributes)
Create a new database and populate it.
|
private java.sql.Connection |
getConnection(java.lang.String dbName,
java.lang.String algorithm,
java.lang.String[] otherAttributes)
Create a new connection to the specified database, using the given
connection attributes.
|
private java.sql.Connection |
getDriverManagerConnection(java.lang.String dbName,
java.lang.String algorithm,
java.lang.String[] otherAttributes) |
private java.lang.String |
obtainDbName(java.lang.String dbName)
Obtain absolute path for the specified database name.
|
void |
runMismatchKeyLength(java.lang.String dbName,
java.lang.String encryptionAlgorithm,
java.lang.String encryptionKeyLength,
java.lang.String[] attributes)
attempt to connect and verify the SQLState if it's expected to fail
does the last bit of work for fixture testEncryptionKeyLength
|
protected void |
runTestEncryptionKeyLengths(java.lang.String encryptionKeyLength)
test connection attempts for a passed in feedback mode:
does most of the work for fixture testEncryptionKeyLength
Connect-and-Create(test case 1.*.1, shutdown, reconnect(1.*.2).
|
protected void |
runTestFeedbackModes(java.lang.String feedbackMode)
test connection attempts for a passed in feedback mode:
Connect-and-Create(test case 1.*.1, shutdown, reconnect(1.*.2).
|
protected void |
shutdown(java.lang.String databaseName)
Shutdown the specified database.
|
static junit.framework.Test |
suite()
Clean up the connection maintained by this test.
|
void |
testEncryptionKeyLengths()
Case 3.x
Test connection attempts for 4 different keyLength values:
valid/supported: 128(case 3.1), 192(case 3.2), 256(case 3.3)
Create-and-connect is test case 3.*.1, reconnection 3.*.2.
|
void |
testFeedbackModes()
Case 1.x
Test connection attempts for 5 different feedback modes:
valid/supported: CBC(case 1.1), ECB(case 1.2), OFB(case 1.3), CFB(case 1.4)
unsupported: ABC(case 1.5)
|
void |
testUnsupportedPadding()
Case 2.1 - Unsupported padding mode
|
protected void |
validateDBContents(java.sql.Connection con)
Validate the data in the database against the data model.
|
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
assertEquals, 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, setUp, toString
private static final java.lang.String TABLE
private static final int[] DATA
public EncryptionAESTest(java.lang.String name)
public static junit.framework.Test suite()
public void testFeedbackModes() throws java.sql.SQLException
java.sql.SQLException
protected void runTestFeedbackModes(java.lang.String feedbackMode) throws java.sql.SQLException
java.sql.SQLException
public void testUnsupportedPadding() throws java.sql.SQLException
java.sql.SQLException
public void testEncryptionKeyLengths() throws java.sql.SQLException
java.sql.SQLException
protected void runTestEncryptionKeyLengths(java.lang.String encryptionKeyLength) throws java.sql.SQLException
java.sql.SQLException
public void runMismatchKeyLength(java.lang.String dbName, java.lang.String encryptionAlgorithm, java.lang.String encryptionKeyLength, java.lang.String[] attributes) throws java.sql.SQLException
java.sql.SQLException
private java.lang.String obtainDbName(java.lang.String dbName)
This absolute path is the name of the database (specified) prefixed with
the absolute path to the EXTINOUT directory. The latter is determined by
consulting SupportFilesSetup
.
dbName
- name of the database
Note that the database name will be prefixed
with the path to the EXTINOUT directorySupportFilesSetup
protected void assertNoDBCreated(java.lang.String expectedSQLState, java.lang.String dbName, java.lang.String algorithm, java.lang.String[] otherAttributes) throws java.sql.SQLException
The method expects a failure This is because it is the creation process that is to be tested.
expectedSQLState
- SQLState for the expected errordbName
- name of the database attempted to createalgorithm
- EncryptionAlgorithmotherAttributes
- array for all other attributes
(Note: dataEncryption=true is already set in getConnection)java.sql.SQLException
- if the database already exist, or
a general error happens during database interactionprotected java.sql.Connection createAndPopulateDB(java.lang.String dbName, java.lang.String algorithm, java.lang.String[] otherAttributes) throws java.sql.SQLException
The method fails with an exception if the database already exists. This is because it is the creation process that is to be tested.
dbName
- name of the database to createalgorithm
- EncryptionAlgorithmotherAttributes
- array for all other attributes
(Note: dataEncryption=true is already set in getConnection)java.sql.SQLException
- if the database already exist, or
a general error happens during database interactionprivate java.sql.Connection getConnection(java.lang.String dbName, java.lang.String algorithm, java.lang.String[] otherAttributes) throws java.sql.SQLException
dbName
- name of the databasealgorithm
- EncryptionAlgorithmotherAttributes
- array for all other attributes
(Note: dataEncryption=true is already set in this method)java.sql.SQLException
- if connection failsprivate java.sql.Connection getDriverManagerConnection(java.lang.String dbName, java.lang.String algorithm, java.lang.String[] otherAttributes) throws java.sql.SQLException
java.sql.SQLException
protected void shutdown(java.lang.String databaseName) throws java.sql.SQLException
databaseName
- the name of the databasejava.sql.SQLException
- if failsprotected void validateDBContents(java.sql.Connection con) throws java.sql.SQLException
con
- the database to validate the contents ofjunit.framework.AssertionFailedError
- if there is a mismatch
between the data in the database and the modeljava.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.