1 13 package info.magnolia.cms.security; 14 15 import junit.framework.TestCase; 16 17 18 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 |