/hg/icedtea-web: tests/netx/unit/net/sourceforge/jnlp/security/K...
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Thu Apr 2 18:09:37 UTC 2015
changeset 149d36336ed5 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=149d36336ed5
author: Jiri Vanek <jvanek at redhat.com>
date: Thu Apr 02 20:09:00 2015 +0200
tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java: new file, added tests for getKeyStoreLocation API.
tests/netx/unit/net/sourceforge/jnlp/security/SecurityDialogsTest.java: minor cleanup on redundant autoboxing.
diffstat:
ChangeLog | 7 +
tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java | 137 ++++++++++
tests/netx/unit/net/sourceforge/jnlp/security/SecurityDialogsTest.java | 32 +-
3 files changed, 160 insertions(+), 16 deletions(-)
diffs (206 lines):
diff -r c1ee9d4fa266 -r 149d36336ed5 ChangeLog
--- a/ChangeLog Thu Apr 02 12:09:53 2015 +0200
+++ b/ChangeLog Thu Apr 02 20:09:00 2015 +0200
@@ -1,3 +1,10 @@
+2015-04-02 Jiri Vanek <jvanek at redhat.com>
+
+ * tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java: new file,
+ added tests for getKeyStoreLocation API.
+ * tests/netx/unit/net/sourceforge/jnlp/security/SecurityDialogsTest.java: minor
+ cleanup on redundant autoboxing.
+
2015-04-01 Jiri Vanek <jvanek at redhat.com>
PathsAndFiles definitions made aware of deployment.properties which can change them
diff -r c1ee9d4fa266 -r 149d36336ed5 tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java Thu Apr 02 20:09:00 2015 +0200
@@ -0,0 +1,137 @@
+/*
+ Copyright (C) 2011 Red Hat, Inc.
+
+ This file is part of IcedTea.
+
+ IcedTea is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 2.
+
+ IcedTea is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with IcedTea; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+ */
+package net.sourceforge.jnlp.security;
+
+import java.io.File;
+import java.security.Permission;
+import net.sourceforge.jnlp.config.PathsAndFiles;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class KeyStoresTest {
+
+ private class DummySM extends SecurityManager {
+ boolean called = false;
+
+ @Override
+ public void checkPermission(Permission perm) {
+ called=true;
+ }
+
+ }
+
+ @AfterClass
+ public static void removeClassLaoder() {
+ System.setSecurityManager(null);
+ }
+
+ //TODO once setConfig is removed, ensure SM is enforced also from PathsAndFiles
+ @Test
+ public void getKeyStoreUserLocationTest() {
+ String s;
+ System.setSecurityManager(null);
+ KeyStores.setConfiguration(JNLPRuntime.getConfiguration());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.CA_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_CACERTS.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_CERTS.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.CLIENT_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_CLIENTCERT.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.JSSE_CA_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_JSSECAC.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.JSSE_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_JSSECER.getFile());
+ }
+
+ @Test
+ public void getKeyStoreSystemLocationTest() {
+ String s;
+ System.setSecurityManager(null);
+ KeyStores.setConfiguration(JNLPRuntime.getConfiguration());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.CA_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_CACERT.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_CERT.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.CLIENT_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_CLIENTCERT.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.JSSE_CA_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_JSSECAC.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.JSSE_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_JSSECERT.getFile());
+ }
+
+ @Test
+ public void getKeyStoreUserLocationTestSM() {
+ DummySM dm = new DummySM();
+ System.setSecurityManager(dm);
+ String s;
+ KeyStores.setConfiguration(JNLPRuntime.getConfiguration());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.CA_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_CACERTS.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_CERTS.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.CLIENT_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_CLIENTCERT.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.JSSE_CA_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_JSSECAC.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.JSSE_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.USER_JSSECER.getFile());
+ Assert.assertEquals(true, dm.called);
+ }
+
+ @Test
+ public void getKeyStoreSystemLocationTestSM() {
+ DummySM dm = new DummySM();
+ System.setSecurityManager(dm);
+ String s;
+ KeyStores.setConfiguration(JNLPRuntime.getConfiguration());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.CA_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_CACERT.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_CERT.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.CLIENT_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_CLIENTCERT.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.JSSE_CA_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_JSSECAC.getFile());
+ s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.JSSE_CERTS);
+ Assert.assertEquals(new File(s), PathsAndFiles.SYS_JSSECERT.getFile());
+ Assert.assertEquals(true, dm.called);
+ }
+
+}
diff -r c1ee9d4fa266 -r 149d36336ed5 tests/netx/unit/net/sourceforge/jnlp/security/SecurityDialogsTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/SecurityDialogsTest.java Thu Apr 02 12:09:53 2015 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/SecurityDialogsTest.java Thu Apr 02 20:09:00 2015 +0200
@@ -51,14 +51,14 @@
public void testGetIntegerResponseAsBoolean() throws Exception {
Object nullRef = null;
Object objRef = new Object();
- Float floatRef = new Float(0.0f);
- Double doubleRef = new Double(0.0d);
- Long longRef = new Long(0);
- Byte byteRef = new Byte((byte)0);
- Short shortRef = new Short((short)0);
+ Float floatRef = 0.0f;
+ Double doubleRef = 0.0d;
+ Long longRef = (long) 0;
+ Byte byteRef = (byte)0;
+ Short shortRef = (short)0;
String strRef = "0";
- Integer intRef1 = new Integer(5);
- Integer intRef2 = new Integer(0);
+ Integer intRef1 = 5;
+ Integer intRef2 = 0;
assertFalse("null reference should have resulted in false", getIntegerResponseAsBoolean(nullRef));
assertFalse("Object reference should have resulted in false", getIntegerResponseAsBoolean(objRef));
@@ -76,16 +76,16 @@
public void testGetIntegerResponseAsAppletAction() throws Exception {
Object nullRef = null;
Object objRef = new Object();
- Float floatRef = new Float(0.0f);
- Double doubleRef = new Double(0.0d);
- Long longRef = new Long(0);
- Byte byteRef = new Byte((byte) 0);
- Short shortRef = new Short((short) 0);
+ Float floatRef = 0.0f;
+ Double doubleRef = 0.0d;
+ Long longRef = (long) 0;
+ Byte byteRef = (byte) 0;
+ Short shortRef = (short) 0;
String strRef = "0";
- Integer intRef1 = new Integer(0);
- Integer intRef2 = new Integer(1);
- Integer intRef3 = new Integer(2);
- Integer intRef4 = new Integer(3);
+ Integer intRef1 = 0;
+ Integer intRef2 = 1;
+ Integer intRef3 = 2;
+ Integer intRef4 = 3;
assertEquals("null reference should have resulted in CANCEL", getIntegerResponseAsAppletAction(nullRef), CANCEL);
assertEquals("Object reference should have resulted in CANCEL", getIntegerResponseAsAppletAction(objRef), CANCEL);
More information about the distro-pkg-dev
mailing list