/hg/release/icedtea-web-1.2: Fixed security tests to pass both j...

jvanek at icedtea.classpath.org jvanek at icedtea.classpath.org
Tue May 22 05:52:29 PDT 2012


changeset c95fe178d33d in /hg/release/icedtea-web-1.2
details: http://icedtea.classpath.org/hg/release/icedtea-web-1.2?cmd=changeset;node=c95fe178d33d
author: Jiri Vanek <jvanek at redhat.com>
date: Tue May 22 14:52:43 2012 +0200

	Fixed security tests to pass both jdk6 and 7


diffstat:

 ChangeLog                                                                                |  13 ++++++++++
 tests/jnlp_tests/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java     |  11 +++----
 tests/jnlp_tests/simple/AddShutdownHook/testcases/AddShutdownHookTest.java               |   4 +-
 tests/jnlp_tests/simple/AllStackTraces/testcases/AllStackTracesTest.java                 |   4 +-
 tests/jnlp_tests/simple/CreateClassLoader/testcases/CreateClassLoaderTest.java           |   4 +-
 tests/jnlp_tests/simple/ReadEnvironment/testcases/ReadEnvironmentTest.java               |   4 +-
 tests/jnlp_tests/simple/ReadProperties/testcases/ReadPropertiesTest.java                 |  10 +++---
 tests/jnlp_tests/simple/RedirectStreams/testcases/RedirectStreamsTest.java               |   4 +-
 tests/jnlp_tests/simple/ReplaceSecurityManager/testcases/ReplaceSecurityManagerTest.java |   4 +-
 tests/jnlp_tests/simple/SetContextClassLoader/testcases/SetContextClassLoaderTest.java   |   4 +-
 10 files changed, 37 insertions(+), 25 deletions(-)

diffs (193 lines):

diff -r dde230f3536a -r c95fe178d33d ChangeLog
--- a/ChangeLog	Wed May 09 16:09:00 2012 -0400
+++ b/ChangeLog	Tue May 22 14:52:43 2012 +0200
@@ -1,3 +1,16 @@
+2012-05-22  Jiri Vanek  <jvanek at redhat.com>
+
+	* tests/jnlp_tests/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java: 
+	* tests/jnlp_tests/simple/AddShutdownHook/testcases/AddShutdownHookTest.java: 
+	* tests/jnlp_tests/simple/AllStackTraces/testcases/AllStackTracesTest.java: 
+	* tests/jnlp_tests/simple/CreateClassLoader/testcases/CreateClassLoaderTest.java: 
+	* tests/jnlp_tests/simple/ReadEnvironment/testcases/ReadEnvironmentTest.java: 
+	* tests/jnlp_tests/simple/ReadProperties/testcases/ReadPropertiesTest.java: 
+	* tests/jnlp_tests/simple/RedirectStreams/testcases/RedirectStreamsTest.java: 
+	* tests/jnlp_tests/simple/ReplaceSecurityManager/testcases/ReplaceSecurityManagerTest.java: 
+	* tests/jnlp_tests/simple/SetContextClassLoader/testcases/SetContextClassLoaderTest.java: 
+	All exact matches upon AccessControlException replaced by regular expression matching both jdk7 and jdk6 syntax
+
 2012-05-09  Omair Majid  <omajid at redhat.com>
 
 	* tests/netx/unit/net/sourceforge/jnlp/JNLPMatcherTest.java
diff -r dde230f3536a -r c95fe178d33d tests/jnlp_tests/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java
--- a/tests/jnlp_tests/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java	Wed May 09 16:09:00 2012 -0400
+++ b/tests/jnlp_tests/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java	Tue May 22 14:52:43 2012 +0200
@@ -48,6 +48,8 @@
     private static ServerAccess server = new ServerAccess();
     private final List<String> l=Collections.unmodifiableList(Arrays.asList(new String[] {"-Xtrustall"}));
 
+    String accessMatcher = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.util.PropertyPermission.{0,5}" + "user.name.{0,5}read" + ".*";
+
     @Test
     public void ReadSignedPropertiesWithoutPermissionsWithXtrustAll() throws Exception {
         //no request for permissions
@@ -56,8 +58,7 @@
         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned1.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.util.PropertyPermission user.name read)";
-        Assert.assertTrue("Stderr should contains "+s+" but did not",pr.stderr.contains(s));
+        Assert.assertTrue("Stderr should match "+accessMatcher+" but did not",pr.stderr.matches(accessMatcher));
         String ss="ClassNotFoundException";
         Assert.assertFalse("Stderr should not contains "+ss+" but did",pr.stderr.contains(ss));
         Assert.assertTrue("stdout lenght should be <2 but was "+pr.stdout.length(),pr.stdout.length()<2); // /home/user or /root or eanything else :(
@@ -73,8 +74,7 @@
         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadPropertiesSigned2.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.util.PropertyPermission user.name read)";
-        Assert.assertFalse("Stderr should NOT contains "+s+" but did",pr.stderr.contains(s));
+        Assert.assertFalse("Stderr should NOT match "+accessMatcher+" but did",pr.stderr.matches(accessMatcher));
         String ss="ClassNotFoundException";
         Assert.assertFalse("Stderr should not contains "+ss+" but did",pr.stderr.contains(ss));
         Assert.assertTrue("stdout lenght should be >= but was "+pr.stdout.length(),pr.stdout.length()>=4); // /home/user or /root or eanything else :(
@@ -89,8 +89,7 @@
         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(l,"/ReadProperties1.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.util.PropertyPermission user.name read)";
-        Assert.assertTrue(pr.stderr.contains(s));
+        Assert.assertTrue("Stderr should match "+accessMatcher+" but did not",pr.stderr.matches(accessMatcher));
         String ss="ClassNotFoundException";
         Assert.assertFalse("Stderr should not contains "+ss+" but did",pr.stderr.contains(ss));
         Assert.assertFalse("stdout lenght should not be  >2 but was "+pr.stdout.length(),pr.stdout.length()>2);
diff -r dde230f3536a -r c95fe178d33d tests/jnlp_tests/simple/AddShutdownHook/testcases/AddShutdownHookTest.java
--- a/tests/jnlp_tests/simple/AddShutdownHook/testcases/AddShutdownHookTest.java	Wed May 09 16:09:00 2012 -0400
+++ b/tests/jnlp_tests/simple/AddShutdownHook/testcases/AddShutdownHookTest.java	Tue May 22 14:52:43 2012 +0200
@@ -51,8 +51,8 @@
         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/AddShutdownHook.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.lang.RuntimePermission shutdownHooks)";
-        Assert.assertTrue("stderr should contains "+s+" but didn't",pr.stderr.contains(s));
+        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "shutdownHooks" + ".*";
+        Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s));
         String cc="ClassNotFoundException";
         Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc));
         Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);
diff -r dde230f3536a -r c95fe178d33d tests/jnlp_tests/simple/AllStackTraces/testcases/AllStackTracesTest.java
--- a/tests/jnlp_tests/simple/AllStackTraces/testcases/AllStackTracesTest.java	Wed May 09 16:09:00 2012 -0400
+++ b/tests/jnlp_tests/simple/AllStackTraces/testcases/AllStackTracesTest.java	Tue May 22 14:52:43 2012 +0200
@@ -53,8 +53,8 @@
         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/AllStackTraces.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String c="java.security.AccessControlException: access denied (java.lang.RuntimePermission getStackTrace)";	
-        Assert.assertTrue("stderr should contains `"+c+"`, but didn't ",pr.stderr.contains(c));
+        String c = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "getStackTrace" + ".*";
+        Assert.assertTrue("stderr should match `"+c+"`, but didn't ",pr.stderr.matches(c));
         String cc="ClassNotFoundException";
         Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did ",pr.stderr.contains(cc));
         Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);
diff -r dde230f3536a -r c95fe178d33d tests/jnlp_tests/simple/CreateClassLoader/testcases/CreateClassLoaderTest.java
--- a/tests/jnlp_tests/simple/CreateClassLoader/testcases/CreateClassLoaderTest.java	Wed May 09 16:09:00 2012 -0400
+++ b/tests/jnlp_tests/simple/CreateClassLoader/testcases/CreateClassLoaderTest.java	Tue May 22 14:52:43 2012 +0200
@@ -51,8 +51,8 @@
         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/CreateClassLoader.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader)";
-        Assert.assertTrue("Stderr should contains "+s+" but didn't",pr.stderr.contains(s));
+        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "createClassLoader" + ".*";
+        Assert.assertTrue("Stderr should match "+s+" but didn't",pr.stderr.matches(s));
         String cc="ClassNotFoundException";
         Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc));
         Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);
diff -r dde230f3536a -r c95fe178d33d tests/jnlp_tests/simple/ReadEnvironment/testcases/ReadEnvironmentTest.java
--- a/tests/jnlp_tests/simple/ReadEnvironment/testcases/ReadEnvironmentTest.java	Wed May 09 16:09:00 2012 -0400
+++ b/tests/jnlp_tests/simple/ReadEnvironment/testcases/ReadEnvironmentTest.java	Tue May 22 14:52:43 2012 +0200
@@ -51,8 +51,8 @@
         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/ReadEnvironment.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.USER)";
-        Assert.assertTrue("stderr should contains "+s+"but didn't",pr.stderr.contains(s));
+        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "getenv.USER" + ".*";
+        Assert.assertTrue("stderr should match"+s+"but didn't",pr.stderr.matches(s));
         String cc="ClassNotFoundException";
         Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc));
         Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);
diff -r dde230f3536a -r c95fe178d33d tests/jnlp_tests/simple/ReadProperties/testcases/ReadPropertiesTest.java
--- a/tests/jnlp_tests/simple/ReadProperties/testcases/ReadPropertiesTest.java	Wed May 09 16:09:00 2012 -0400
+++ b/tests/jnlp_tests/simple/ReadProperties/testcases/ReadPropertiesTest.java	Tue May 22 14:52:43 2012 +0200
@@ -52,8 +52,8 @@
         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties1.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.util.PropertyPermission user.name read)";
-        Assert.assertTrue("stderr should contains "+s+" but didn't",pr.stderr.contains(s));
+        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.util.PropertyPermission.{0,5}" + "user.name.{0,5}read" + ".*";
+        Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s));
         String cc="ClassNotFoundException";
         Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc));
         Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);
@@ -61,15 +61,15 @@
         Assert.assertEquals((Integer)0, pr.returnValue);
     }
 
- @Test
+    @Test
     public void ReadPropertiesLunch2() throws Exception {
         System.out.println("connecting ReadProperties2 request");
         System.err.println("connecting ReadProperties2 request");
         ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/ReadProperties2.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read)";
-        Assert.assertTrue("stderr should contains "+s+" but didn't",pr.stderr.contains(s));
+        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.util.PropertyPermission.{0,5}" + "user.home.{0,5}read" + ".*";
+        Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s));
         String cc="ClassNotFoundException";
         Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc));
         Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);
diff -r dde230f3536a -r c95fe178d33d tests/jnlp_tests/simple/RedirectStreams/testcases/RedirectStreamsTest.java
--- a/tests/jnlp_tests/simple/RedirectStreams/testcases/RedirectStreamsTest.java	Wed May 09 16:09:00 2012 -0400
+++ b/tests/jnlp_tests/simple/RedirectStreams/testcases/RedirectStreamsTest.java	Tue May 22 14:52:43 2012 +0200
@@ -50,8 +50,8 @@
         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/RedirectStreams.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.lang.RuntimePermission setIO)";
-        Assert.assertTrue("Stderr should contains "+s+" but didn't",pr.stderr.contains(s));
+        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "setIO" + ".*";
+        Assert.assertTrue("Stderr should match "+s+" but didn't",pr.stderr.matches(s));
         String cc="ClassNotFoundException";
         Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc));
         Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);
diff -r dde230f3536a -r c95fe178d33d tests/jnlp_tests/simple/ReplaceSecurityManager/testcases/ReplaceSecurityManagerTest.java
--- a/tests/jnlp_tests/simple/ReplaceSecurityManager/testcases/ReplaceSecurityManagerTest.java	Wed May 09 16:09:00 2012 -0400
+++ b/tests/jnlp_tests/simple/ReplaceSecurityManager/testcases/ReplaceSecurityManagerTest.java	Tue May 22 14:52:43 2012 +0200
@@ -50,8 +50,8 @@
         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/ReplaceSecurityManager.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.lang.RuntimePermission setSecurityManager)";
-        Assert.assertTrue("stderr should contains "+s+" but didn't",pr.stderr.contains(s));
+        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "setSecurityManager" + ".*";
+        Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s));
         String cc="ClassNotFoundException";
         Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc));
         Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);
diff -r dde230f3536a -r c95fe178d33d tests/jnlp_tests/simple/SetContextClassLoader/testcases/SetContextClassLoaderTest.java
--- a/tests/jnlp_tests/simple/SetContextClassLoader/testcases/SetContextClassLoaderTest.java	Wed May 09 16:09:00 2012 -0400
+++ b/tests/jnlp_tests/simple/SetContextClassLoader/testcases/SetContextClassLoaderTest.java	Tue May 22 14:52:43 2012 +0200
@@ -50,8 +50,8 @@
         ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/SetContextClassLoader.jnlp");
         System.out.println(pr.stdout);
         System.err.println(pr.stderr);
-        String s="java.security.AccessControlException: access denied (java.lang.RuntimePermission setContextClassLoader)";
-        Assert.assertTrue("stderr should contains "+s+" but didn't",pr.stderr.contains(s));
+        String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "setContextClassLoader" + ".*";
+        Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s));
         String cc="ClassNotFoundException";
         Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc));
         Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2);



More information about the distro-pkg-dev mailing list