Debian Codegraph @

tests/reproducers/signed/SandboxSignedAllPerm/testcases/SandboxSignedAllPermTest.java

raw symbols SCIP
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 /* AppletTest.java
22 Copyright (C) 2011 Red Hat, Inc.
23
24 This file is part of IcedTea.
25
26 IcedTea is free software; you can redistribute it and/or
27 modify it under the terms of the GNU General Public License as published by
28 the Free Software Foundation, version 2.
29
30 IcedTea is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 General Public License for more details.
34
35 You should have received a copy of the GNU General Public License
36 along with IcedTea; see the file COPYING. If not, write to
37 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
38 02110-1301 USA.
39
40 Linking this library statically or dynamically with other modules is
41 making a combined work based on this library. Thus, the terms and
42 conditions of the GNU General Public License cover the whole
43 combination.
44
45 As a special exception, the copyright holders of this library give you
46 permission to link this library with independent modules to produce an
47 executable, regardless of the license terms of these independent
48 modules, and to copy and distribute the resulting executable under
49 terms of your choice, provided that you also meet, for each linked
50 independent module, the terms and conditions of the license of that
51 module. An independent module is a module which is not derived from
52 or based on this library. If you modify this library, you may extend
53 this exception to your version of the library, but you are not
54 obligated to do so. If you do not wish to do so, delete this
55 exception statement from your version.
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 //no security dialog
75 //crash (jnlp dont have all-permnissions)
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 //no security dialog
93 //pass
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 //no security dialog
103 //crash (jnlp dont have all-permnissions)
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())); //applets have exception flused only in verbose mode? strange...
109 }
110 @Test
111 //no security dialog
112 //pass
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 //no security dialog
123 //pass
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 }