1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.shiro.mgt;
20
21 import org.apache.shiro.subject.PrincipalCollection;
22 import org.apache.shiro.subject.Subject;
23 import org.apache.shiro.subject.SubjectContext;
24 import org.apache.shiro.subject.support.DefaultSubjectContext;
25 import org.junit.Test;
26
27 import static org.junit.Assert.assertNull;
28
29
30
31
32 public class AbstractRememberMeManagerTest {
33
34
35
36
37
38
39
40 @Test
41 public void testGetRememberedPrincipalsWithEmptySerializedBytes() {
42 AbstractRememberMeManager rmm = new DummyRememberMeManager();
43
44
45 PrincipalCollection principals = rmm.getRememberedPrincipals(new DefaultSubjectContext());
46 assertNull(principals);
47
48
49 rmm = new DummyRememberMeManager() {
50 @Override
51 protected byte[] getRememberedSerializedIdentity(SubjectContext subjectContext) {
52 return null;
53 }
54 };
55 principals = rmm.getRememberedPrincipals(new DefaultSubjectContext());
56 assertNull(principals);
57 }
58
59 private static class DummyRememberMeManager extends AbstractRememberMeManager {
60 public void forgetIdentity(SubjectContext subjectContext) {
61
62 }
63
64 @Override
65 protected void forgetIdentity(Subject subject) {
66 }
67
68 @Override
69 protected void rememberSerializedIdentity(Subject subject, byte[] serialized) {
70 }
71
72 @Override
73 protected byte[] getRememberedSerializedIdentity(SubjectContext subjectContext) {
74 return new byte[0];
75 }
76 }
77 }