Search in sources :

Example 16 with SecurityManagerSetup

use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.

the class SecurityPolicyReloadingTest method decorateTest.

// /////////////////////////////////////////////////////////////////////////////////
// 
// TEST DECORATION
// 
// /////////////////////////////////////////////////////////////////////////////////
/**
 * Add decorators to a test run. Context is established in the reverse order
 * that decorators are declared here. That is, decorators compose in reverse
 * order. The order of the setup methods is:
 *
 * <ul>
 * <li>Copy security policy to visible location.</li>
 * <li>Setup authorization-enabling properties.</li>
 * <li>Install a security manager.</li>
 * <li>Run the tests.</li>
 * </ul>
 */
private static Test decorateTest() {
    Test test = new SecurityPolicyReloadingTest();
    // 
    // Install a security manager using the initial policy file.
    // 
    test = new SecurityManagerSetup(test, makeServerPolicyName());
    // 
    // Set up authorization with a DBO and non-DBO user
    // 
    test = TestConfiguration.sqlAuthorizationDecorator(test, new String[] { NON_DBO_USER }, PASSWORD_TOKEN);
    // 
    // Copy over the initial policy file we want to use.
    // 
    test = new SupportFilesSetup(test, null, new String[] { getSourcePolicy() }, null, new String[] { makeTargetPolicyStub() });
    // No need to run with default testing policy file because we install our
    // own initial policy file.
    test = SecurityManagerSetup.noSecurityManager(test);
    return test;
}
Also used : Test(junit.framework.Test) SecurityManagerSetup(org.apache.derbyTesting.junit.SecurityManagerSetup) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

Example 17 with SecurityManagerSetup

use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.

the class AssertFailureTest method suite.

public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("AssertFailureTest");
    try {
        // Only add the tests if this is a sane build.
        Class.forName("org.apache.derby.shared.common.sanity." + "AssertFailure");
        // Run with thread dump permissions
        suite.addTest(new SecurityManagerSetup(new AssertFailureTest("testAssertFailureThreadDump"), POLICY_FILENAME));
        // Run WITHOUT thread dump permissions
        suite.addTest(new SecurityManagerSetup(new AssertFailureTest("testAssertFailureNoThreadDump"), NO_DUMP_POLICY_FILENAME));
    } catch (ClassNotFoundException e) {
    // Ignore. Just return an empty suite.
    }
    return suite;
}
Also used : BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SecurityManagerSetup(org.apache.derbyTesting.junit.SecurityManagerSetup)

Example 18 with SecurityManagerSetup

use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.

the class RuntimeInfoTest method decorateTest.

/**
 * Decorate a test with SecurityManagerSetup, clientServersuite, and
 * SupportFilesSetup.
 *
 * @return the decorated test
 */
private static Test decorateTest(Locale serverLocale, String testName) {
    Test test = new RuntimeInfoTest(testName);
    test = TestConfiguration.clientServerDecorator(test);
    /* A single use database must be used to ensure the consistent output.
         * The output would change whether the test was being ran for the first
         * or subsequent times. */
    test = TestConfiguration.singleUseDatabaseDecorator(test);
    test = new LocaleTestSetup(test, serverLocale);
    // Install a security manager using the initial policy file.
    return new SecurityManagerSetup(test, POLICY_FILE_NAME);
}
Also used : Test(junit.framework.Test) LocaleTestSetup(org.apache.derbyTesting.junit.LocaleTestSetup) SecurityManagerSetup(org.apache.derbyTesting.junit.SecurityManagerSetup)

Example 19 with SecurityManagerSetup

use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.

the class SecureServerTest method makeDerby6619Test.

private static Test makeDerby6619Test() {
    Test t = new SecureServerTest("test6619");
    t = TestConfiguration.clientServerDecorator(t);
    t = new SecurityManagerSetup(t, POLICY6619);
    t = new ClassLoaderTestSetup(t);
    return t;
}
Also used : Test(junit.framework.Test) SecurityManagerSetup(org.apache.derbyTesting.junit.SecurityManagerSetup) ClassLoaderTestSetup(org.apache.derbyTesting.junit.ClassLoaderTestSetup)

Example 20 with SecurityManagerSetup

use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.

the class _Suite method suite.

/**
 * Returns the default set of compatibility tests, intended to be run
 * as part of suites.All.
 *
 * @return A default suite of compatibility tests.
 */
public static Test suite() {
    // run off of UNC paths (network drives).
    if (suffersFromDerby5889()) {
        String msg = ("tests.compatibility disabled on Windows " + "with UNC paths, see DERBY-5889");
        println(msg);
        return new BaseTestSuite(msg);
    }
    // from VersionCombinationConfigurator.getJarDirectoryOf
    if (!TestConfiguration.loadingFromJars())
        return new BaseTestSuite("Compatibility tests skipped becasue " + "they need to run from jars");
    if (!Derby.hasClient() || !Derby.hasServer()) {
        return new BaseTestSuite("Compatibility tests skipped because " + "client or server is missing");
    }
    BaseTestSuite suite = new BaseTestSuite();
    addVersionCombinations(suite);
    TestConfiguration config = TestConfiguration.getCurrent();
    return new SecurityManagerSetup(new ServerSetup(suite, "localhost", config.getPort()), // to put on the classpath for the spawned process(es).
    VersionCombinationConfigurator.class.getName().replaceAll("\\.", "/") + ".policy", true);
}
Also used : TestConfiguration(org.apache.derbyTesting.junit.TestConfiguration) ServerSetup(org.apache.derbyTesting.junit.ServerSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SecurityManagerSetup(org.apache.derbyTesting.junit.SecurityManagerSetup)

Aggregations

SecurityManagerSetup (org.apache.derbyTesting.junit.SecurityManagerSetup)20 Test (junit.framework.Test)13 BaseTestSuite (org.apache.derbyTesting.junit.BaseTestSuite)13 SupportFilesSetup (org.apache.derbyTesting.junit.SupportFilesSetup)4 Properties (java.util.Properties)2 LocaleTestSetup (org.apache.derbyTesting.junit.LocaleTestSetup)2 SystemPropertyTestSetup (org.apache.derbyTesting.junit.SystemPropertyTestSetup)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 PreparedStatement (java.sql.PreparedStatement)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 ClassLoaderTestSetup (org.apache.derbyTesting.junit.ClassLoaderTestSetup)1 CleanDatabaseTestSetup (org.apache.derbyTesting.junit.CleanDatabaseTestSetup)1 ServerSetup (org.apache.derbyTesting.junit.ServerSetup)1 TestConfiguration (org.apache.derbyTesting.junit.TestConfiguration)1