1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package waffle.spring;
25
26 import org.junit.jupiter.api.Assertions;
27 import org.junit.jupiter.api.BeforeEach;
28 import org.junit.jupiter.api.Test;
29 import org.springframework.security.core.authority.SimpleGrantedAuthority;
30
31 import waffle.mock.MockWindowsAccount;
32 import waffle.windows.auth.WindowsAccount;
33
34
35
36
37 class FqnGrantedAuthorityFactoryTest {
38
39
40 private WindowsAccount group;
41
42
43
44
45 @BeforeEach
46 void setUp() {
47 this.group = new WindowsAccount(new MockWindowsAccount("group"));
48 }
49
50
51
52
53 @Test
54 void testPrefixAndUppercase() {
55 final FqnGrantedAuthorityFactory factory = new FqnGrantedAuthorityFactory("prefix_", true);
56 Assertions.assertEquals(new SimpleGrantedAuthority("PREFIX_GROUP"), factory.createGrantedAuthority(this.group));
57 }
58
59
60
61
62 @Test
63 void testPrefixAndLowercase() {
64 final FqnGrantedAuthorityFactory factory = new FqnGrantedAuthorityFactory("prefix_", false);
65 Assertions.assertEquals(new SimpleGrantedAuthority("prefix_group"), factory.createGrantedAuthority(this.group));
66 }
67
68
69
70
71 @Test
72 void testNoPrefixAndUppercase() {
73 final FqnGrantedAuthorityFactory factory = new FqnGrantedAuthorityFactory(null, true);
74 Assertions.assertEquals(new SimpleGrantedAuthority("GROUP"), factory.createGrantedAuthority(this.group));
75 }
76
77
78
79
80 @Test
81 void testNoPrefixAndLowercase() {
82 final FqnGrantedAuthorityFactory factory = new FqnGrantedAuthorityFactory(null, false);
83 Assertions.assertEquals(new SimpleGrantedAuthority("group"), factory.createGrantedAuthority(this.group));
84 }
85
86 }