| 1 |
|
| 2 |
import java.io.IOException; |
| 3 |
import java.util.Arrays; |
| 4 |
import net.sourceforge.jnlp.OptionsDefinitions; |
| 5 |
import net.sourceforge.jnlp.ProcessResult; |
| 6 |
import net.sourceforge.jnlp.ServerAccess; |
| 7 |
import net.sourceforge.jnlp.annotations.TestInBrowsers; |
| 8 |
import net.sourceforge.jnlp.browsertesting.BrowserTest; |
| 9 |
import net.sourceforge.jnlp.browsertesting.Browsers; |
| 10 |
import net.sourceforge.jnlp.closinglisteners.AutoErrorClosingListener; |
| 11 |
import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; |
| 12 |
import net.sourceforge.jnlp.closinglisteners.StringBasedClosingListener; |
| 13 |
import net.sourceforge.jnlp.config.DeploymentConfiguration; |
| 14 |
import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; |
| 15 |
import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; |
| 16 |
import org.junit.AfterClass; |
| 17 |
import org.junit.Assert; |
| 18 |
import org.junit.BeforeClass; |
| 19 |
import org.junit.Test; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
public class SandboxSignedAllPermTest extends BrowserTest { |
| 58 |
|
| 59 |
private static final DeploymentPropertiesModifier dpm = new DeploymentPropertiesModifier(); |
| 60 |
private static final StringBasedClosingListener aok = new AutoOkClosingListener(); |
| 61 |
private static final StringBasedClosingListener aer = new AutoErrorClosingListener(); |
| 62 |
private static final String confirmation = "*** applet running ***"; |
| 63 |
@BeforeClass |
| 64 |
public static void setDeploymentManifestPermissionReadingOnly() throws IOException{ |
| 65 |
dpm.setProperties(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.PERMISSIONS.toString()); |
| 66 |
} |
| 67 |
|
| 68 |
@AfterClass |
| 69 |
public static void restoreDeploymentProeprtiees() throws IOException{ |
| 70 |
dpm.restoreProperties(); |
| 71 |
} |
| 72 |
|
| 73 |
@Test |
| 74 |
|
| 75 |
|
| 76 |
public void javawsAllPermNoSecurity() throws Exception{ |
| 77 |
ProcessResult p = server.executeJavawsHeadless("SandboxSignedAllPerm.jnlp"); |
| 78 |
Assert.assertTrue(p.stdout.contains(confirmation)); |
| 79 |
Assert.assertFalse(p.stdout.contains(aok.getCondition())); |
| 80 |
Assert.assertTrue(p.stderr.contains(aer.getCondition())); |
| 81 |
} |
| 82 |
|
| 83 |
@Test |
| 84 |
public void javawsHtml() throws Exception{ |
| 85 |
ProcessResult p = server.executeJavaws(Arrays.asList(new String[] {OptionsDefinitions.OPTIONS.HTML.option}), "SandboxSignedAllPerm.html", new AutoOkClosingListener(), new AutoErrorClosingListener()); |
| 86 |
Assert.assertTrue(p.stdout.contains(confirmation)); |
| 87 |
Assert.assertTrue(p.stdout.contains(aok.getCondition())); |
| 88 |
Assert.assertFalse(p.stderr.contains(aer.getCondition())); |
| 89 |
} |
| 90 |
|
| 91 |
@Test |
| 92 |
|
| 93 |
|
| 94 |
public void javawsAllPermAllSecurity() throws Exception{ |
| 95 |
ProcessResult p = server.executeJavawsHeadless("SandboxSignedAllPerm_security.jnlp"); |
| 96 |
Assert.assertTrue(p.stdout.contains(confirmation)); |
| 97 |
Assert.assertTrue(p.stdout.contains(aok.getCondition())); |
| 98 |
Assert.assertFalse(p.stderr.contains(aer.getCondition())); |
| 99 |
} |
| 100 |
|
| 101 |
@Test |
| 102 |
|
| 103 |
|
| 104 |
public void javawsAppletAllPermNoSecurity() throws Exception{ |
| 105 |
ProcessResult p = server.executeJavaws(Arrays.asList(new String[]{"-headless", "-verbose"}), "SandboxSignedAllPerm_applet.jnlp", new AutoOkClosingListener(), new AutoErrorClosingListener()); |
| 106 |
Assert.assertTrue(p.stdout.contains(confirmation)); |
| 107 |
Assert.assertFalse(p.stdout.contains(aok.getCondition())); |
| 108 |
Assert.assertTrue(p.stderr.contains(aer.getCondition())); |
| 109 |
} |
| 110 |
@Test |
| 111 |
|
| 112 |
|
| 113 |
public void javawsAppletAllPermAllSecurity() throws Exception{ |
| 114 |
ProcessResult p = server.executeJavawsHeadless("SandboxSignedAllPerm_applet_security.jnlp", new AutoOkClosingListener(), new AutoErrorClosingListener()); |
| 115 |
Assert.assertTrue(p.stdout.contains(confirmation)); |
| 116 |
Assert.assertTrue(p.stdout.contains(aok.getCondition())); |
| 117 |
Assert.assertFalse(p.stderr.contains(aer.getCondition())); |
| 118 |
} |
| 119 |
|
| 120 |
@Test |
| 121 |
@TestInBrowsers(testIn = Browsers.one) |
| 122 |
|
| 123 |
|
| 124 |
public void appletAllPermAllSecurity() throws Exception{ |
| 125 |
server.getBrowserLocation(); |
| 126 |
ProcessResult p = server.executeBrowser("SandboxSignedAllPerm.html", ServerAccess.AutoClose.CLOSE_ON_BOTH); |
| 127 |
Assert.assertTrue(p.stdout.contains(confirmation)); |
| 128 |
Assert.assertTrue(p.stdout.contains(aok.getCondition())); |
| 129 |
Assert.assertFalse(p.stderr.contains(aer.getCondition())); |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
} |