5656import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
5757import static org .mockito .ArgumentMatchers .any ;
5858import static org .mockito .ArgumentMatchers .anyString ;
59+ import static org .mockito .ArgumentMatchers .eq ;
5960import static org .mockito .BDDMockito .given ;
6061import static org .mockito .Mockito .mock ;
6162import static org .mockito .Mockito .verify ;
@@ -147,7 +148,7 @@ public void authenticateWhenAuthorizationNotFoundThenThrowOAuth2AuthenticationEx
147148 }
148149
149150 @ Test
150- public void authenticateWhenUserCodeIsInvalidedThenThrowOAuth2AuthenticationException () {
151+ public void authenticateWhenUserCodeIsInvalidatedThenThrowOAuth2AuthenticationException () {
151152 RegisteredClient registeredClient = TestRegisteredClients .registeredClient ().build ();
152153 // @formatter:off
153154 OAuth2Authorization authorization = TestOAuth2Authorizations
@@ -157,7 +158,9 @@ public void authenticateWhenUserCodeIsInvalidedThenThrowOAuth2AuthenticationExce
157158 .attribute (OAuth2ParameterNames .SCOPE , registeredClient .getScopes ())
158159 .build ();
159160 // @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 );
161164 Authentication authentication = createAuthentication ();
162165 // @formatter:off
163166 assertThatExceptionOfType (OAuth2AuthenticationException .class )
@@ -174,7 +177,7 @@ public void authenticateWhenUserCodeIsInvalidedThenThrowOAuth2AuthenticationExce
174177 }
175178
176179 @ Test
177- public void authenticateWhenUserCodeIsExpiredButNotInvalidatedThenInvalidateUserCodeAndThrowOAuth2AuthenticationException () {
180+ public void authenticateWhenUserCodeIsExpiredAndNotInvalidatedThenThrowOAuth2AuthenticationException () {
178181 RegisteredClient registeredClient = TestRegisteredClients .registeredClient ().build ();
179182 // @formatter:off
180183 OAuth2Authorization authorization = TestOAuth2Authorizations
@@ -185,7 +188,9 @@ public void authenticateWhenUserCodeIsExpiredButNotInvalidatedThenInvalidateUser
185188 .attribute (OAuth2ParameterNames .SCOPE , registeredClient .getScopes ())
186189 .build ();
187190 // @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 );
189194 Authentication authentication = createAuthentication ();
190195 // @formatter:off
191196 assertThatExceptionOfType (OAuth2AuthenticationException .class )
@@ -203,9 +208,7 @@ public void authenticateWhenUserCodeIsExpiredButNotInvalidatedThenInvalidateUser
203208 verifyNoInteractions (this .registeredClientRepository , this .authorizationConsentService );
204209
205210 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 );
209212 }
210213
211214 @ Test
0 commit comments