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 org.junit.Ignore;
19 import org.junit.Test;
20 import org.kuali.rice.kim.api.common.assignee.Assignee;
21 import org.kuali.rice.kim.api.permission.PermissionService;
22 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
23 import org.kuali.rice.kim.impl.common.template.TemplateBo;
24 import org.kuali.rice.kim.impl.permission.PermissionBo;
25 import org.kuali.rice.kim.test.KIMTestCase;
26 import org.kuali.rice.test.BaselineTestCase;
27
28 import java.util.Collections;
29 import java.util.HashMap;
30 import java.util.List;
31
32 import static org.junit.Assert.*;
33
34
35
36
37
38
39
40 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
41 public class PermissionServiceTest extends KIMTestCase {
42
43 private PermissionService permissionService;
44
45 @Override
46 public void setUp() throws Exception {
47 super.setUp();
48 setPermissionService(KimApiServiceLocator.getPermissionService());
49 }
50
51 @Test
52 public void testHasPermission() {
53 assertTrue(getPermissionService().hasPermission("entity123pId", "KR-NS", "perm1"));
54 assertTrue(getPermissionService().hasPermission("entity123pId", "KR-NS", "perm2"));
55 assertFalse(getPermissionService().hasPermission("entity124pId", "KR-NS", "perm2"));
56 }
57
58 @Test
59 public void testIsAuthorized() {
60 assertTrue(getPermissionService().isAuthorized("entity123pId", "KR-NS", "perm1", new HashMap<String, String>()));
61 assertTrue(getPermissionService().isAuthorized("entity123pId", "KR-NS", "perm2", new HashMap<String, String>()));
62 assertFalse(getPermissionService().isAuthorized("entity124pId", "KR-NS", "perm2", new HashMap<String, String>()));
63 }
64
65 @Test
66 public void testHasPermissionByTemplateName() {
67 assertTrue(getPermissionService().hasPermissionByTemplate("entity123pId", "KUALI", "Default",
68 new HashMap<String, String>()));
69
70
71 }
72
73 @Test
74 @Ignore
75 public void testIsAuthorizedByTemplateName() {
76
77 }
78
79 @Test
80 public void testGetPermissionAssignees() {
81
82 List<Assignee> assignees = getPermissionService().getPermissionAssignees("KUALI", "Log In Kuali Portal", Collections.<String, String>emptyMap());
83 assertNotNull(assignees);
84 assertEquals(1, assignees.size());
85 Assignee permInfo = assignees.get(0);
86 assertEquals("entity123pId", permInfo.getPrincipalId());
87 assignees = getPermissionService().getPermissionAssignees("KUALI", "Not A Valid Permission Name", Collections.<String, String>emptyMap());
88
89 assertTrue(null == assignees || assignees.size() == 0);
90 }
91
92 @Test
93 @Ignore
94 public void testGetPermissionAssigneesForTemplateName() {
95
96
97
98
99
100
101
102
103
104 }
105
106 @Test
107 @Ignore
108 public void testIsPermissionDefined() {
109 }
110
111 @Test
112 @Ignore
113 public void testIsPermissionDefinedForTemplateName() {
114 }
115
116 @Test
117 @Ignore
118 public void testGetAuthorizedPermissions() {
119 }
120
121 @Test
122 @Ignore
123 public void testGetAuthorizedPermissionsByTemplateName() {
124 }
125
126 @Test
127 public void testGetPermission() {
128 PermissionBo permissionBo = PermissionBo.from(getPermissionService().getPermission("p1"));
129
130 assertNotNull(permissionBo);
131 assertEquals("perm1", permissionBo.getName());
132 assertEquals("KR-NS", permissionBo.getNamespaceCode());
133 assertEquals(0, permissionBo.getDetails().size());
134 assertTrue(permissionBo.isActive());
135
136 TemplateBo templateBo = permissionBo.getTemplate();
137 assertNotNull(templateBo);
138 assertTrue(templateBo.isActive());
139 assertEquals("1", templateBo.getKimTypeId());
140 assertEquals("Default", templateBo.getName());
141 assertEquals("KUALI", templateBo.getNamespaceCode());
142
143 permissionBo = PermissionBo.from(getPermissionService().getPermission("p0"));
144 assertNull(permissionBo);
145 }
146
147 @Test
148 @Ignore
149 public void testGetPermissionsByTemplateName() {
150 }
151
152 @Test
153 @Ignore
154 public void testGetPermissionsByName() {
155 }
156
157 @Test
158 @Ignore
159 public void testLookupPermissions() {
160 }
161
162 @Test
163 @Ignore
164 public void testGetRoleIdsForPermission() {
165 }
166
167 @Test
168 @Ignore
169 public void testGetRoleIdsForPermissions() {
170 }
171
172 @Test
173 @Ignore
174 public void testGetPermissionDetailLabel() {
175 }
176
177 public PermissionService getPermissionService() {
178 return this.permissionService;
179 }
180
181 public void setPermissionService(PermissionService permissionService) {
182 this.permissionService = permissionService;
183 }
184
185 }