/hg/icedtea-web: New 2-arg constructor for CustomPermission
aazores at icedtea.classpath.org
aazores at icedtea.classpath.org
Thu Jun 19 13:52:02 UTC 2014
changeset 50ef0215a6d5 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=50ef0215a6d5
author: Andrew Azores <aazores at redhat.com>
date: Thu Jun 19 09:51:39 2014 -0400
New 2-arg constructor for CustomPermission
2014-06-19 Andrew Azores <aazores at redhat.com>
* netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java:
added 2-arg constructor for permissions without actions
* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java
(testToStringWithoutActions) renamed testToStringWithEmptyActions
(testToStringWithNoActions) new test
* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPolicyViewerTest.java
(PERMISSION) uses 2-arg constructor
* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java
(testAddCustomPermission) renamed testAddCustomPermissionEmptyActions
(testClearCustomPermissions) renamed testClearCustomPermissionsEmptyActions
(testAddCustomPermissionNoActions) new test
(testClearCustomPermissionsNoActions) new test
diffstat:
ChangeLog | 17 +++++++-
netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java | 11 +++++
tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java | 21 ++++++++-
tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPolicyViewerTest.java | 2 +-
tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java | 22 +++++++++-
5 files changed, 67 insertions(+), 6 deletions(-)
diffs (133 lines):
diff -r 3eec89a2205e -r 50ef0215a6d5 ChangeLog
--- a/ChangeLog Thu Jun 19 12:55:49 2014 +0200
+++ b/ChangeLog Thu Jun 19 09:51:39 2014 -0400
@@ -1,4 +1,19 @@
-2014-06-19 Kurt Miller <kurt at intricatesoftware.com>
+2014-06-19 Andrew Azores <aazores at redhat.com>
+
+ * netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java:
+ added 2-arg constructor for permissions without actions
+ * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java
+ (testToStringWithoutActions) renamed testToStringWithEmptyActions
+ (testToStringWithNoActions) new test
+ * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPolicyViewerTest.java
+ (PERMISSION) uses 2-arg constructor
+ * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java
+ (testAddCustomPermission) renamed testAddCustomPermissionEmptyActions
+ (testClearCustomPermissions) renamed testClearCustomPermissionsEmptyActions
+ (testAddCustomPermissionNoActions) new test
+ (testClearCustomPermissionsNoActions) new test
+
+2014-06-19 Kurt Miller <kurt at intricatesoftware.com>
Fixed PR1743 - Intermittant deadlock in PluginRequestProcessor
* NEWS: added PR1743
diff -r 3eec89a2205e -r 50ef0215a6d5 netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java Thu Jun 19 12:55:49 2014 +0200
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java Thu Jun 19 09:51:39 2014 -0400
@@ -61,6 +61,17 @@
public final String type, target, actions;
/**
+ * Constructor for custom basic permissions (ie those without actions). This is equivalent
+ * to CustomPermission(type, target, "")
+ * @param type eg java.io.FilePermission
+ * @param target eg ${user.home}${/}*
+ */
+ public CustomPermission(final String type, final String target) {
+ this(type, target, "");
+ }
+
+ /**
+ * Constructor for custom permissions with actions
* @param type eg java.io.FilePermission
* @param target eg ${user.home}${/}*
* @param actions eg read,write
diff -r 3eec89a2205e -r 50ef0215a6d5 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java Thu Jun 19 12:55:49 2014 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java Thu Jun 19 09:51:39 2014 -0400
@@ -116,14 +116,31 @@
}
@Test
- public void testToStringWithoutActions() throws Exception {
+ public void testToStringWithNoActions() throws Exception {
+ final CustomPermission cp = new CustomPermission("java.lang.RuntimePermission", "createClassLoader");
+ final String expected = "permission java.lang.RuntimePermission \"createClassLoader\";";
+ assertEquals(expected, cp.toString());
+ }
+
+ @Test
+ public void testToStringWithEmptyActions() throws Exception {
final CustomPermission cp = new CustomPermission("java.lang.RuntimePermission", "createClassLoader", "");
final String expected = "permission java.lang.RuntimePermission \"createClassLoader\";";
assertEquals(expected, cp.toString());
}
@Test
- public void testCompareTo() throws Exception {
+ public void testCompareToWithNoActions() throws Exception {
+ final CustomPermission cp1 = new CustomPermission("java.io.FilePermission", "*", "read");
+ final CustomPermission cp2 = new CustomPermission("java.io.FilePermission", "${user.home}${/}*", "read");
+ final CustomPermission cp3 = new CustomPermission("java.lang.RuntimePermission", "queuePrintJob");
+ assertTrue("cp1.compareTo(cp2) should be > 0", cp1.compareTo(cp2) > 0);
+ assertTrue("cp1.compareTo(cp1) should be 0", cp1.compareTo(cp1) == 0);
+ assertTrue("cp2.compareTo(cp3) should be < 0", cp2.compareTo(cp3) < 0);
+ }
+
+ @Test
+ public void testCompareToWithEmptyActions() throws Exception {
final CustomPermission cp1 = new CustomPermission("java.io.FilePermission", "*", "read");
final CustomPermission cp2 = new CustomPermission("java.io.FilePermission", "${user.home}${/}*", "read");
final CustomPermission cp3 = new CustomPermission("java.lang.RuntimePermission", "queuePrintJob", "");
diff -r 3eec89a2205e -r 50ef0215a6d5 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPolicyViewerTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPolicyViewerTest.java Thu Jun 19 12:55:49 2014 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPolicyViewerTest.java Thu Jun 19 09:51:39 2014 -0400
@@ -55,7 +55,7 @@
private CustomPolicyViewer viewer;
private static final String CODEBASE = "http://example.com";
- private static final CustomPermission PERMISSION = new CustomPermission("java.lang.RuntimePermission", "createClassLoader", "");
+ private static final CustomPermission PERMISSION = new CustomPermission("java.lang.RuntimePermission", "createClassLoader");
@Before
public void setupViewer() {
diff -r 3eec89a2205e -r 50ef0215a6d5 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java Thu Jun 19 12:55:49 2014 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java Thu Jun 19 09:51:39 2014 -0400
@@ -143,7 +143,15 @@
}
@Test
- public void testAddCustomPermission() throws Exception {
+ public void testAddCustomPermissionNoActions() throws Exception {
+ final String codebase = "http://example.com";
+ final CustomPermission customPermission = new CustomPermission("java.lang.RuntimePermission", "createClassLoader");
+ editor.addCustomPermission(codebase, customPermission);
+ assertTrue("Editor custom permissions should include " + customPermission + " but did not", editor.getCustomPermissions(codebase).contains(customPermission));
+ }
+
+ @Test
+ public void testAddCustomPermissionEmptyActions() throws Exception {
final String codebase = "http://example.com";
final CustomPermission customPermission = new CustomPermission("java.lang.RuntimePermission", "createClassLoader", "");
editor.addCustomPermission(codebase, customPermission);
@@ -151,7 +159,17 @@
}
@Test
- public void testClearCustomPermissions() throws Exception {
+ public void testClearCustomPermissionsNoActions() throws Exception {
+ final String codebase = "http://example.com";
+ final CustomPermission customPermission = new CustomPermission("java.lang.RuntimePermission", "createClassLoader");
+ editor.addCustomPermission(codebase, customPermission);
+ assertTrue("Editor custom permissions should include " + customPermission + " but did not", editor.getCustomPermissions(codebase).contains(customPermission));
+ editor.clearCustomPermissions(codebase);
+ assertEquals(0, editor.getCustomPermissions(codebase).size());
+ }
+
+ @Test
+ public void testClearCustomPermissionsEmptyActions() throws Exception {
final String codebase = "http://example.com";
final CustomPermission customPermission = new CustomPermission("java.lang.RuntimePermission", "createClassLoader", "");
editor.addCustomPermission(codebase, customPermission);
More information about the distro-pkg-dev
mailing list