01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.bridge;
20:
21: import org.apache.batik.test.*;
22:
23: /**
24: * Checks that JAR Scripts which should be loaded are indeed
25: * loaded.
26: *
27: * @author <a href="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
28: * @version $Id: JarLoadTest.java 475477 2006-11-15 22:44:28Z cam $
29: */
30: public class JarLoadTest extends DefaultTestSuite {
31: public JarLoadTest() {
32: String scripts = "application/java-archive";
33: // Note: base64 encoding of jar content is not supported.
34: String[] scriptSource = { "jarCheckLoadAny",
35: "jarCheckLoadSameAsDocument" };
36: boolean[] secure = { true, false };
37: String[] scriptOrigin = { "any", "document", "embeded" };
38:
39: //
40: // <!> Need to make restricted {true/false}
41: //
42:
43: //
44: // An jar script can be loaded if JAR is listed
45: // as an allowed script _and_ the loaded script
46: // has an origin allowed by the scriptOrigin setting.
47: // All other security settings should not have an
48: // influence on whether or not the script can be loaded.
49: //
50: for (int i = 0; i < scriptSource.length; i++) {
51: for (int j = 0; j <= i; j++) {
52: for (int k = 0; k < secure.length; k++) {
53: ScriptSelfTest t = buildTest(scripts,
54: scriptSource[i], scriptOrigin[j], secure[k]);
55: addTest(t);
56: }
57: }
58: }
59: }
60:
61: ScriptSelfTest buildTest(String scripts, String id, String origin,
62: boolean secure) {
63: ScriptSelfTest t = new ScriptSelfTest();
64: String desc = "(scripts=" + scripts + ")(scriptOrigin="
65: + origin + ")(secure=" + secure + ")";
66:
67: t.setId(id + desc);
68: t.setScriptOrigin(origin);
69: t.setSecure(secure);
70: t.setScripts(scripts);
71:
72: return t;
73: }
74:
75: }
|