|
@@ -155,14 +155,13 @@ public class ServerOAuth2AuthorizedClientExchangeFilterFunctionTests {
|
|
when(this.exchange.getResponse().body(any())).thenReturn(Mono.just(response));
|
|
when(this.exchange.getResponse().body(any())).thenReturn(Mono.just(response));
|
|
Instant issuedAt = Instant.now().minus(Duration.ofDays(1));
|
|
Instant issuedAt = Instant.now().minus(Duration.ofDays(1));
|
|
Instant accessTokenExpiresAt = issuedAt.plus(Duration.ofHours(1));
|
|
Instant accessTokenExpiresAt = issuedAt.plus(Duration.ofHours(1));
|
|
- Instant refreshTokenExpiresAt = Instant.now().plus(Duration.ofHours(1));
|
|
|
|
|
|
|
|
this.accessToken = new OAuth2AccessToken(this.accessToken.getTokenType(),
|
|
this.accessToken = new OAuth2AccessToken(this.accessToken.getTokenType(),
|
|
this.accessToken.getTokenValue(),
|
|
this.accessToken.getTokenValue(),
|
|
issuedAt,
|
|
issuedAt,
|
|
accessTokenExpiresAt);
|
|
accessTokenExpiresAt);
|
|
|
|
|
|
- OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", issuedAt, refreshTokenExpiresAt);
|
|
|
|
|
|
+ OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", issuedAt);
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
"principalName", this.accessToken, refreshToken);
|
|
"principalName", this.accessToken, refreshToken);
|
|
ClientRequest request = ClientRequest.create(GET, URI.create("https://example.com"))
|
|
ClientRequest request = ClientRequest.create(GET, URI.create("https://example.com"))
|
|
@@ -203,14 +202,13 @@ public class ServerOAuth2AuthorizedClientExchangeFilterFunctionTests {
|
|
when(this.exchange.getResponse().body(any())).thenReturn(Mono.just(response));
|
|
when(this.exchange.getResponse().body(any())).thenReturn(Mono.just(response));
|
|
Instant issuedAt = Instant.now().minus(Duration.ofDays(1));
|
|
Instant issuedAt = Instant.now().minus(Duration.ofDays(1));
|
|
Instant accessTokenExpiresAt = issuedAt.plus(Duration.ofHours(1));
|
|
Instant accessTokenExpiresAt = issuedAt.plus(Duration.ofHours(1));
|
|
- Instant refreshTokenExpiresAt = Instant.now().plus(Duration.ofHours(1));
|
|
|
|
|
|
|
|
this.accessToken = new OAuth2AccessToken(this.accessToken.getTokenType(),
|
|
this.accessToken = new OAuth2AccessToken(this.accessToken.getTokenType(),
|
|
this.accessToken.getTokenValue(),
|
|
this.accessToken.getTokenValue(),
|
|
issuedAt,
|
|
issuedAt,
|
|
accessTokenExpiresAt);
|
|
accessTokenExpiresAt);
|
|
|
|
|
|
- OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", issuedAt, refreshTokenExpiresAt);
|
|
|
|
|
|
+ OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", issuedAt);
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
"principalName", this.accessToken, refreshToken);
|
|
"principalName", this.accessToken, refreshToken);
|
|
ClientRequest request = ClientRequest.create(GET, URI.create("https://example.com"))
|
|
ClientRequest request = ClientRequest.create(GET, URI.create("https://example.com"))
|
|
@@ -260,7 +258,7 @@ public class ServerOAuth2AuthorizedClientExchangeFilterFunctionTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void filterWhenNotExpiredThenShouldRefreshFalse() {
|
|
public void filterWhenNotExpiredThenShouldRefreshFalse() {
|
|
- OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", this.accessToken.getIssuedAt(), this.accessToken.getExpiresAt());
|
|
|
|
|
|
+ OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", this.accessToken.getIssuedAt());
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
"principalName", this.accessToken, refreshToken);
|
|
"principalName", this.accessToken, refreshToken);
|
|
ClientRequest request = ClientRequest.create(GET, URI.create("https://example.com"))
|
|
ClientRequest request = ClientRequest.create(GET, URI.create("https://example.com"))
|
|
@@ -281,7 +279,7 @@ public class ServerOAuth2AuthorizedClientExchangeFilterFunctionTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void filterWhenClientRegistrationIdThenAuthorizedClientResolved() {
|
|
public void filterWhenClientRegistrationIdThenAuthorizedClientResolved() {
|
|
- OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", this.accessToken.getIssuedAt(), this.accessToken.getExpiresAt());
|
|
|
|
|
|
+ OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", this.accessToken.getIssuedAt());
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
"principalName", this.accessToken, refreshToken);
|
|
"principalName", this.accessToken, refreshToken);
|
|
when(this.authorizedClientRepository.loadAuthorizedClient(any(), any(), any())).thenReturn(Mono.just(authorizedClient));
|
|
when(this.authorizedClientRepository.loadAuthorizedClient(any(), any(), any())).thenReturn(Mono.just(authorizedClient));
|
|
@@ -306,7 +304,7 @@ public class ServerOAuth2AuthorizedClientExchangeFilterFunctionTests {
|
|
public void filterWhenClientRegistrationIdFromAuthenticationThenAuthorizedClientResolved() {
|
|
public void filterWhenClientRegistrationIdFromAuthenticationThenAuthorizedClientResolved() {
|
|
this.function.setDefaultOAuth2AuthorizedClient(true);
|
|
this.function.setDefaultOAuth2AuthorizedClient(true);
|
|
|
|
|
|
- OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", this.accessToken.getIssuedAt(), this.accessToken.getExpiresAt());
|
|
|
|
|
|
+ OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", this.accessToken.getIssuedAt());
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
"principalName", this.accessToken, refreshToken);
|
|
"principalName", this.accessToken, refreshToken);
|
|
when(this.authorizedClientRepository.loadAuthorizedClient(any(), any(), any())).thenReturn(Mono.just(authorizedClient));
|
|
when(this.authorizedClientRepository.loadAuthorizedClient(any(), any(), any())).thenReturn(Mono.just(authorizedClient));
|
|
@@ -354,7 +352,7 @@ public class ServerOAuth2AuthorizedClientExchangeFilterFunctionTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void filterWhenClientRegistrationIdAndServerWebExchangeFromContextThenServerWebExchangeFromContext() {
|
|
public void filterWhenClientRegistrationIdAndServerWebExchangeFromContextThenServerWebExchangeFromContext() {
|
|
- OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", this.accessToken.getIssuedAt(), this.accessToken.getExpiresAt());
|
|
|
|
|
|
+ OAuth2RefreshToken refreshToken = new OAuth2RefreshToken("refresh-token", this.accessToken.getIssuedAt());
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(this.registration,
|
|
"principalName", this.accessToken, refreshToken);
|
|
"principalName", this.accessToken, refreshToken);
|
|
when(this.authorizedClientRepository.loadAuthorizedClient(any(), any(), any())).thenReturn(Mono.just(authorizedClient));
|
|
when(this.authorizedClientRepository.loadAuthorizedClient(any(), any(), any())).thenReturn(Mono.just(authorizedClient));
|