1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.kuali.mobility.library.entity;
16
17
18 import org.junit.Test;
19 import static org.junit.Assert.*;
20 import org.kuali.mobility.security.group.api.Group;
21 import org.kuali.mobility.security.group.entity.GroupImpl;
22 import org.kuali.mobility.security.user.api.User;
23 import org.kuali.mobility.security.user.entity.UserImpl;
24
25
26
27
28
29
30
31
32 public class LibraryPermissionsTest {
33
34
35
36
37
38 @Test
39 public void testValidUserPermissions(){
40 User user = new UserImpl();
41 Group group = new GroupImpl();
42 group.setName(LibraryPermissions.ADMIN);
43 user.addGroup(group);
44 assertTrue("User with admin permission is expected to be allowed", LibraryPermissions.ADMIN_EXPRESSION.evaluate(user));
45 }
46
47
48
49
50
51 @Test
52 public void testInvalidUserPermissions(){
53 User user = new UserImpl();
54 Group group = new GroupImpl();
55 group.setName("nothing_special");
56 user.addGroup(group);
57 assertFalse("User without admin permission not is expected to be allowed", LibraryPermissions.ADMIN_EXPRESSION.evaluate(user));
58 }
59 }