| 1 |
/* |
| 2 |
Copyright (C) 2015 Red Hat, Inc. |
| 3 |
|
| 4 |
This file is part of IcedTea. |
| 5 |
|
| 6 |
IcedTea is free software; you can redistribute it and/or |
| 7 |
modify it under the terms of the GNU General Public License as published by |
| 8 |
the Free Software Foundation, version 2. |
| 9 |
|
| 10 |
IcedTea is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with IcedTea; see the file COPYING. If not, write to |
| 17 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 18 |
02110-1301 USA. |
| 19 |
|
| 20 |
Linking this library statically or dynamically with other modules is |
| 21 |
making a combined work based on this library. Thus, the terms and |
| 22 |
conditions of the GNU General Public License cover the whole |
| 23 |
combination. |
| 24 |
|
| 25 |
As a special exception, the copyright holders of this library give you |
| 26 |
permission to link this library with independent modules to produce an |
| 27 |
executable, regardless of the license terms of these independent |
| 28 |
modules, and to copy and distribute the resulting executable under |
| 29 |
terms of your choice, provided that you also meet, for each linked |
| 30 |
independent module, the terms and conditions of the license of that |
| 31 |
module. An independent module is a module which is not derived from |
| 32 |
or based on this library. If you modify this library, you may extend |
| 33 |
this exception to your version of the library, but you are not |
| 34 |
obligated to do so. If you do not wish to do so, delete this |
| 35 |
exception statement from your version. |
| 36 |
*/ |
| 37 |
|
| 38 |
import java.io.IOException; |
| 39 |
import java.util.Arrays; |
| 40 |
import net.sourceforge.jnlp.OptionsDefinitions; |
| 41 |
import net.sourceforge.jnlp.ProcessResult; |
| 42 |
import net.sourceforge.jnlp.ServerAccess; |
| 43 |
import net.sourceforge.jnlp.annotations.TestInBrowsers; |
| 44 |
import net.sourceforge.jnlp.browsertesting.BrowserTest; |
| 45 |
import static net.sourceforge.jnlp.browsertesting.BrowserTest.server; |
| 46 |
import net.sourceforge.jnlp.browsertesting.Browsers; |
| 47 |
import net.sourceforge.jnlp.closinglisteners.AutoErrorClosingListener; |
| 48 |
import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; |
| 49 |
import net.sourceforge.jnlp.closinglisteners.StringBasedClosingListener; |
| 50 |
import net.sourceforge.jnlp.config.DeploymentConfiguration; |
| 51 |
import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; |
| 52 |
import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; |
| 53 |
import org.junit.AfterClass; |
| 54 |
import org.junit.Assert; |
| 55 |
import org.junit.BeforeClass; |
| 56 |
import org.junit.Test; |
| 57 |
|
| 58 |
public class EntryPointSignedSingleBothOkTest2 extends BrowserTest { |
| 59 |
|
| 60 |
|
| 61 |
public static final String MAGICAL_OK1_CLOSING_STRING = "*** APPLET1 FINISHED ***"; |
| 62 |
public static final String MAGICAL_OK2_CLOSING_STRING = "*** APPLET2 FINISHED ***"; |
| 63 |
|
| 64 |
private static class AutoOk1ClosingListener extends StringBasedClosingListener { |
| 65 |
|
| 66 |
public AutoOk1ClosingListener() { |
| 67 |
super(MAGICAL_OK1_CLOSING_STRING); |
| 68 |
} |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
private static class AutoOk2ClosingListener extends StringBasedClosingListener { |
| 73 |
|
| 74 |
public AutoOk2ClosingListener() { |
| 75 |
super(MAGICAL_OK2_CLOSING_STRING); |
| 76 |
} |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
private static final DeploymentPropertiesModifier dpm = new DeploymentPropertiesModifier(); |
| 81 |
private static final StringBasedClosingListener aok = new AutoOkClosingListener(); |
| 82 |
|
| 83 |
private static final StringBasedClosingListener aok1 = new AutoOk1ClosingListener(); |
| 84 |
private static final StringBasedClosingListener aok2 = new AutoOk2ClosingListener(); |
| 85 |
|
| 86 |
private static final StringBasedClosingListener aer = new AutoErrorClosingListener(); |
| 87 |
private static final String confirmation1 = "*** applet1 running ***"; |
| 88 |
private static final String confirmation2 = "*** applet2 running ***"; |
| 89 |
|
| 90 |
|
| 91 |
@BeforeClass |
| 92 |
public static void setDeploymentManifestPermissionReadingOnly() throws IOException { |
| 93 |
dpm.setProperties(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.ENTRYPOINT.toString()); |
| 94 |
} |
| 95 |
|
| 96 |
@AfterClass |
| 97 |
public static void restoreDeploymentProeprtiees() throws IOException { |
| 98 |
dpm.restoreProperties(); |
| 99 |
} |
| 100 |
|
| 101 |
@Test |
| 102 |
public void javawsAllPermNoSecurity2() throws Exception { |
| 103 |
ProcessResult p = server.executeJavawsHeadless("EntryPointSignedSingleBothOk2.jnlp"); |
| 104 |
Assert.assertTrue(p.stdout.contains(confirmation2)); |
| 105 |
Assert.assertFalse(p.stdout.contains(aok2.getCondition())); |
| 106 |
Assert.assertTrue(p.stderr.contains(aer.getCondition())); |
| 107 |
assertNope(p); |
| 108 |
} |
| 109 |
|
| 110 |
@Test |
| 111 |
public void javawsAllPermAllSecurity2() throws Exception { |
| 112 |
ProcessResult p = server.executeJavawsHeadless("EntryPointSignedSingleBothOk_security2.jnlp"); |
| 113 |
Assert.assertTrue(p.stdout.contains(confirmation2)); |
| 114 |
Assert.assertTrue(p.stdout.contains(aok2.getCondition())); |
| 115 |
Assert.assertFalse(p.stderr.contains(aer.getCondition())); |
| 116 |
} |
| 117 |
|
| 118 |
@Test |
| 119 |
public void javawsAppletAllPermNoSecurity2() throws Exception { |
| 120 |
ProcessResult p = server.executeJavaws(Arrays.asList(new String[]{"-headless", "-verbose"}), "EntryPointSignedSingleBothOk_applet2.jnlp", new AutoOkClosingListener(), new AutoErrorClosingListener()); |
| 121 |
Assert.assertTrue(p.stdout.contains(confirmation2)); |
| 122 |
Assert.assertFalse(p.stdout.contains(aok2.getCondition())); |
| 123 |
Assert.assertTrue(p.stderr.contains(aer.getCondition())); |
| 124 |
assertNope(p); |
| 125 |
} |
| 126 |
|
| 127 |
@Test |
| 128 |
public void javawsAppletAllPermAllSecurity2() throws Exception { |
| 129 |
ProcessResult p = server.executeJavawsHeadless("EntryPointSignedSingleBothOk_applet_security2.jnlp", new AutoOkClosingListener(), new AutoErrorClosingListener()); |
| 130 |
Assert.assertTrue(p.stdout.contains(confirmation2)); |
| 131 |
Assert.assertTrue(p.stdout.contains(aok2.getCondition())); |
| 132 |
Assert.assertFalse(p.stderr.contains(aer.getCondition())); |
| 133 |
assertNope(p); |
| 134 |
} |
| 135 |
|
| 136 |
@Test |
| 137 |
@TestInBrowsers(testIn = Browsers.one) |
| 138 |
public void appletAllPermAllSecurity2() throws Exception { |
| 139 |
server.getBrowserLocation(); |
| 140 |
ProcessResult p = server.executeBrowser("EntryPointSignedSingleBothOk2.html", ServerAccess.AutoClose.CLOSE_ON_BOTH); |
| 141 |
Assert.assertTrue(p.stdout.contains(confirmation2)); |
| 142 |
Assert.assertTrue(p.stdout.contains(aok2.getCondition())); |
| 143 |
Assert.assertFalse(p.stderr.contains(aer.getCondition())); |
| 144 |
assertNope(p); |
| 145 |
} |
| 146 |
|
| 147 |
@Test |
| 148 |
public void javawsHtml2() throws Exception { |
| 149 |
ProcessResult p = server.executeJavaws(Arrays.asList(new String[]{OptionsDefinitions.OPTIONS.HTML.option}), "EntryPointSignedSingleBothOk2.html", new AutoOkClosingListener(), new AutoErrorClosingListener()); |
| 150 |
Assert.assertTrue(p.stdout.contains(confirmation2)); |
| 151 |
Assert.assertTrue(p.stdout.contains(aok2.getCondition())); |
| 152 |
Assert.assertFalse(p.stderr.contains(aer.getCondition())); |
| 153 |
assertNope(p); |
| 154 |
} |
| 155 |
|
| 156 |
public void assertNope(ProcessResult p){ |
| 157 |
Assert.assertFalse(p.stdout.contains(confirmation1)); |
| 158 |
Assert.assertFalse(p.stdout.contains(aok1.getCondition())); |
| 159 |
} |
| 160 |
|
| 161 |
} |