KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > security > SecureURITest


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.security;
14
15 import junit.framework.TestCase;
16
17
18 /**
19  * @author Fabrizio Giustina
20  * @version $Revision: 7626 $ ($Author: gjoseph $)
21  */

22 public class SecureURITest extends TestCase {
23
24     public void testUnsecureNoWildcards() {
25         SecureURI.init();
26         SecureURI.addUnsecure("/home/x/test.htm");
27         assertTrue(SecureURI.isUnsecure("/home/x/test.htm"));
28         assertFalse(SecureURI.isUnsecure("/home/x/test.html"));
29         assertFalse(SecureURI.isUnsecure("/home/x/test/do.htm"));
30     }
31
32     public void testUnsecureWildcards() {
33         SecureURI.init();
34         SecureURI.addUnsecure("/home/x/test*");
35         assertFalse(SecureURI.isUnsecure("/home/x/tes"));
36         assertTrue(SecureURI.isUnsecure("/home/x/test.htm"));
37         assertTrue(SecureURI.isUnsecure("/home/x/test.html"));
38         assertTrue(SecureURI.isUnsecure("/home/x/test/me.html"));
39         assertTrue(SecureURI.isUnsecure("/home/x/test/me/if.html"));
40     }
41
42     public void testUnsecureWildcard() {
43         SecureURI.init();
44         SecureURI.addUnsecure("/home/x/test?");
45         assertFalse(SecureURI.isUnsecure("/home/x/tes"));
46         assertTrue(SecureURI.isUnsecure("/home/x/test"));
47         assertTrue(SecureURI.isUnsecure("/home/x/test."));
48         assertTrue(SecureURI.isUnsecure("/home/x/testd"));
49         assertFalse(SecureURI.isUnsecure("/home/x/test.html"));
50         assertFalse(SecureURI.isUnsecure("/home/x/test/me.html"));
51         assertFalse(SecureURI.isUnsecure("/home/x/test/me/if.html"));
52     }
53 }
54
Popular Tags