Skip to content

Commit a0a9718

Browse files
committed
Use Instant with micro-second precision
Closes gh-9449
1 parent 95da121 commit a0a9718

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/R2dbcReactiveOAuth2AuthorizedClientServiceTests.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
package org.springframework.security.oauth2.client;
1818

19+
import java.time.Duration;
20+
import java.time.Instant;
21+
import java.util.Arrays;
22+
import java.util.HashSet;
23+
1924
import io.r2dbc.h2.H2ConnectionFactory;
2025
import io.r2dbc.spi.ConnectionFactory;
2126
import io.r2dbc.spi.Result;
@@ -38,8 +43,6 @@
3843
import org.springframework.security.oauth2.client.registration.TestClientRegistrations;
3944
import org.springframework.security.oauth2.core.OAuth2AccessToken;
4045
import org.springframework.security.oauth2.core.OAuth2RefreshToken;
41-
import org.springframework.security.oauth2.core.TestOAuth2AccessTokens;
42-
import org.springframework.security.oauth2.core.TestOAuth2RefreshTokens;
4346

4447
import static org.assertj.core.api.Assertions.assertThat;
4548
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -364,16 +367,19 @@ private static OAuth2AuthorizedClient createAuthorizedClient(Authentication prin
364367

365368
private static OAuth2AuthorizedClient createAuthorizedClient(Authentication principal,
366369
ClientRegistration clientRegistration, boolean requiredAttributesOnly) {
370+
Instant issuedAt = Instant.ofEpochSecond(1234567890, 123456000);
367371
OAuth2AccessToken accessToken;
368372
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")));
370375
}
371376
else {
372-
accessToken = TestOAuth2AccessTokens.noScopes();
377+
accessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, "no-scopes", issuedAt,
378+
issuedAt.plus(Duration.ofDays(1)));
373379
}
374380
OAuth2RefreshToken refreshToken = null;
375381
if (!requiredAttributesOnly) {
376-
refreshToken = TestOAuth2RefreshTokens.refreshToken();
382+
refreshToken = new OAuth2RefreshToken("refresh-token", issuedAt);
377383
}
378384
return new OAuth2AuthorizedClient(clientRegistration, principal.getName(), accessToken, refreshToken);
379385
}

0 commit comments

Comments
 (0)