Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6663eea

Browse files
committed
Polish OTT Tests
Improve tests so that they do not rely on OneTimeTokenAuthenticationToken as the concrete type. Issue gh-17799
1 parent 89b2f9c commit 6663eea

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

‎core/src/test/java/org/springframework/security/authentication/ott/OneTimeTokenAuthenticationProviderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.mockito.junit.jupiter.MockitoExtension;
2727

2828
import org.springframework.security.authentication.BadCredentialsException;
29+
import org.springframework.security.core.Authentication;
2930
import org.springframework.security.core.userdetails.User;
3031
import org.springframework.security.core.userdetails.UserDetailsService;
3132
import org.springframework.security.core.userdetails.UsernameNotFoundException;
@@ -69,8 +70,7 @@ void authenticateWhenAuthenticationTokenIsPresentThenAuthenticates() {
6970
.willReturn(new User(USERNAME, PASSWORD, List.of()));
7071
OneTimeTokenAuthenticationToken token = new OneTimeTokenAuthenticationToken(TOKEN);
7172

72-
OneTimeTokenAuthenticationToken authentication = (OneTimeTokenAuthenticationToken) this.provider
73-
.authenticate(token);
73+
Authentication authentication = this.provider.authenticate(token);
7474

7575
User user = (User) authentication.getPrincipal();
7676
assertThat(authentication.isAuthenticated()).isTrue();

‎core/src/test/java/org/springframework/security/authentication/ott/reactive/OneTimeTokenReactiveAuthenticationManagerTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,12 @@ void authenticateWhenOneTimeTokenAuthenticationTokenIsPresentThenSuccess() {
8888
this.authenticationManager = new OneTimeTokenReactiveAuthenticationManager(oneTimeTokenService,
8989
userDetailsService);
9090

91-
Authentication auth = this.authenticationManager
91+
Authentication token = this.authenticationManager
9292
.authenticate(OneTimeTokenAuthenticationToken.unauthenticated(TOKEN))
9393
.block();
9494

95-
OneTimeTokenAuthenticationToken token = (OneTimeTokenAuthenticationToken) auth;
9695
UserDetails user = (UserDetails) token.getPrincipal();
97-
Collection<GrantedAuthority> authorities = token.getAuthorities();
96+
Collection<? extendsGrantedAuthority> authorities = token.getAuthorities();
9897

9998
assertThat(user).isNotNull();
10099
assertThat(user.getUsername()).isEqualTo(USERNAME);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /