use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.
the class SystemPrivilegesPermissionTest method suite.
/**
* Return a suite with all tests in this class (default suite)
*/
public static Test suite() {
// this suite cannot be constructed with automatic test extraction
// (by passing a class argument); instead, the tests need to be added
// manually since some of them require their own policy file
BaseTestSuite suite = new BaseTestSuite("SystemPrivilegesPermissionTest");
// add API tests for the basic security framework classes
suite.addTest(new SystemPrivilegesPermissionTest("testSystemPrincipal"));
suite.addTest(new SystemPrivilegesPermissionTest("testSystemPermission"));
suite.addTest(new SystemPrivilegesPermissionTest("testSystemPermissionCollections"));
// the DatabasePermission test attempts to canonicalize various
// directory path names and requires an all-files-read-permission,
// which is not granted by default derby_tests.policy
suite.addTest(new SecurityManagerSetup(new SystemPrivilegesPermissionTest("testDatabasePermission"), POLICY_FILE_NAME1));
// on all JVM platforms
if (SecurityManagerSetup.JVM_HAS_SUBJECT_AUTHORIZATION) {
suite.addTest(new SecurityManagerSetup(new SystemPrivilegesPermissionTest("policyTestSystemPermissionGrants"), POLICY_FILE_NAME));
suite.addTest(new SecurityManagerSetup(new SystemPrivilegesPermissionTest("policyTestDatabasePermissionGrants"), POLICY_FILE_NAME));
}
// Only run this test on Java 8.
if (isJava8()) {
suite.addTest(SecurityManagerSetup.noSecurityManager(new SystemPrivilegesPermissionTest("testSerialization")));
}
return suite;
}
use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.
the class ProtocolTest method suite.
/**
* Creates a suite of tests dynamically from a file describing protocol
* tests.
*
* @return A suite of tests.
* @throws Exception if creating the suite fails for some reason
*/
public static Test suite() throws Exception {
BaseTestSuite suite = new BaseTestSuite("Derby DRDA protocol tests");
// Process the list of files and create test cases for the sub-tests.
// NOTE: We cannot assume anything about the order in which the tests
// are executed.
final String testFile = PREFIX + "protocol.tests";
final URL testFileURL = BaseTestCase.getTestResource(testFile);
BufferedReader bIn = new BufferedReader(new InputStreamReader(openTestResource(testFileURL), Charset.forName("UTF-8")));
// Split the tests into individual tests.
final String END_TEST = ProtocolTestGrammar.END_TEST.toCmdString();
int currentLine = 1;
// First line is line number one.
int startLine = 1;
ArrayList<String> cmdLines = new ArrayList<String>();
StringBuilder str = new StringBuilder();
String line;
// Iterate until the end of test token is reached.
while ((line = bIn.readLine()) != null) {
cmdLines.add(line);
str.append(line).append(NL);
if (line.toLowerCase(Locale.ENGLISH).startsWith(END_TEST)) {
// Create a new test case.
suite.addTest(new ProtocolTest("protocol.tests", str.toString(), startLine, currentLine - startLine));
cmdLines.clear();
str.setLength(0);
startLine = currentLine + 1;
}
currentLine++;
}
bIn.close();
// Install a security policy and copy the required include files.
final String resourcePath = "functionTests/tests/derbynet";
return new SecurityManagerSetup(TestConfiguration.clientServerDecorator(new SupportFilesSetup(suite, new String[] { resourcePath + "/connect.inc", resourcePath + "/excsat_accsecrd1.inc", resourcePath + "/excsat_accsecrd2.inc", resourcePath + "/excsat_accsecrd_nordb.inc", resourcePath + "/excsat_secchk_nordbonaccsec.inc", resourcePath + "/excsat_secchk.inc", resourcePath + "/values1.inc", resourcePath + "/values64kblksz.inc" })), PREFIX + "ProtocolTest.policy", true);
}
use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.
the class GetCurrentPropertiesTest method suite.
public static Test suite() {
Test test = new BaseTestSuite(GetCurrentPropertiesTest.class);
test = TestConfiguration.clientServerDecorator(test);
// Install a security manager using the special policy file.
// Grant ALL FILES execute, and getPolicy permissions,
// as well as write for the trace files.
test = new SecurityManagerSetup(test, POLICY_FILE_NAME);
// properties, wrap in singleUseDatabaseDecorator
return TestConfiguration.singleUseDatabaseDecorator(test);
}
use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.
the class Derby5582AutomaticIndexStatisticsTest method suite.
public static Test suite() {
// Run just the one fixture with the custom SecurityManager
Test t = new Derby5582AutomaticIndexStatisticsTest("testDerby5582");
Derby5582SecurityManager sm = new Derby5582SecurityManager();
return TestConfiguration.additionalDatabaseDecorator(new SecurityManagerSetup(t, null, sm), MASTERDB);
}
use of org.apache.derbyTesting.junit.SecurityManagerSetup in project derby by apache.
the class CacheManagerMBeanTest method suite.
public static Test suite() {
BaseTestSuite suite = new BaseTestSuite();
suite.addTest(MBeanTest.suite(CacheManagerMBeanTest.class, "CacheManagerMBeanTest"));
// files, so skip these test cases when running from classes.
if (TestConfiguration.loadingFromJars()) {
Test negative = new CacheManagerMBeanTest("withoutPermsTest");
negative = JMXConnectionDecorator.platformMBeanServer(negative);
negative = new SecurityManagerSetup(negative, "org/apache/derbyTesting/functionTests/tests/management/" + "CacheManagerMBeanTest.withoutPerm.policy");
suite.addTest(negative);
Test positive = new CacheManagerMBeanTest("withPermsTest");
positive = JMXConnectionDecorator.platformMBeanServer(positive);
positive = new SecurityManagerSetup(positive, "org/apache/derbyTesting/functionTests/tests/management/" + "CacheManagerMBeanTest.withPerm.policy");
suite.addTest(positive);
}
return suite;
}
Aggregations