|
18 | 18 |
|
19 | 19 | import org.junit.jupiter.api.Test;
|
20 | 20 |
|
| 21 | +import org.springframework.security.core.Authentication; |
21 | 22 | import org.springframework.security.core.authority.AuthorityUtils;
|
22 | 23 |
|
23 | 24 | import static org.assertj.core.api.Assertions.assertThat;
|
@@ -63,4 +64,56 @@ public void testGettersSetters() {
|
63 | 64 | assertThat(trustResolver.getRememberMeClass()).isEqualTo(TestingAuthenticationToken.class);
|
64 | 65 | }
|
65 | 66 |
|
| 67 | + @Test |
| 68 | + void isAuthenticatedWhenAuthenticationNullThenFalse() { |
| 69 | + AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); |
| 70 | + Authentication authentication = null; |
| 71 | + assertThat(trustResolver.isAuthenticated(authentication)).isFalse(); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + void isAuthenticatedWhenAuthenticationNotAuthenticatedThenFalse() { |
| 76 | + AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); |
| 77 | + TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password"); |
| 78 | + assertThat(trustResolver.isAuthenticated(authentication)).isFalse(); |
| 79 | + } |
| 80 | + |
| 81 | + @Test |
| 82 | + void isAuthenticatedWhenAnonymousThenFalse() { |
| 83 | + AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); |
| 84 | + AnonymousAuthenticationToken authentication = new AnonymousAuthenticationToken("key", "principal", |
| 85 | + AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")); |
| 86 | + assertThat(trustResolver.isAuthenticated(authentication)).isFalse(); |
| 87 | + } |
| 88 | + |
| 89 | + @Test |
| 90 | + void isFullyAuthenticatedWhenAuthenticationNullThenFalse() { |
| 91 | + AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); |
| 92 | + Authentication authentication = null; |
| 93 | + assertThat(trustResolver.isFullyAuthenticated(authentication)).isFalse(); |
| 94 | + } |
| 95 | + |
| 96 | + @Test |
| 97 | + void isFullyAuthenticatedWhenAuthenticationNotAuthenticatedThenFalse() { |
| 98 | + AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); |
| 99 | + TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password"); |
| 100 | + assertThat(trustResolver.isFullyAuthenticated(authentication)).isFalse(); |
| 101 | + } |
| 102 | + |
| 103 | + @Test |
| 104 | + void isFullyAuthenticatedWhenAnonymousThenFalse() { |
| 105 | + AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); |
| 106 | + AnonymousAuthenticationToken authentication = new AnonymousAuthenticationToken("key", "principal", |
| 107 | + AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")); |
| 108 | + assertThat(trustResolver.isFullyAuthenticated(authentication)).isFalse(); |
| 109 | + } |
| 110 | + |
| 111 | + @Test |
| 112 | + void isFullyAuthenticatedWhenRememberMeThenFalse() { |
| 113 | + AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); |
| 114 | + RememberMeAuthenticationToken authentication = new RememberMeAuthenticationToken("key", "user", |
| 115 | + AuthorityUtils.createAuthorityList("ROLE_USER")); |
| 116 | + assertThat(trustResolver.isFullyAuthenticated(authentication)).isFalse(); |
| 117 | + } |
| 118 | + |
66 | 119 | }
|
0 commit comments