public class RolesTest extends BaseJDBCTestCase
Modifier and Type | Field and Description |
---|---|
private int |
_authLevel |
private java.sql.Connection |
_conn |
private java.sql.Statement |
_stm |
private java.lang.String |
_user |
private java.lang.String |
_userPassword |
private static int |
additionaluserIndex |
private static int |
dboIndex |
private static java.lang.String |
idParseError |
private static java.lang.String |
invalidPUBLIC |
private static java.lang.String |
invalidRole |
private static java.lang.String |
invalidRoleName |
private static java.lang.String |
loginFailed |
private int |
MAX_IDENTIFIER_LENGTH |
private static int |
NO_SQLAUTHORIZATION |
private static int |
nonDboIndex |
private static java.lang.String |
notIdle |
private static java.lang.String |
objectAlreadyExists |
private static java.lang.String |
pwSuffix |
private static java.lang.String |
revokeWarn |
private static java.lang.String |
roleDboOnly |
private static java.lang.String |
roleGrantCircularity |
private static int |
SQLAUTHORIZATION |
private static java.lang.String |
sqlAuthorizationRequired |
private static java.lang.String |
syntaxError |
private static java.lang.String |
tooLongId |
private static java.lang.String |
userException |
private static java.lang.String[] |
users
Users used by all suites when when authLevel == SQLAUTHORIZATION.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
RolesTest(java.lang.String name,
int authLevel,
java.lang.String user,
java.lang.String userPassword)
Create a new instance of RolesTest.
|
Modifier and Type | Method and Description |
---|---|
private void |
assertRoleInRs(java.sql.ResultSet rs,
java.lang.String dboRole,
java.lang.String notDboRole) |
private void |
assertSysColPermsRowCount(int rcNoAuth,
int rcDbo,
int rcMereMortal) |
private void |
assertSysRolesRowCount(int rcNoAuth,
int rcDbo,
int rcMereMortal) |
private void |
assertSysRoutinePermsRowCount(int rcNoAuth,
int rcDbo,
int rcMereMortal) |
private void |
assertSysTablePermsRowCount(int rcNoAuth,
int rcDbo,
int rcMereMortal) |
private void |
assertSystableRowCount(java.lang.String table,
int rcNoAuth,
int rcDbo,
int rcMereMortal) |
private void |
checkGrantCircularity() |
private void |
doDynamicSetRole(java.sql.Connection conn) |
private java.sql.ResultSet |
doQuery(java.lang.String stmt,
java.lang.String noAuthState,
java.lang.String authDboState,
java.lang.String authNotDboState) |
private void |
doStmt(java.lang.String stmt,
java.lang.String noAuthState,
java.lang.String authDboState,
java.lang.String authNotDboState) |
private java.sql.ResultSet |
doStmt(java.lang.String stmt,
java.lang.String noAuthState,
java.lang.String authDboState,
java.lang.String authNotDboState,
boolean query) |
private java.sql.ResultSet |
doStmtWithWarnings(java.lang.String stmt,
java.lang.String[] noAuthState,
java.lang.String[] authDboState,
java.lang.String[] authNotDboState,
boolean query) |
private void |
doTestCurrentRoleIsReset(javax.sql.PooledConnection pc,
java.lang.String user)
Executes a test sequence to make sure the current role is reset between
logical connections.
|
private void |
dumpSysColPerms() |
private void |
dumpSysRoles() |
private void |
dumpSysRoutinePerms() |
private void |
dumpSysTablePerms() |
static int |
f1()
Utility function used to test auto-drop of grant routine
permission to a role
|
private boolean |
isDbo() |
private static junit.framework.Test |
negativeSyntaxSuite(java.lang.String framework)
Construct suite of tests for negative syntax
|
private static junit.framework.Test |
positiveSyntaxSuite(java.lang.String framework)
Construct suite of tests for positive syntax (edge cases)
|
private static junit.framework.Test |
semanticSuite(java.lang.String framework)
Construct suite of semantic tests
|
protected void |
setUp() |
static junit.framework.Test |
suite()
Construct top level suite in this JUnit test
|
protected void |
tearDown()
Tear down this fixture, sub-classes should call
super.tearDown().
|
private void |
testCurrentRoleIsReset()
Verifies that the current role is reset when creating a new logical
connection.
|
private void |
testLoginWithUsernameWhichIsARole()
Create a user that has the same name as a role and try to
log in with it; should be denied.
|
void |
testNegativeSyntax()
Test negative syntax for roles.
|
void |
testPositiveSyntax()
Test syntax edge cases (positive)
|
void |
testSemantics()
Semantic tests for roles.
|
private static junit.framework.Test |
wrapInAuthorization(java.lang.String testName)
Wrap in decorators to run with data base owner and one other
valid user in sqlAuthorization mode.
|
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, 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, toString
private final int _authLevel
private final java.lang.String _user
private final java.lang.String _userPassword
private java.sql.Connection _conn
private java.sql.Statement _stm
private static final int NO_SQLAUTHORIZATION
private static final int SQLAUTHORIZATION
private static final java.lang.String pwSuffix
private static final java.lang.String sqlAuthorizationRequired
private static final java.lang.String syntaxError
private static final java.lang.String roleDboOnly
private static final java.lang.String invalidRole
private static final java.lang.String tooLongId
private static final java.lang.String revokeWarn
private static final java.lang.String notIdle
private static final java.lang.String invalidRoleName
private static final java.lang.String userException
private static final java.lang.String objectAlreadyExists
private static final java.lang.String invalidPUBLIC
private static final java.lang.String loginFailed
private static final java.lang.String roleGrantCircularity
private static final java.lang.String idParseError
private int MAX_IDENTIFIER_LENGTH
private static final java.lang.String[] users
private static final int dboIndex
private static final int nonDboIndex
private static final int additionaluserIndex
public RolesTest(java.lang.String name, int authLevel, java.lang.String user, java.lang.String userPassword)
name
- Fixture nameauthLevel
- authentication level with which test is runuser
- Database useruserPassword
- Database user's passwordprivate boolean isDbo()
public static junit.framework.Test suite()
private static junit.framework.Test negativeSyntaxSuite(java.lang.String framework)
framework
- Derby framework indicationprivate static junit.framework.Test positiveSyntaxSuite(java.lang.String framework)
framework
- Derby framework indicationpublic void testNegativeSyntax() throws java.sql.SQLException
java.sql.SQLException
public void testPositiveSyntax() throws java.sql.SQLException
java.sql.SQLException
private static junit.framework.Test semanticSuite(java.lang.String framework)
framework
- Derby framework indicationprivate static junit.framework.Test wrapInAuthorization(java.lang.String testName)
testName
- test to wrappublic void testSemantics() throws java.sql.SQLException
java.sql.SQLException
private void testLoginWithUsernameWhichIsARole() throws java.sql.SQLException
java.lang.Exception
java.sql.SQLException
private void testCurrentRoleIsReset() throws java.sql.SQLException
The test is run in a non-statement pooling configuration first, and then with statement pooling enabled if the environment supports it.
The test pattern is borrowed from the test case in J2EEDataSourceTest.
java.sql.SQLException
- if something goes wrongJ2EEDataSourceTest.testSchemaIsReset()
private void doTestCurrentRoleIsReset(javax.sql.PooledConnection pc, java.lang.String user) throws java.sql.SQLException
pc
- pooled connection to get logical connections fromuser
- name of for the connectionjava.sql.SQLException
- if something goes wrong...private void checkGrantCircularity()
protected void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
protected void tearDown() throws java.lang.Exception
BaseJDBCTestCase
tearDown
in class BaseJDBCTestCase
java.lang.Exception
private void doStmt(java.lang.String stmt, java.lang.String noAuthState, java.lang.String authDboState, java.lang.String authNotDboState)
private java.sql.ResultSet doQuery(java.lang.String stmt, java.lang.String noAuthState, java.lang.String authDboState, java.lang.String authNotDboState)
private java.sql.ResultSet doStmt(java.lang.String stmt, java.lang.String noAuthState, java.lang.String authDboState, java.lang.String authNotDboState, boolean query)
private java.sql.ResultSet doStmtWithWarnings(java.lang.String stmt, java.lang.String[] noAuthState, java.lang.String[] authDboState, java.lang.String[] authNotDboState, boolean query)
private void doDynamicSetRole(java.sql.Connection conn)
private void assertSystableRowCount(java.lang.String table, int rcNoAuth, int rcDbo, int rcMereMortal) throws java.sql.SQLException
java.sql.SQLException
private void assertSysRolesRowCount(int rcNoAuth, int rcDbo, int rcMereMortal) throws java.sql.SQLException
java.sql.SQLException
private void assertSysTablePermsRowCount(int rcNoAuth, int rcDbo, int rcMereMortal) throws java.sql.SQLException
java.sql.SQLException
private void assertSysColPermsRowCount(int rcNoAuth, int rcDbo, int rcMereMortal) throws java.sql.SQLException
java.sql.SQLException
private void assertSysRoutinePermsRowCount(int rcNoAuth, int rcDbo, int rcMereMortal) throws java.sql.SQLException
java.sql.SQLException
private void dumpSysRoles() throws java.sql.SQLException
java.sql.SQLException
private void dumpSysTablePerms() throws java.sql.SQLException
java.sql.SQLException
private void dumpSysColPerms() throws java.sql.SQLException
java.sql.SQLException
private void dumpSysRoutinePerms() throws java.sql.SQLException
java.sql.SQLException
private void assertRoleInRs(java.sql.ResultSet rs, java.lang.String dboRole, java.lang.String notDboRole) throws java.sql.SQLException
java.sql.SQLException
public static int f1()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.