1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.test.service;
17
18 import java.util.List;
19
20 import org.junit.Test;
21 import org.kuali.rice.kim.bo.role.dto.KimPermissionInfo;
22 import org.kuali.rice.kim.bo.role.dto.KimPermissionTemplateInfo;
23 import org.kuali.rice.kim.bo.role.dto.PermissionAssigneeInfo;
24 import org.kuali.rice.kim.bo.types.dto.AttributeSet;
25 import org.kuali.rice.kim.service.KIMServiceLocator;
26 import org.kuali.rice.kim.service.PermissionService;
27 import org.kuali.rice.kim.test.KIMTestCase;
28
29
30
31
32
33
34
35 public class PermissionServiceTest extends KIMTestCase {
36
37 private PermissionService permissionService;
38
39 public void setUp() throws Exception {
40 super.setUp();
41 setPermissionService(KIMServiceLocator.getPermissionService());
42 }
43
44 @Test
45 public void testHasPermission() {
46 assertTrue(getPermissionService().hasPermission("entity123pId", "KR-NS", "perm1", new AttributeSet()));
47 assertTrue(getPermissionService().hasPermission("entity123pId", "KR-NS", "perm2", new AttributeSet()));
48 assertFalse(getPermissionService().hasPermission("entity124pId", "KR-NS", "perm2", new AttributeSet()));
49 }
50
51 @Test
52 public void testIsAuthorized() {
53 assertTrue(getPermissionService().isAuthorized("entity123pId", "KR-NS", "perm1", new AttributeSet(), new AttributeSet()));
54 assertTrue(getPermissionService().isAuthorized("entity123pId", "KR-NS", "perm2", new AttributeSet(), new AttributeSet()));
55 assertFalse(getPermissionService().isAuthorized("entity124pId", "KR-NS", "perm2", new AttributeSet(), new AttributeSet()));
56 }
57
58 @Test
59 public void testHasPermissionByTemplateName() {
60 assertTrue(getPermissionService().hasPermissionByTemplateName("entity123pId", "KUALI", "Default", new AttributeSet()));
61
62
63 }
64
65 @Test
66 public void testIsAuthorizedByTemplateName() {
67
68 }
69
70 @Test
71 public void testGetPermissionAssignees() {
72
73 List<PermissionAssigneeInfo> assignees = getPermissionService().getPermissionAssignees("KUALI", "Log In", null, null);
74 assertNotNull(assignees);
75 assertEquals(1, assignees.size());
76 PermissionAssigneeInfo permInfo = assignees.get(0);
77 assertEquals("entity123pId", permInfo.getPrincipalId());
78 assignees = getPermissionService().getPermissionAssignees("KUALI", "Not A Valid Permission Name", null, null);
79
80 assertTrue(null == assignees || assignees.size() == 0);
81 }
82
83 @Test
84 public void testGetPermissionAssigneesForTemplateName() {
85
86
87
88
89
90
91
92
93
94 }
95
96 @Test
97 public void testIsPermissionDefined() {
98 }
99
100 @Test
101 public void testIsPermissionDefinedForTemplateName() {
102 }
103
104 @Test
105 public void testGetAuthorizedPermissions() {
106 }
107
108 @Test
109 public void testGetAuthorizedPermissionsByTemplateName() {
110 }
111
112 @Test
113 public void testGetPermission() {
114 KimPermissionInfo permInfo = getPermissionService().getPermission("p1");
115
116 assertNotNull(permInfo);
117 assertEquals("perm1", permInfo.getName());
118 assertEquals("KR-NS", permInfo.getNamespaceCode());
119 assertEquals(0, permInfo.getDetails().size());
120 assertTrue(permInfo.isActive());
121
122 KimPermissionTemplateInfo templateInfo = permInfo.getTemplate();
123 assertNotNull(templateInfo);
124 assertTrue(templateInfo.isActive());
125 assertEquals("1", templateInfo.getKimTypeId());
126 assertEquals("Default", templateInfo.getName());
127 assertEquals("KUALI", templateInfo.getNamespaceCode());
128
129 permInfo = getPermissionService().getPermission("p0");
130 assertNull(permInfo);
131 }
132
133 @Test
134 public void testGetPermissionsByTemplateName() {
135 }
136
137 @Test
138 public void testGetPermissionsByName() {
139 }
140
141 @Test
142 public void testLookupPermissions() {
143 }
144
145 @Test
146 public void testGetRoleIdsForPermission() {
147 }
148
149 @Test
150 public void testGetRoleIdsForPermissions() {
151 }
152
153 @Test
154 public void testGetPermissionDetailLabel() {
155 }
156
157 public PermissionService getPermissionService() {
158 return this.permissionService;
159 }
160
161 public void setPermissionService(PermissionService permissionService) {
162 this.permissionService = permissionService;
163 }
164
165 }