56
56
import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
57
57
import static org .mockito .ArgumentMatchers .any ;
58
58
import static org .mockito .ArgumentMatchers .anyString ;
59
+ import static org .mockito .ArgumentMatchers .eq ;
59
60
import static org .mockito .BDDMockito .given ;
60
61
import static org .mockito .Mockito .mock ;
61
62
import static org .mockito .Mockito .verify ;
@@ -147,7 +148,7 @@ public void authenticateWhenAuthorizationNotFoundThenThrowOAuth2AuthenticationEx
147
148
}
148
149
149
150
@ Test
150
- public void authenticateWhenUserCodeIsInvalidedThenThrowOAuth2AuthenticationException () {
151
+ public void authenticateWhenUserCodeIsInvalidatedThenThrowOAuth2AuthenticationException () {
151
152
RegisteredClient registeredClient = TestRegisteredClients .registeredClient ().build ();
152
153
// @formatter:off
153
154
OAuth2Authorization authorization = TestOAuth2Authorizations
@@ -157,7 +158,9 @@ public void authenticateWhenUserCodeIsInvalidedThenThrowOAuth2AuthenticationExce
157
158
.attribute (OAuth2ParameterNames .SCOPE , registeredClient .getScopes ())
158
159
.build ();
159
160
// @formatter:on
160
- given (this .authorizationService .findByToken (anyString (), any (OAuth2TokenType .class ))).willReturn (authorization );
161
+ given (this .authorizationService .findByToken (eq (USER_CODE ),
162
+ eq (OAuth2DeviceVerificationAuthenticationProvider .USER_CODE_TOKEN_TYPE )))
163
+ .willReturn (authorization );
161
164
Authentication authentication = createAuthentication ();
162
165
// @formatter:off
163
166
assertThatExceptionOfType (OAuth2AuthenticationException .class )
@@ -174,7 +177,7 @@ public void authenticateWhenUserCodeIsInvalidedThenThrowOAuth2AuthenticationExce
174
177
}
175
178
176
179
@ Test
177
- public void authenticateWhenUserCodeIsExpiredButNotInvalidatedThenInvalidateUserCodeAndThrowOAuth2AuthenticationException () {
180
+ public void authenticateWhenUserCodeIsExpiredAndNotInvalidatedThenThrowOAuth2AuthenticationException () {
178
181
RegisteredClient registeredClient = TestRegisteredClients .registeredClient ().build ();
179
182
// @formatter:off
180
183
OAuth2Authorization authorization = TestOAuth2Authorizations
@@ -185,7 +188,9 @@ public void authenticateWhenUserCodeIsExpiredButNotInvalidatedThenInvalidateUser
185
188
.attribute (OAuth2ParameterNames .SCOPE , registeredClient .getScopes ())
186
189
.build ();
187
190
// @formatter:on
188
- given (this .authorizationService .findByToken (anyString (), any (OAuth2TokenType .class ))).willReturn (authorization );
191
+ given (this .authorizationService .findByToken (eq (USER_CODE ),
192
+ eq (OAuth2DeviceVerificationAuthenticationProvider .USER_CODE_TOKEN_TYPE )))
193
+ .willReturn (authorization );
189
194
Authentication authentication = createAuthentication ();
190
195
// @formatter:off
191
196
assertThatExceptionOfType (OAuth2AuthenticationException .class )
@@ -203,9 +208,7 @@ public void authenticateWhenUserCodeIsExpiredButNotInvalidatedThenInvalidateUser
203
208
verifyNoInteractions (this .registeredClientRepository , this .authorizationConsentService );
204
209
205
210
OAuth2Authorization updatedAuthorization = authorizationCaptor .getValue ();
206
- assertThat (updatedAuthorization .getToken (OAuth2UserCode .class ))
207
- .extracting (isInvalidated ())
208
- .isEqualTo (true );
211
+ assertThat (updatedAuthorization .getToken (OAuth2UserCode .class )).extracting (isInvalidated ()).isEqualTo (true );
209
212
}
210
213
211
214
@ Test
0 commit comments