diff -r fc73a2a7f392 Makefile.am --- a/Makefile.am Fri Jun 24 11:50:41 2011 +0200 +++ b/Makefile.am Fri Jun 24 15:57:30 2011 +0200 @@ -22,6 +22,7 @@ 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 JUNIT_RUNNER_JAR=$(abs_top_builddir)/junit-runner.jar @@ -455,23 +456,45 @@ @junit-runner-source-files.txt && \ $(BOOT_DIR)/bin/jar cf $@ -C $(JUNIT_RUNNER_DIR) . -junit-jnlp-dist-dirs.txt: +junit-jnlp-dist-dirs: junit-jnlp-dist-simple.txt junit-jnlp-dist-signed.txt mkdir -p $(JNLP_TESTS_SERVER_DEPLOYDIR) mkdir -p $(JNLP_TESTS_DIR) mkdir -p $(JNLP_TESTS_ENGINE_DIR) + +junit-jnlp-dist-simple.txt: cd $(JNLP_TESTS_SRCDIR)/simple/ ; \ find . -maxdepth 1 -mindepth 1 | sed "s/.\/*//" > $(abs_top_builddir)/$@ -stamps/netx-dist-tests-prepare-reproducers.stamp: junit-jnlp-dist-dirs.txt - simpleReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-dirs.txt `); \ +junit-jnlp-dist-signed.txt: + cd $(JNLP_TESTS_SRCDIR)/signed/ ; \ + find . -maxdepth 1 -mindepth 1 | sed "s/.\/*//" > $(abs_top_builddir)/$@ + + +stamps/netx-dist-tests-prepare-reproducers.stamp: junit-jnlp-dist-dirs + types=(simple signed); \ + for which in "$${types[@]}" ; do \ + simpleReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-$$which.txt `); \ for dir in "$${simpleReproducers[@]}" ; do \ mkdir -p $(JNLP_TESTS_DIR)/$$dir ; \ - $(BOOT_DIR)/bin/javac -d $(JNLP_TESTS_DIR)/$$dir/ $(JNLP_TESTS_SRCDIR)/simple/$$dir/srcs/* ; \ + $(BOOT_DIR)/bin/javac -d $(JNLP_TESTS_DIR)/$$dir/ $(JNLP_TESTS_SRCDIR)/$$which/$$dir/srcs/* ; \ d=`pwd` ; \ cd $(JNLP_TESTS_DIR)/$$dir/ ; \ $(BOOT_DIR)/bin/jar cf $(JNLP_TESTS_SERVER_DEPLOYDIR)/$$dir.jar * ; \ cd $$d ; \ - cp -R $(JNLP_TESTS_SRCDIR)/simple/$$dir/resources/* $(JNLP_TESTS_SERVER_DEPLOYDIR)/ ; \ + cp -R $(JNLP_TESTS_SRCDIR)/$$which/$$dir/resources/* $(JNLP_TESTS_SERVER_DEPLOYDIR)/ ; \ + done ; \ + done ; \ + mkdir -p stamps && \ + touch $@ + +stamps/netx-dist-tests-sign-some-reproducers.stamp: stamps/netx-dist-tests-prepare-reproducers.stamp + alias=redhat; \ + 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" ; \ + simpleReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-signed.txt `); \ + for dir in "$${simpleReproducers[@]}" ; do \ + $(JARSIGNER) -keystore $$keystore -storepass $$pass -keypass $$pass $(JNLP_TESTS_SERVER_DEPLOYDIR)/$$dir.jar $$alias ; \ done ; \ mkdir -p stamps && \ touch $@ @@ -480,7 +503,7 @@ find $(JNLP_TESTS_ENGINE_SRCDIR) -name '*.java' | sort > $@ stamps/netx-dist-tests-compile.stamp: stamps/netx.stamp \ - junit-jnlp-dist-dirs.txt netx-dist-tests-source-files.txt + junit-jnlp-dist-dirs netx-dist-tests-source-files.txt $(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \ -d $(JNLP_TESTS_ENGINE_DIR) \ -classpath $(JUNIT_JAR):$(NETX_DIR)/lib/classes.jar \ @@ -488,19 +511,22 @@ mkdir -p stamps && \ touch $@ -stamps/netx-dist-tests-compile-testcases.stamp: stamps/netx.stamp junit-jnlp-dist-dirs.txt\ +stamps/netx-dist-tests-compile-testcases.stamp: stamps/netx.stamp junit-jnlp-dist-dirs \ netx-dist-tests-source-files.txt stamps/netx-dist-tests-compile.stamp - simpleReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-dirs.txt `); \ + types=(simple signed); \ + for which in "$${types[@]}" ; do \ + simpleReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-$$which.txt `); \ for dir in "$${simpleReproducers[@]}" ; do \ $(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \ -d $(JNLP_TESTS_ENGINE_DIR) \ -classpath $(JUNIT_JAR):$(NETX_DIR)/lib/classes.jar:$(JNLP_TESTS_ENGINE_DIR) \ - $(JNLP_TESTS_SRCDIR)/simple/$$dir/testcases/* ; \ + $(JNLP_TESTS_SRCDIR)/$$which/$$dir/testcases/* ; \ + done ; \ done ; \ mkdir -p stamps && \ touch $@ -run-netx-dist-tests: all-local stamps/netx.stamp junit-jnlp-dist-dirs.txt stamps/netx-dist-tests-prepare-reproducers.stamp \ +run-netx-dist-tests: all-local stamps/netx.stamp junit-jnlp-dist-dirs stamps/netx-dist-tests-sign-some-reproducers.stamp \ stamps/netx-dist-tests-compile.stamp stamps/netx-dist-tests-compile-testcases.stamp $(JUNIT_RUNNER_JAR) $(TESTS_DIR)/$(REPORT_STYLES_DIRNAME) cd $(JNLP_TESTS_ENGINE_DIR) ; \ class_names= ; \ @@ -581,7 +607,10 @@ rm -f stamps/netx-dist-tests-compile.stamp rm -f stamps/netx-dist-tests-prepare-reproducers.stamp rm -f stamps/netx-dist-tests-compile-testcases.stamp - rm -f junit-jnlp-dist-dirs.txt + rm -f stamps/netx-dist-tests-sign-some-reproducers.stamp + rm -f junit-jnlp-dist-simple.txt + rm -f junit-jnlp-dist-signed.txt + rm -f $(abs_top_builddir)/$(keystore_name) # plugin tests @@ -623,6 +652,8 @@ ln -sf $(JAR) $(BOOT_DIR)/bin/jar ln -sf $(abs_top_builddir)/javac $(BOOT_DIR)/bin/javac ln -sf $(JAVADOC) $(BOOT_DIR)/bin/javadoc + ln -sf $(KEYTOOL) $(BOOT_DIR)/bin/keytool + ln -sf $(JARSIGNER) $(BOOT_DIR)/bin/jarsigner mkdir -p $(BOOT_DIR)/jre/lib && \ ln -s $(SYSTEM_JDK_DIR)/jre/lib/rt.jar $(BOOT_DIR)/jre/lib && \ if [ -e $(SYSTEM_JDK_DIR)/jre/lib/jsse.jar ] ; then \ diff -r fc73a2a7f392 acinclude.m4 --- a/acinclude.m4 Fri Jun 24 11:50:41 2011 +0200 +++ b/acinclude.m4 Fri Jun 24 15:57:30 2011 +0200 @@ -617,6 +617,56 @@ AC_SUBST(JAVA) ]) +AC_DEFUN_ONCE([IT_FIND_KEYTOOL], +[ + AC_REQUIRE([IT_CHECK_FOR_JDK]) + AC_MSG_CHECKING([for keytool]) + AC_ARG_WITH([keytool], + [AS_HELP_STRING(--with-keytool, specify location keytool)], + [ + KEYTOOL="${withval}" + ], + [ + KEYTOOL=${SYSTEM_JDK_DIR}/bin/keytool + ]) + if ! test -f "${KEYTOOL}"; then + AC_PATH_PROG(KEYTOOL, "${KEYTOOL}") + fi + if test -z "${KEYTOOL}"; then + AC_PATH_PROG(KEYTOOL, "keytool") + fi + if test -z "${KEYTOOL}" && test "x$ENABLE_CHECK" = "xyes"; then + AC_MSG_ERROR("keytool requred in jdk") + fi + AC_MSG_RESULT(${KEYTOOL}) + AC_SUBST(KEYTOOL) +]) + +AC_DEFUN_ONCE([IT_FIND_JARSIGNER], +[ + AC_REQUIRE([IT_CHECK_FOR_JDK]) + AC_MSG_CHECKING([for jarsigner]) + AC_ARG_WITH([jarsigner], + [AS_HELP_STRING(--with-jarsigner, specify location jarsigner)], + [ + JARSIGNER="${withval}" + ], + [ + JARSIGNER=${SYSTEM_JDK_DIR}/bin/jarsigner + ]) + if ! test -f "${JARSIGNER}"; then + AC_PATH_PROG(JARSIGNER, "${JARSIGNER}") + fi + if test -z "${JARSIGNER}"; then + AC_PATH_PROG(JARSIGNER, "jarsigner") + fi + if test -z "${JARSIGNER}" && test "x$ENABLE_CHECK" = "xyes"; then + AC_MSG_ERROR("JARSIGNER requred in jdk") + fi + AC_MSG_RESULT(${JARSIGNER}) + AC_SUBST(JARSIGNER) +]) + AC_DEFUN([IT_FIND_JAVADOC], [ AC_REQUIRE([IT_CHECK_FOR_JDK]) diff -r fc73a2a7f392 configure.ac --- a/configure.ac Fri Jun 24 11:50:41 2011 +0200 +++ b/configure.ac Fri Jun 24 15:57:30 2011 +0200 @@ -27,12 +27,23 @@ AM_CONDITIONAL([ENABLE_DOCS], [test x$ENABLE_DOCS = xyes]) AC_MSG_RESULT(${ENABLE_DOCS}) +AC_MSG_CHECKING([whether to check]) +AC_ARG_ENABLE([check], + [AS_HELP_STRING([--disable-check], + [Disable checking for check specific tools ketool and jarsigner])], + [ENABLE_CHECK="${enableval}"], [ENABLE_CHECK='yes']) +AM_CONDITIONAL([ENABLE_CHECK], [test x$ENABLE_CHECK = xyes]) +AC_MSG_RESULT(${ENABLE_CHECK}) + + IT_CHECK_WITH_GCJ FIND_TOOL([ZIP], [zip]) FIND_JAVAC FIND_JAR FIND_ECJ_JAR IT_FIND_JAVADOC +IT_FIND_KEYTOOL +IT_FIND_JARSIGNER AC_CONFIG_FILES([javac], [chmod +x javac]) IT_SET_VERSION diff -r fc73a2a7f392 tests/jnlp_tests/README --- a/tests/jnlp_tests/README Fri Jun 24 11:50:41 2011 +0200 +++ b/tests/jnlp_tests/README Fri Jun 24 15:57:30 2011 +0200 @@ -1,1 +1,2 @@ Each file in directory simple must follows naming convention and is compiled/jared automatically into server's working directory and content of resources likewise. The name of jnlp is independent, and there can be even more jnlps for each future jar. Files in advanced directory have to care about themselves, but even those can have some parts inside simple directory, so some parts of them are processed automatically. There are three reproducers – simpletest1, simpletest2 and deadlocktest, which tests test’s suite itself and serve as examples of behaviour. +Directory signed is handling its content in similar way as simle's content is handled, but in addition final jars are signed with simple testkey. diff -r fc73a2a7f392 tests/jnlp_tests/signed/ReadPropertiesSigned/resources/ReadPropertiesSigned1.jnlp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/jnlp_tests/signed/ReadPropertiesSigned/resources/ReadPropertiesSigned1.jnlp Fri Jun 24 15:57:30 2011 +0200 @@ -0,0 +1,14 @@ + + + + read properties using System.getenv() + + + + + + user.name + + diff -r fc73a2a7f392 tests/jnlp_tests/signed/ReadPropertiesSigned/resources/ReadPropertiesSigned2.jnlp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/jnlp_tests/signed/ReadPropertiesSigned/resources/ReadPropertiesSigned2.jnlp Fri Jun 24 15:57:30 2011 +0200 @@ -0,0 +1,17 @@ + + + + read properties using System.getenv() + + + + + + user.name + + + + + diff -r fc73a2a7f392 tests/jnlp_tests/signed/ReadPropertiesSigned/srcs/ReadPropertiesSigned.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/jnlp_tests/signed/ReadPropertiesSigned/srcs/ReadPropertiesSigned.java Fri Jun 24 15:57:30 2011 +0200 @@ -0,0 +1,45 @@ +/* ReadPropertiesSigned.java +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. + */ +public class ReadPropertiesSigned { + +/** +*some system property is expected as arg[0], eg user.name or user.home +*/ + public static void main(String[] args) { + System.out.println(System.getProperty(args[0])); + } +} diff -r fc73a2a7f392 tests/jnlp_tests/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/jnlp_tests/signed/ReadPropertiesSigned/testcases/ReadPropertiesSignedTest.java Fri Jun 24 15:57:30 2011 +0200 @@ -0,0 +1,76 @@ +/* ReadPropertiesSignedTest.java +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. + */ + + +import net.sourceforge.jnlp.ServerAccess; +import org.junit.Assert; +import org.junit.Test; + +public class ReadPropertiesSignedTest { + + private static ServerAccess server = new ServerAccess(); + + + + @Test + public void ReadPropertiesLunch1() throws Exception { + //no request for permissions + System.out.println("connecting ReadPropertiesSigned1 request"); + ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/ReadPropertiesSigned1.jnlp"); + System.out.println(pr.stdout); + System.err.println(pr.stderr); + Assert.assertTrue(pr.stderr.contains("java.security.AccessControlException: access denied (java.util.PropertyPermission user.name read)")); + Assert.assertFalse(pr.stderr.contains("ClassNotFoundException")); + Assert.assertTrue(pr.stdout.length()<2); // /home/user or /root or eanything else :( + Assert.assertFalse(pr.wasTerminated); + Assert.assertEquals((Integer)0, pr.returnValue); + } + + @Test + public void ReadPropertiesLunch2() throws Exception { + //request for allpermissions + System.out.println("connecting ReadPropertiesSigned2 request"); + ServerAccess.ProcessResult pr=server.executeJavawsHeadless(null,"/ReadPropertiesSigned2.jnlp"); + System.out.println(pr.stdout); + System.err.println(pr.stderr); + Assert.assertFalse(pr.stderr.contains("java.security.AccessControlException: access denied (java.util.PropertyPermission user.name read)")); + Assert.assertFalse(pr.stderr.contains("ClassNotFoundException")); + Assert.assertTrue(pr.stdout.length()>=4); // /home/user or /root or eanything else :( + Assert.assertFalse(pr.wasTerminated); + Assert.assertEquals((Integer)0, pr.returnValue); + } + } diff -r fc73a2a7f392 tests/jnlp_tests/simple/ReadProperties/srcs/ReadProperties.java --- a/tests/jnlp_tests/simple/ReadProperties/srcs/ReadProperties.java Fri Jun 24 11:50:41 2011 +0200 +++ b/tests/jnlp_tests/simple/ReadProperties/srcs/ReadProperties.java Fri Jun 24 15:57:30 2011 +0200 @@ -40,6 +40,6 @@ *some system property is expected as arg[0], eg user.name or user.home */ public static void main(String[] args) { - System.getProperty(args[0]); + System.out.println(System.getProperty(args[0])); } }