|
16 | 16 |
|
17 | 17 | package org.springframework.security.oauth2.client;
|
18 | 18 |
|
| 19 | +import java.time.Duration; |
| 20 | +import java.time.Instant; |
| 21 | +import java.util.Arrays; |
| 22 | +import java.util.HashSet; |
| 23 | + |
19 | 24 | import io.r2dbc.h2.H2ConnectionFactory;
|
20 | 25 | import io.r2dbc.spi.ConnectionFactory;
|
21 | 26 | import io.r2dbc.spi.Result;
|
|
38 | 43 | import org.springframework.security.oauth2.client.registration.TestClientRegistrations;
|
39 | 44 | import org.springframework.security.oauth2.core.OAuth2AccessToken;
|
40 | 45 | import org.springframework.security.oauth2.core.OAuth2RefreshToken;
|
41 |
| -import org.springframework.security.oauth2.core.TestOAuth2AccessTokens; |
42 |
| -import org.springframework.security.oauth2.core.TestOAuth2RefreshTokens; |
43 | 46 |
|
44 | 47 | import static org.assertj.core.api.Assertions.assertThat;
|
45 | 48 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
@@ -364,16 +367,19 @@ private static OAuth2AuthorizedClient createAuthorizedClient(Authentication prin
|
364 | 367 |
|
365 | 368 | private static OAuth2AuthorizedClient createAuthorizedClient(Authentication principal,
|
366 | 369 | ClientRegistration clientRegistration, boolean requiredAttributesOnly) {
|
| 370 | + Instant issuedAt = Instant.ofEpochSecond(1234567890, 123456000); |
367 | 371 | OAuth2AccessToken accessToken;
|
368 | 372 | if (!requiredAttributesOnly) {
|
369 |
| - accessToken = TestOAuth2AccessTokens.scopes("read", "write"); |
| 373 | + accessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, "scopes", issuedAt, |
| 374 | + issuedAt.plus(Duration.ofDays(1)), new HashSet<>(Arrays.asList("read", "write"))); |
370 | 375 | }
|
371 | 376 | else {
|
372 |
| - accessToken = TestOAuth2AccessTokens.noScopes(); |
| 377 | + accessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, "no-scopes", issuedAt, |
| 378 | + issuedAt.plus(Duration.ofDays(1))); |
373 | 379 | }
|
374 | 380 | OAuth2RefreshToken refreshToken = null;
|
375 | 381 | if (!requiredAttributesOnly) {
|
376 |
| - refreshToken = TestOAuth2RefreshTokens.refreshToken(); |
| 382 | + refreshToken = new OAuth2RefreshToken("refresh-token", issuedAt); |
377 | 383 | }
|
378 | 384 | return new OAuth2AuthorizedClient(clientRegistration, principal.getName(), accessToken, refreshToken);
|
379 | 385 | }
|
|
0 commit comments