You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2014/07/14 11:59:16 UTC
svn commit: r1610374 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit:
MissingPermissionsTest.java MissingPermissionsTest.policy
MissingPermissionsTest1.policy MissingPermissionsTest2.policy
Author: kahatlen
Date: Mon Jul 14 09:59:16 2014
New Revision: 1610374
URL: http://svn.apache.org/r1610374
Log:
DERBY-6617: Fix setting of permissions in MissingPermissionTest
- When forking a new JVM, pass on the properties that tell where
various jar files are located.
- The specialized policy files for the test should include permissions
required when running the test from Ant.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy
db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest1.policy
db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest2.policy
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java?rev=1610374&r1=1610373&r2=1610374&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java Mon Jul 14 09:59:16 2014
@@ -22,7 +22,6 @@
package org.apache.derbyTesting.unitTests.junit;
import java.io.BufferedReader;
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@@ -205,14 +204,16 @@ public class MissingPermissionsTest exte
// The command runs ij with a security manager whose policy
// lacks the permissions to create derby.system.home.
final List<String> args = new ArrayList<String>();
- final String codeJarUrl = "file:" + getDerbyJarPath();
args.add("-Djava.security.manager");
- args.add("-Djava.security.policy==extin/MissingPermissionsTest2.policy");
- args.add("-DderbyTesting.codejar=" + codeJarUrl);
+ args.add("-Djava.security.policy=extin/MissingPermissionsTest2.policy");
+ args.add("-DderbyTesting.codejar="
+ + getSystemProperty("derbyTesting.codejar"));
+ args.add("-DderbyTesting.testjar="
+ + getSystemProperty("derbyTesting.testjar"));
+ args.add("-DderbyTesting.antjunit="
+ + getSystemProperty("derbyTesting.antjunit"));
args.add("-Dderby.system.home=system/nested");
args.add("-Dij.connection.test=jdbc:derby:wombat;create=true");
- args.add("-classpath");
- args.add(getClassPath());
args.add("org.apache.derby.tools.ij");
final String[] argArray = args.toArray(new String[0]);
@@ -302,27 +303,4 @@ public class MissingPermissionsTest exte
return new BufferedReader(new FileReader(file));
}});
}
-
-
- private static String getClassPath() throws PrivilegedActionException {
- return AccessController.doPrivileged(
- new PrivilegedExceptionAction<String>() {
- @Override
- public String run() {
- return System.getProperty("java.class.path");
- }});
- }
-
- private static String getDerbyJarPath() throws PrivilegedActionException {
- final String classpath = getClassPath();
- final String[] classpathEntries = classpath.split(File.pathSeparator);
-
- for (String s: classpathEntries) {
- int i = s.indexOf("derby.jar");
- if (i >= 0) {
- return s.substring(0, i);
- }
- }
- return null;
- }
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy?rev=1610374&r1=1610373&r2=1610374&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.policy Mon Jul 14 09:59:16 2014
@@ -126,3 +126,27 @@ grant codeBase "${derbyTesting.testjar}d
// **** Needed by this test
permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
};
+
+// JUnit jar file tries to read junit.properties in the user's
+// home directory and seems to require permission to read the
+// property user.home as well.
+// junit.swingui.TestRunner writes to .junitsession on exit.
+grant codeBase "${derbyTesting.junit}" {
+ permission java.util.PropertyPermission "user.home", "read";
+ permission java.io.FilePermission "${user.home}${/}junit.properties", "read";
+ permission java.io.FilePermission "${user.home}${/}.junitsession", "write";
+
+ // This permission is needed when running the tests using ant 1.7
+ permission java.io.FilePermission "${user.dir}${/}*", "write";
+};
+
+// Ant's junit runner requires setOut to redirect the System output streams
+// to the forked JVM used when running junit tests inside Ant. Ant requires
+// forking the JVM if you want to run tests in a different directory than the
+// current one.
+grant codeBase "${derbyTesting.antjunit}" {
+ permission java.lang.RuntimePermission "setIO";
+
+ // This permission is needed when running the tests using ant 1.7
+ permission java.io.FilePermission "${user.dir}${/}*", "write";
+};
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest1.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest1.policy?rev=1610374&r1=1610373&r2=1610374&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest1.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest1.policy Mon Jul 14 09:59:16 2014
@@ -128,3 +128,27 @@ grant codeBase "${derbyTesting.testjar}d
// **** Needed by this test
permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
};
+
+// JUnit jar file tries to read junit.properties in the user's
+// home directory and seems to require permission to read the
+// property user.home as well.
+// junit.swingui.TestRunner writes to .junitsession on exit.
+grant codeBase "${derbyTesting.junit}" {
+ permission java.util.PropertyPermission "user.home", "read";
+ permission java.io.FilePermission "${user.home}${/}junit.properties", "read";
+ permission java.io.FilePermission "${user.home}${/}.junitsession", "write";
+
+ // This permission is needed when running the tests using ant 1.7
+ permission java.io.FilePermission "${user.dir}${/}*", "write";
+};
+
+// Ant's junit runner requires setOut to redirect the System output streams
+// to the forked JVM used when running junit tests inside Ant. Ant requires
+// forking the JVM if you want to run tests in a different directory than the
+// current one.
+grant codeBase "${derbyTesting.antjunit}" {
+ permission java.lang.RuntimePermission "setIO";
+
+ // This permission is needed when running the tests using ant 1.7
+ permission java.io.FilePermission "${user.dir}${/}*", "write";
+};
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest2.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest2.policy?rev=1610374&r1=1610373&r2=1610374&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest2.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest2.policy Mon Jul 14 09:59:16 2014
@@ -134,3 +134,27 @@ grant codeBase "${derbyTesting.codejar}d
permission java.io.FilePermission "java.runtime.version", "read";
permission java.io.FilePermission "java.fullversion", "read";
};
+
+// JUnit jar file tries to read junit.properties in the user's
+// home directory and seems to require permission to read the
+// property user.home as well.
+// junit.swingui.TestRunner writes to .junitsession on exit.
+grant codeBase "${derbyTesting.junit}" {
+ permission java.util.PropertyPermission "user.home", "read";
+ permission java.io.FilePermission "${user.home}${/}junit.properties", "read";
+ permission java.io.FilePermission "${user.home}${/}.junitsession", "write";
+
+ // This permission is needed when running the tests using ant 1.7
+ permission java.io.FilePermission "${user.dir}${/}*", "write";
+};
+
+// Ant's junit runner requires setOut to redirect the System output streams
+// to the forked JVM used when running junit tests inside Ant. Ant requires
+// forking the JVM if you want to run tests in a different directory than the
+// current one.
+grant codeBase "${derbyTesting.antjunit}" {
+ permission java.lang.RuntimePermission "setIO";
+
+ // This permission is needed when running the tests using ant 1.7
+ permission java.io.FilePermission "${user.dir}${/}*", "write";
+};