/hg/icedtea-web: Added possibility to run signed applets during ...
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Wed Apr 18 03:27:52 PDT 2012
changeset 14dcb4fb43ac in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=14dcb4fb43ac
author: Jiri Vanek <jvanek at redhat.com>
date: Wed Apr 18 12:28:08 2012 +0200
Added possibility to run signed applets during reproducers runs.
Added example reproducer.
diffstat:
ChangeLog | 27 ++
Makefile.am | 39 ++-
tests/jnlp_tests/signed/AppletTestSigned/resources/AppletTestSigned.html | 46 ++++
tests/jnlp_tests/signed/AppletTestSigned/resources/AppletTestSigned.jnlp | 63 ++++++
tests/jnlp_tests/signed/AppletTestSigned/srcs/AppletTestSigned.java | 82 ++++++++
tests/jnlp_tests/signed/AppletTestSigned/testcases/AppletTestSignedTests.java | 99 ++++++++++
6 files changed, 345 insertions(+), 11 deletions(-)
diffs (432 lines):
diff -r 2a13d6d1b57c -r 14dcb4fb43ac ChangeLog
--- a/ChangeLog Tue Apr 17 16:43:11 2012 +0200
+++ b/ChangeLog Wed Apr 18 12:28:08 2012 +0200
@@ -1,3 +1,30 @@
+2012-04-18 Jiri Vanek <jvanek at redhat.com>
+
+ Allowed signed applets in automatic reproducers tests
+ * tests/jnlp_tests/signed/AppletTestSigned/resources/AppletTestSigned.html:
+ html file for launching signed applet. Its style is different from the one for
+ calling unsigned applets - red.
+ * tests/jnlp_tests/signed/AppletTestSigned/resources/AppletTestSigned.jnlp:
+ jnlp file for launched signed applet
+ * tests/jnlp_tests/signed/AppletTestSigned/srcs/AppletTestSigned.java
+ body of signed applet
+ * tests/jnlp_tests/signed/AppletTestSigned/testcases/AppletTestSignedTests.java:
+ (AppletTestSignedTest): testing method to launch signed applet in javaws
+ (AppletTestSignedFirefoxTest): testing method to launch signed applet in
+ browser
+ * Makefile.am: PUBLIC_KEYSTORE_PASS, EXPORTED_TEST_CERT, TEST_CERT_ALIAS,
+ PUBLIC_KEYSTORE PUBLIC_KEYSTORE_PASS: new global variables holding
+ keystores' credentials
+ (clean-local): clean-bootstrap-directory moved to be last one, as keytool
+ is necessary for removing certificate
+ (EXPORTED_TEST_CERT): new target exporting certificate from testing keystore
+ (stamps/netx-dist-tests-import-cert-to-public): new target to import
+ certificate to PUBLIC_KEYSTORE
+ (netx-dist-tests-remove-cert-from-public): new target removing testing
+ certificate from PUBLIC_KEYSTORE
+ (clean-netx-dist-tests): now depends on netx-dist-tests-remove-cert-from-public
+ and is removing EXPORTED_TEST_CERT file
+
2012-04-17 Jiri Vanek <jvanek at redhat.com>
Rewritten DeadLockTestTest to stop failing in more then 1/2 of cases
diff -r 2a13d6d1b57c -r 14dcb4fb43ac Makefile.am
--- a/Makefile.am Tue Apr 17 16:43:11 2012 +0200
+++ b/Makefile.am Wed Apr 18 12:28:08 2012 +0200
@@ -22,7 +22,12 @@
JNLP_TESTS_ENGINE_DIR=$(TESTS_DIR)/netx/jnlp_testsengine
JNLP_TESTS_SERVER_DEPLOYDIR=$(TESTS_DIR)/jnlp_test_server
JNLP_TESTS_DIR=$(TESTS_DIR)/jnlp_tests
-KEYSTORE_NAME=teststore.ks
+PRIVATE_KEYSTORE_NAME=teststore.ks
+PRIVATE_KEYSTORE_PASS=123456789
+EXPORTED_TEST_CERT=icedteatests.crt
+TEST_CERT_ALIAS=icedteaweb
+PUBLIC_KEYSTORE=~/.icedtea/security/trusted.certs
+PUBLIC_KEYSTORE_PASS=changeit
JUNIT_RUNNER_JAR=$(abs_top_builddir)/junit-runner.jar
UNIT_CLASS_NAMES = $(abs_top_builddir)/unit_class_names
@@ -142,8 +147,8 @@
check-local: $(RHINO_TESTS) $(JUNIT_TESTS)
-clean-local: clean-netx clean-plugin clean-liveconnect clean-extra clean-bootstrap-directory \
- clean-native-ecj clean-launchers clean-desktop-files clean-docs clean-tests
+clean-local: clean-netx clean-plugin clean-liveconnect clean-extra \
+ clean-native-ecj clean-launchers clean-desktop-files clean-docs clean-tests clean-bootstrap-directory
if [ -e stamps ] ; then \
rmdir stamps ; \
fi
@@ -506,19 +511,30 @@
touch $@
stamps/netx-dist-tests-sign-some-reproducers.stamp: stamps/netx-dist-tests-prepare-reproducers.stamp
- alias=icedteaweb; \
- keystore=$(abs_top_builddir)/$(KEYSTORE_NAME); \
- pass=123456789; \
- $(BOOT_DIR)/bin/keytool -genkey -alias $$alias -keystore $$keystore -keypass $$pass -storepass $$pass -dname "cn=$$alias, ou=$$alias, o=$$alias, c=$$alias" ; \
+ keystore=$(abs_top_builddir)/$(PRIVATE_KEYSTORE_NAME); \
+ $(BOOT_DIR)/bin/keytool -genkey -alias $(TEST_CERT_ALIAS) -keystore $$keystore -keypass $(PRIVATE_KEYSTORE_PASS) -storepass $(PRIVATE_KEYSTORE_PASS) -dname "cn=$(TEST_CERT_ALIAS), ou=$(TEST_CERT_ALIAS), o=$(TEST_CERT_ALIAS), c=$(TEST_CERT_ALIAS)" ; \
. $(abs_top_srcdir)/NEW_LINE_IFS ; \
signedReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-signed.txt `); \
IFS="$$IFS_BACKUP" ; \
for dir in "$${signedReproducers[@]}" ; do \
- $(BOOT_DIR)/bin/jarsigner -keystore $$keystore -storepass $$pass -keypass $$pass "$(JNLP_TESTS_SERVER_DEPLOYDIR)/$$dir.jar" $$alias ; \
+ $(BOOT_DIR)/bin/jarsigner -keystore $$keystore -storepass $(PRIVATE_KEYSTORE_PASS) -keypass $(PRIVATE_KEYSTORE_PASS) "$(JNLP_TESTS_SERVER_DEPLOYDIR)/$$dir.jar" $(TEST_CERT_ALIAS) ; \
done ; \
mkdir -p stamps && \
touch $@
+#this always tries to remove previous testcert
+$(EXPORTED_TEST_CERT): stamps/netx-dist-tests-sign-some-reproducers.stamp netx-dist-tests-remove-cert-from-public
+ keytool -export -alias $(TEST_CERT_ALIAS) -file $(EXPORTED_TEST_CERT) -storepass $(PRIVATE_KEYSTORE_PASS) -keystore $(PRIVATE_KEYSTORE_NAME)
+
+stamps/netx-dist-tests-import-cert-to-public: $(EXPORTED_TEST_CERT)
+ yes | $(BOOT_DIR)/bin/keytool -import -alias $(TEST_CERT_ALIAS) -keystore $(PUBLIC_KEYSTORE) -storepass $(PUBLIC_KEYSTORE_PASS) -file $(EXPORTED_TEST_CERT); \
+ mkdir -p stamps && \
+ touch $@
+
+netx-dist-tests-remove-cert-from-public:
+ -$(BOOT_DIR)/bin/keytool -delete -alias $(TEST_CERT_ALIAS) -keystore $(PUBLIC_KEYSTORE) -storepass $(PUBLIC_KEYSTORE_PASS)
+ -rm -rf stamps/netx-dist-tests-import-cert-to-public
+
netx-dist-tests-source-files.txt:
find $(JNLP_TESTS_ENGINE_SRCDIR) -name '*.java' | sort > $@
@@ -560,7 +576,7 @@
stamps/run-netx-dist-tests.stamp: stamps/netx-dist.stamp extra-lib/about.jar stamps/plugin.stamp launcher.build/$(javaws) \
javaws.desktop stamps/docs.stamp launcher.build/$(itweb_settings) itweb-settings.desktop \
- stamps/netx.stamp stamps/junit-jnlp-dist-dirs stamps/netx-dist-tests-sign-some-reproducers.stamp \
+ stamps/netx.stamp stamps/junit-jnlp-dist-dirs stamps/netx-dist-tests-import-cert-to-public \
stamps/netx-dist-tests-compile.stamp stamps/netx-dist-tests-compile-testcases.stamp $(JUNIT_RUNNER_JAR) \
$(TESTS_DIR)/$(REPORT_STYLES_DIRNAME) $(REPRODUCERS_CLASS_NAMES)
cd $(JNLP_TESTS_ENGINE_DIR) ; \
@@ -798,7 +814,7 @@
rm -rf $(TESTS_DIR)/$(REPORT_STYLES_DIRNAME)/
rm -f $(TESTS_DIR)/index*.html
-clean-netx-dist-tests: clean_tests_reports
+clean-netx-dist-tests: clean_tests_reports netx-dist-tests-remove-cert-from-public
rm -f netx-dist-tests-source-files.txt
rm -rf $(JNLP_TESTS_DIR)
rm -rf $(JNLP_TESTS_SERVER_DEPLOYDIR)
@@ -811,7 +827,8 @@
rm -f junit-jnlp-dist-simple.txt
rm -f junit-jnlp-dist-signed.txt
rm -f $(REPRODUCERS_CLASS_NAMES)
- rm -f $(abs_top_builddir)/$(KEYSTORE_NAME)
+ rm -f $(abs_top_builddir)/$(PRIVATE_KEYSTORE_NAME)
+ rm -f $(EXPORTED_TEST_CERT)
rm -f stamps/run-netx-dist-tests.stamp
clean-unit-test-code-coverage:
diff -r 2a13d6d1b57c -r 14dcb4fb43ac tests/jnlp_tests/signed/AppletTestSigned/resources/AppletTestSigned.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/signed/AppletTestSigned/resources/AppletTestSigned.html Wed Apr 18 12:28:08 2012 +0200
@@ -0,0 +1,46 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+ -->
+<html><head></head><body bgcolor="red">
+<p>
+ <applet code="AppletTestSigned.class" archive="XslowXAppletTestSigned.jar" codebase="." width="100" height="100">
+ <param name="key1" value="value1">
+ <param name="key2" value="#value2">
+ </applet>
+</p>
+</body>
+</html>
diff -r 2a13d6d1b57c -r 14dcb4fb43ac tests/jnlp_tests/signed/AppletTestSigned/resources/AppletTestSigned.jnlp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/signed/AppletTestSigned/resources/AppletTestSigned.jnlp Wed Apr 18 12:28:08 2012 +0200
@@ -0,0 +1,63 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="AppletTestSigned.jnlp" codebase=".">
+ <information>
+ <title>SignedAppletTest</title>
+ <vendor>IcedTea</vendor>
+ <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web "/>
+ <description>SignedAppletTest</description>
+ <offline/>
+ </information>
+ <resources>
+ <j2se version="1.4+"/>
+ <jar href="AppletTestSigned.jar"/>
+ </resources>
+ <applet-desc
+ documentBase="."
+ name="AppletTest"
+ main-class="AppletTestSigned"
+ width="100"
+ height="100">
+ <param name="key1" value="value1"/>
+ <param name="key2" value="value2"/>
+ </applet-desc>
+</jnlp>
+
+
+</applet-desc>
diff -r 2a13d6d1b57c -r 14dcb4fb43ac tests/jnlp_tests/signed/AppletTestSigned/srcs/AppletTestSigned.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/signed/AppletTestSigned/srcs/AppletTestSigned.java Wed Apr 18 12:28:08 2012 +0200
@@ -0,0 +1,82 @@
+/* AppletTestSigned.java
+Copyright (C) 2012 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.
+ */
+
+import java.applet.Applet;
+
+public class AppletTestSigned extends Applet {
+
+ private class Killer extends Thread {
+
+ public int n = 2000;
+
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(n);
+ System.out.println("AppletTestSigned killing himself after " + n + " ms of life");
+ System.exit(0);
+ } catch (Exception ex) {
+ }
+ }
+ }
+ private Killer killer;
+
+ @Override
+ public void init() {
+ System.out.println("AppletTestSigned was initialised");
+ killer = new Killer();
+ }
+
+ @Override
+ public void start() {
+ System.out.println("AppletTestSigned was started");
+ System.out.println(getParameter("key1"));
+ System.out.println(getParameter("key2"));
+ killer.start();
+ System.out.println("killer was started");
+ }
+
+ @Override
+ public void stop() {
+ System.out.println("AppletTestSigned was stopped");
+ }
+
+ @Override
+ public void destroy() {
+ System.out.println("AppletTestSigned will be destroyed");
+ }
+}
diff -r 2a13d6d1b57c -r 14dcb4fb43ac tests/jnlp_tests/signed/AppletTestSigned/testcases/AppletTestSignedTests.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jnlp_tests/signed/AppletTestSigned/testcases/AppletTestSignedTests.java Wed Apr 18 12:28:08 2012 +0200
@@ -0,0 +1,99 @@
+/* AppletTestSignedTests.java
+Copyright (C) 2012 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.
+ */
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import net.sourceforge.jnlp.ServerAccess;
+import net.sourceforge.jnlp.ServerAccess.ProcessResult;
+import org.junit.Assert;
+
+import org.junit.Test;
+
+public class AppletTestSignedTests {
+
+ private static ServerAccess server = new ServerAccess();
+ private final List<String> l = Collections.unmodifiableList(Arrays.asList(new String[]{"-Xtrustall"}));
+
+ @Test
+ public void AppletTestSignedTest() throws Exception {
+ System.out.println("connecting AppletTestSigned request");
+ System.err.println("connecting AppletTestSigned request");
+ ServerAccess.ProcessResult pr = server.executeJavawsHeadless(l, "/AppletTestSigned.jnlp");
+ System.out.println(pr.stdout);
+ System.err.println(pr.stderr);
+ evaluateSignedApplet(pr);
+ Assert.assertFalse(pr.wasTerminated);
+ Assert.assertEquals((Integer) 0, pr.returnValue);
+ }
+
+ private void evaluateSignedApplet(ProcessResult pr) {
+ String s3 = "AppletTestSigned was initialised";
+ Assert.assertTrue("AppletTestSigned stdout should contain " + s3 + " but didn't", pr.stdout.contains(s3));
+ String s0 = "AppletTestSigned was started";
+ Assert.assertTrue("AppletTestSigned stdout should contain " + s0 + " but didn't", pr.stdout.contains(s0));
+ String s1 = "value1";
+ Assert.assertTrue("AppletTestSigned stdout should contain " + s1 + " but didn't", pr.stdout.contains(s1));
+ String s2 = "value2";
+ Assert.assertTrue("AppletTestSigned stdout should contain " + s2 + " but didn't", pr.stdout.contains(s2));
+ String s4 = "AppletTestSigned was stopped";
+ Assert.assertFalse("AppletTestSigned stdout shouldn't contain " + s4 + " but did", pr.stdout.contains(s4));
+ String s5 = "AppletTestSigned will be destroyed";
+ Assert.assertFalse("AppletTestSigned stdout shouldn't contain " + s5 + " but did", pr.stdout.contains(s5));
+ String ss = "xception";
+ Assert.assertFalse("AppletTestSigned stderr should not contain " + ss + " but did", pr.stderr.contains(ss));
+ String s7 = "AppletTestSigned killing himself after 2000 ms of life";
+ Assert.assertTrue("AppletTestSigned stdout should contain " + s7 + " but didn't", pr.stdout.contains(s7));
+ }
+
+ @Test
+ public void AppletTestSignedFirefoxTest() throws Exception {
+ System.out.println("connecting AppletTestSigned in firefox request");
+ System.err.println("connecting AppletTestSigned in firefox request");
+ ServerAccess.PROCESS_TIMEOUT = 30 * 1000;
+ try {
+ ServerAccess.ProcessResult pr = server.executeBrowser("/AppletTestSigned.html");
+ System.out.println(pr.stdout);
+ System.err.println(pr.stderr);
+ evaluateSignedApplet(pr);
+ Assert.assertTrue(pr.wasTerminated);
+ //Assert.assertEquals((Integer) 0, pr.returnValue); due to destroy is null
+ } finally {
+ ServerAccess.PROCESS_TIMEOUT = 20 * 1000; //back to normal
+ }
+ }
+}
More information about the distro-pkg-dev
mailing list