org.apache.derbyTesting.unitTests.junit
Class SystemPrivilegesPermissionTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.derbyTesting.junit.BaseTestCase
              extended by org.apache.derbyTesting.unitTests.junit.SystemPrivilegesPermissionTest
All Implemented Interfaces:
junit.framework.Test

public class SystemPrivilegesPermissionTest
extends BaseTestCase

This class tests the basic permission classes for system privileges.


Nested Class Summary
 class SystemPrivilegesPermissionTest.CreateDatabaseAction
          Represents a Create Database action.
static class SystemPrivilegesPermissionTest.RunAsPrivilegedUserAction
          Represents a Privileged User action.
 class SystemPrivilegesPermissionTest.ShutdownAction
          Represents a Shutdown server and engine action.
 
Field Summary
private static java.lang.String[] absDirPathAliases
          Some absolute directory path aliases for testing DatabasePermissions.
private static java.lang.String[] absDirPaths
          Some absolute directory paths for testing DatabasePermissions.
private static boolean[][] dirPathImpls
          The matrix defining which of the above directory paths imply each other.
private static java.lang.String[] dirPaths
          Some directory paths for testing DatabasePermissions.
private static java.lang.String POLICY_FILE_NAME
          The policy file name for the subject authorization tests.
private static java.lang.String POLICY_FILE_NAME1
          The policy file name for the DatabasePermission API test.
private static java.lang.String[] relDirPathAliases
          Some relative directory path aliases for testing DatabasePermissions.
private static java.lang.String[] relDirPaths
          Some relative directory paths for testing DatabasePermissions.
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
SystemPrivilegesPermissionTest(java.lang.String name)
          Create a test with the given name.
 
Method Summary
private  void assertEquivalentPermissions(java.security.Permission p1, java.security.Permission p2)
           
private  void checkDistinctPermissions(java.security.Permission[] set)
          Check thet a set of Permission objects are distinct, do not equal or imply each other.
private  void checkHashCodeAndEquals(java.security.Permission[] dbp0, java.security.Permission[] dbp1)
          Tests DatabasePermission.hashCode() and .equals().
private  void checkImplies(java.security.Permission[] dbp0, java.security.Permission[] dbp1, boolean[][] impls)
          Tests DatabasePermission.implies().
private  void checkNameAndActions(org.apache.derby.security.DatabasePermission[] dbperm, java.lang.String[] dbpath)
          Tests DatabasePermission.getName() and .getActions().
private  void execute(org.apache.derby.authentication.SystemPrincipal principal, java.security.PrivilegedAction action, boolean isGrantExpected)
          Runs a privileged user action for a given principal.
private static java.lang.String getAuthorizationId(java.lang.String name)
          Returns the Authorization Identifier for a principal name.
 void policyTestDatabasePermissionGrants()
          Tests DatabasePermissions against the Policy.
 void policyTestSystemPermissionGrants()
          Tests SystemPermissions against the Policy.
static junit.framework.Test suite()
          Return a suite with all tests in this class (default suite)
 void testDatabasePermission()
          Tests DatabasePermission.
 void testSystemPermission()
          Tests SystemPermission.
 void testSystemPrincipal()
          Tests SystemPrincipal.
 
Methods inherited from class org.apache.derbyTesting.junit.BaseTestCase
alarm, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertSecurityManager, assertThrowableEquals, execJavaCmd, fail, getFailureFolder, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeSystemProperty, runBare, setSystemProperty, traceit
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
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, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

POLICY_FILE_NAME

private static java.lang.String POLICY_FILE_NAME
The policy file name for the subject authorization tests.


POLICY_FILE_NAME1

private static java.lang.String POLICY_FILE_NAME1
The policy file name for the DatabasePermission API test.


dirPaths

private static final java.lang.String[] dirPaths
Some directory paths for testing DatabasePermissions.


relDirPaths

private static final java.lang.String[] relDirPaths
Some relative directory paths for testing DatabasePermissions.


relDirPathAliases

private static final java.lang.String[] relDirPathAliases
Some relative directory path aliases for testing DatabasePermissions.


absDirPaths

private static final java.lang.String[] absDirPaths
Some absolute directory paths for testing DatabasePermissions.


absDirPathAliases

private static final java.lang.String[] absDirPathAliases
Some absolute directory path aliases for testing DatabasePermissions.


dirPathImpls

private static final boolean[][] dirPathImpls
The matrix defining which of the above directory paths imply each other. For instance, dirPathImpls[1][2] shows the expected value for:

Constructor Detail

SystemPrivilegesPermissionTest

public SystemPrivilegesPermissionTest(java.lang.String name)
Create a test with the given name.

Parameters:
name - name of the test
Method Detail

suite

public static junit.framework.Test suite()
Return a suite with all tests in this class (default suite)

Throws:
java.lang.Exception

testSystemPrincipal

public void testSystemPrincipal()
Tests SystemPrincipal.


testSystemPermission

public void testSystemPermission()
Tests SystemPermission.


policyTestSystemPermissionGrants

public void policyTestSystemPermissionGrants()
Tests SystemPermissions against the Policy.


testDatabasePermission

public void testDatabasePermission()
                            throws java.io.IOException
Tests DatabasePermission.

Throws:
java.io.IOException

policyTestDatabasePermissionGrants

public void policyTestDatabasePermissionGrants()
                                        throws java.io.IOException
Tests DatabasePermissions against the Policy.

Throws:
java.io.IOException

execute

private void execute(org.apache.derby.authentication.SystemPrincipal principal,
                     java.security.PrivilegedAction action,
                     boolean isGrantExpected)
Runs a privileged user action for a given principal.


checkNameAndActions

private void checkNameAndActions(org.apache.derby.security.DatabasePermission[] dbperm,
                                 java.lang.String[] dbpath)
                          throws java.io.IOException
Tests DatabasePermission.getName() and .getActions().

Throws:
java.io.IOException

checkHashCodeAndEquals

private void checkHashCodeAndEquals(java.security.Permission[] dbp0,
                                    java.security.Permission[] dbp1)
                             throws java.io.IOException
Tests DatabasePermission.hashCode() and .equals().

Throws:
java.io.IOException

checkImplies

private void checkImplies(java.security.Permission[] dbp0,
                          java.security.Permission[] dbp1,
                          boolean[][] impls)
                   throws java.io.IOException
Tests DatabasePermission.implies().

Throws:
java.io.IOException

checkDistinctPermissions

private void checkDistinctPermissions(java.security.Permission[] set)
Check thet a set of Permission objects are distinct, do not equal or imply each other.


assertEquivalentPermissions

private void assertEquivalentPermissions(java.security.Permission p1,
                                         java.security.Permission p2)

getAuthorizationId

private static java.lang.String getAuthorizationId(java.lang.String name)
Returns the Authorization Identifier for a principal name.

Parameters:
name - the name of the principal
Returns:
the authorization identifier for this principal

Built on Sat 2009-11-28 18:44:18-0800, from revision 885187

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.