KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > test > core > security > AuthorizationManagerTestCase


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.test.core.security;
10
11 import java.util.HashSet JavaDoc;
12 import java.util.Set JavaDoc;
13
14 import junit.framework.TestCase;
15
16 import org.jboss.portal.core.security.AuthorizationRealm;
17
18 /**
19  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
20  * @version $Revision: 1.3 $
21  */

22 public class AuthorizationManagerTestCase extends TestCase
23 {
24    public AuthorizationManagerTestCase(String JavaDoc key)
25    {
26       super(key);
27    }
28
29    public void testImplies()
30    {
31       // PortalPermission a = new PortalPermission(".*", "admin");
32
// PortalPermission b = new PortalPermission(new String[]{"test"}, Level.ACCESS_ADMIN);
33
// assertTrue(a.implies(b));
34
}
35
36    public void testSuccess()
37    {
38       Set JavaDoc set = new HashSet JavaDoc();
39       set.add("foo");
40       AuthorizationRealm realm = new AccessControllerAuthorizationRealm();
41       // assertTrue(realm.isAuthorized(set, new String[]{}, Level.ACCESS_READ));
42
// assertTrue(realm.isAuthorized(set, new String[]{"a"}, Level.ACCESS_READ));
43
// assertTrue(realm.isAuthorized(set, new String[]{"a","b"}, Level.ACCESS_READ));
44
// assertTrue(realm.isAuthorized(set, new String[]{"a","b","c"}, Level.ACCESS_READ));
45
}
46
47    public void testFailureWithNoMatchingTest()
48    {
49       Set JavaDoc set = new HashSet JavaDoc();
50       set.add("foo");
51       AuthorizationRealm realm = new AccessControllerAuthorizationRealm();
52       // assertFalse(realm.isAuthorized(set, new String[]{"a","b","c","d"}, Level.ACCESS_READ));
53
}
54
55    public void testFailureWithNotImpliedLevel()
56    {
57       Set JavaDoc set = new HashSet JavaDoc();
58       set.add("foo");
59       AuthorizationRealm realm = new AccessControllerAuthorizationRealm();
60       // assertFalse(realm.isAuthorized(set, new String[]{"a","b","c"}, Level.ACCESS_ADMIN));
61
}
62
63    public void testFailureWithNoMatchingPrincipal()
64    {
65       Set JavaDoc set = new HashSet JavaDoc();
66       set.add("bar");
67       AuthorizationRealm realm = new AccessControllerAuthorizationRealm();
68       // assertFalse(realm.isAuthorized(set, new String[]{"a","b","c"}, Level.ACCESS_READ));
69
}
70
71    public void testWithOneMatchingPrincipalAmongMultiplePrincipals()
72    {
73       Set JavaDoc set = new HashSet JavaDoc();
74       set.add("foo");
75       set.add("bar");
76       AuthorizationRealm realm = new AccessControllerAuthorizationRealm();
77       // assertTrue(realm.isAuthorized(set, new String[]{"a","b","c"}, Level.ACCESS_READ));
78
}
79 }
80
Popular Tags