Skip to content

Commit 225095e

Browse files
committed
wipwip
1 parent 649921d commit 225095e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: web/src/test/java/org/springframework/security/web/authentication/ott/OneTimeTokenAuthenticationFilterTests.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
import static org.assertj.core.api.Assertions.assertThat;
3939
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
4040
import static org.mockito.ArgumentMatchers.any;
41+
import static org.mockito.BDDMockito.given;
4142
import static org.mockito.Mockito.mock;
4243
import static org.mockito.Mockito.verify;
4344
import static org.mockito.Mockito.verifyNoInteractions;
44-
import static org.mockito.Mockito.when;
4545
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
4646
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
4747

@@ -66,7 +66,7 @@ class OneTimeTokenAuthenticationFilterTests {
6666

6767
@BeforeEach
6868
void setUp() {
69-
this.filter.setAuthenticationManager(authenticationManager);
69+
this.filter.setAuthenticationManager(this.authenticationManager);
7070
}
7171

7272
@Test
@@ -103,7 +103,7 @@ void doFilterWhenMissingTokenThenUnauthorized() throws ServletException, IOExcep
103103

104104
@Test
105105
void doFilterWhenInvalidTokenThenUnauthorized() throws ServletException, IOException {
106-
when(this.authenticationManager.authenticate(any())).thenThrow(new BadCredentialsException("invalid token"));
106+
given(this.authenticationManager.authenticate(any())).willThrow(new BadCredentialsException("invalid token"));
107107
this.filter.doFilter(
108108
post("/login/ott").param("token", "some-token-value").buildRequest(new MockServletContext()),
109109
this.response, this.chain);
@@ -113,7 +113,8 @@ void doFilterWhenInvalidTokenThenUnauthorized() throws ServletException, IOExcep
113113

114114
@Test
115115
void doFilterWhenValidThenRedirectsToSavedRequest() throws ServletException, IOException {
116-
when(this.authenticationManager.authenticate(any())).thenReturn(OneTimeTokenAuthenticationToken.authenticated("username", AuthorityUtils.NO_AUTHORITIES));
116+
given(this.authenticationManager.authenticate(any()))
117+
.willReturn(OneTimeTokenAuthenticationToken.authenticated("username", AuthorityUtils.NO_AUTHORITIES));
117118
this.filter.doFilter(
118119
post("/login/ott").param("token", "some-token-value").buildRequest(new MockServletContext()),
119120
this.response, this.chain);

0 commit comments

Comments
 (0)