Polish gh-10131
This commit is contained in:
parent
044157061f
commit
acca3dba69
|
@ -359,8 +359,8 @@ public class WebClientReactiveAuthorizationCodeTokenResponseClientTests {
|
|||
public void convertWhenHeadersConverterAddedThenCalled() throws Exception {
|
||||
OAuth2AuthorizationCodeGrantRequest request = authorizationCodeGrantRequest();
|
||||
Converter<OAuth2AuthorizationCodeGrantRequest, HttpHeaders> addedHeadersConverter = mock(Converter.class);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
headers.put("CUSTOM_AUTHORIZATION", Collections.singletonList("Basic CUSTOM"));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.put("custom-header-name", Collections.singletonList("custom-header-value"));
|
||||
given(addedHeadersConverter.convert(request)).willReturn(headers);
|
||||
this.tokenResponseClient.addHeadersConverter(addedHeadersConverter);
|
||||
// @formatter:off
|
||||
|
@ -377,15 +377,16 @@ public class WebClientReactiveAuthorizationCodeTokenResponseClientTests {
|
|||
RecordedRequest actualRequest = this.server.takeRequest();
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION))
|
||||
.isEqualTo("Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=");
|
||||
assertThat(actualRequest.getHeader("CUSTOM_AUTHORIZATION")).isEqualTo("Basic CUSTOM");
|
||||
assertThat(actualRequest.getHeader("custom-header-name")).isEqualTo("custom-header-value");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertWhenHeadersConverterSetThenCalled() throws Exception {
|
||||
OAuth2AuthorizationCodeGrantRequest request = authorizationCodeGrantRequest();
|
||||
ClientRegistration clientRegistration = request.getClientRegistration();
|
||||
Converter<OAuth2AuthorizationCodeGrantRequest, HttpHeaders> headersConverter = mock(Converter.class);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
headers.put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Basic CUSTOM"));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setBasicAuth(clientRegistration.getClientId(), clientRegistration.getClientSecret());
|
||||
given(headersConverter.convert(request)).willReturn(headers);
|
||||
this.tokenResponseClient.setHeadersConverter(headersConverter);
|
||||
// @formatter:off
|
||||
|
@ -400,8 +401,8 @@ public class WebClientReactiveAuthorizationCodeTokenResponseClientTests {
|
|||
this.tokenResponseClient.getTokenResponse(request).block();
|
||||
verify(headersConverter).convert(request);
|
||||
RecordedRequest actualRequest = this.server.takeRequest();
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION)).isEqualTo("Basic CUSTOM");
|
||||
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION))
|
||||
.isEqualTo("Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -231,8 +231,8 @@ public class WebClientReactiveClientCredentialsTokenResponseClientTests {
|
|||
OAuth2ClientCredentialsGrantRequest request = new OAuth2ClientCredentialsGrantRequest(
|
||||
this.clientRegistration.build());
|
||||
Converter<OAuth2ClientCredentialsGrantRequest, HttpHeaders> addedHeadersConverter = mock(Converter.class);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
headers.put("CUSTOM_AUTHORIZATION", Collections.singletonList("Basic CUSTOM"));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.put("custom-header-name", Collections.singletonList("custom-header-value"));
|
||||
given(addedHeadersConverter.convert(request)).willReturn(headers);
|
||||
this.client.addHeadersConverter(addedHeadersConverter);
|
||||
// @formatter:off
|
||||
|
@ -248,16 +248,17 @@ public class WebClientReactiveClientCredentialsTokenResponseClientTests {
|
|||
RecordedRequest actualRequest = this.server.takeRequest();
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION))
|
||||
.isEqualTo("Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=");
|
||||
assertThat(actualRequest.getHeader("CUSTOM_AUTHORIZATION")).isEqualTo("Basic CUSTOM");
|
||||
assertThat(actualRequest.getHeader("custom-header-name")).isEqualTo("custom-header-value");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertWhenHeadersConverterSetThenCalled() throws Exception {
|
||||
OAuth2ClientCredentialsGrantRequest request = new OAuth2ClientCredentialsGrantRequest(
|
||||
this.clientRegistration.build());
|
||||
ClientRegistration clientRegistration = request.getClientRegistration();
|
||||
Converter<OAuth2ClientCredentialsGrantRequest, HttpHeaders> headersConverter = mock(Converter.class);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
headers.put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Basic CUSTOM"));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setBasicAuth(clientRegistration.getClientId(), clientRegistration.getClientSecret());
|
||||
given(headersConverter.convert(request)).willReturn(headers);
|
||||
this.client.setHeadersConverter(headersConverter);
|
||||
// @formatter:off
|
||||
|
@ -271,7 +272,8 @@ public class WebClientReactiveClientCredentialsTokenResponseClientTests {
|
|||
this.client.getTokenResponse(request).block();
|
||||
verify(headersConverter).convert(request);
|
||||
RecordedRequest actualRequest = this.server.takeRequest();
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION)).isEqualTo("Basic CUSTOM");
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION))
|
||||
.isEqualTo("Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -235,8 +235,8 @@ public class WebClientReactivePasswordTokenResponseClientTests {
|
|||
OAuth2PasswordGrantRequest request = new OAuth2PasswordGrantRequest(this.clientRegistrationBuilder.build(),
|
||||
this.username, this.password);
|
||||
Converter<OAuth2PasswordGrantRequest, HttpHeaders> addedHeadersConverter = mock(Converter.class);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
headers.put("CUSTOM_AUTHORIZATION", Collections.singletonList("Basic CUSTOM"));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.put("custom-header-name", Collections.singletonList("custom-header-value"));
|
||||
given(addedHeadersConverter.convert(request)).willReturn(headers);
|
||||
this.tokenResponseClient.addHeadersConverter(addedHeadersConverter);
|
||||
// @formatter:off
|
||||
|
@ -253,16 +253,17 @@ public class WebClientReactivePasswordTokenResponseClientTests {
|
|||
RecordedRequest actualRequest = this.server.takeRequest();
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION))
|
||||
.isEqualTo("Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=");
|
||||
assertThat(actualRequest.getHeader("CUSTOM_AUTHORIZATION")).isEqualTo("Basic CUSTOM");
|
||||
assertThat(actualRequest.getHeader("custom-header-name")).isEqualTo("custom-header-value");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertWhenHeadersConverterSetThenCalled() throws Exception {
|
||||
OAuth2PasswordGrantRequest request = new OAuth2PasswordGrantRequest(this.clientRegistrationBuilder.build(),
|
||||
this.username, this.password);
|
||||
ClientRegistration clientRegistration = request.getClientRegistration();
|
||||
Converter<OAuth2PasswordGrantRequest, HttpHeaders> headersConverter = mock(Converter.class);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
headers.put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Basic CUSTOM"));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setBasicAuth(clientRegistration.getClientId(), clientRegistration.getClientSecret());
|
||||
given(headersConverter.convert(request)).willReturn(headers);
|
||||
this.tokenResponseClient.setHeadersConverter(headersConverter);
|
||||
// @formatter:off
|
||||
|
@ -277,7 +278,8 @@ public class WebClientReactivePasswordTokenResponseClientTests {
|
|||
this.tokenResponseClient.getTokenResponse(request).block();
|
||||
verify(headersConverter).convert(request);
|
||||
RecordedRequest actualRequest = this.server.takeRequest();
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION)).isEqualTo("Basic CUSTOM");
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION))
|
||||
.isEqualTo("Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -238,8 +238,8 @@ public class WebClientReactiveRefreshTokenTokenResponseClientTests {
|
|||
OAuth2RefreshTokenGrantRequest request = new OAuth2RefreshTokenGrantRequest(
|
||||
this.clientRegistrationBuilder.build(), this.accessToken, this.refreshToken);
|
||||
Converter<OAuth2RefreshTokenGrantRequest, HttpHeaders> addedHeadersConverter = mock(Converter.class);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
headers.put("CUSTOM_AUTHORIZATION", Collections.singletonList("Basic CUSTOM"));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.put("custom-header-name", Collections.singletonList("custom-header-value"));
|
||||
given(addedHeadersConverter.convert(request)).willReturn(headers);
|
||||
this.tokenResponseClient.addHeadersConverter(addedHeadersConverter);
|
||||
// @formatter:off
|
||||
|
@ -256,16 +256,17 @@ public class WebClientReactiveRefreshTokenTokenResponseClientTests {
|
|||
RecordedRequest actualRequest = this.server.takeRequest();
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION))
|
||||
.isEqualTo("Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=");
|
||||
assertThat(actualRequest.getHeader("CUSTOM_AUTHORIZATION")).isEqualTo("Basic CUSTOM");
|
||||
assertThat(actualRequest.getHeader("custom-header-name")).isEqualTo("custom-header-value");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertWhenHeadersConverterSetThenCalled() throws Exception {
|
||||
OAuth2RefreshTokenGrantRequest request = new OAuth2RefreshTokenGrantRequest(
|
||||
this.clientRegistrationBuilder.build(), this.accessToken, this.refreshToken);
|
||||
ClientRegistration clientRegistration = request.getClientRegistration();
|
||||
Converter<OAuth2RefreshTokenGrantRequest, HttpHeaders> headersConverter1 = mock(Converter.class);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
headers.put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Basic CUSTOM"));
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setBasicAuth(clientRegistration.getClientId(), clientRegistration.getClientSecret());
|
||||
given(headersConverter1.convert(request)).willReturn(headers);
|
||||
this.tokenResponseClient.setHeadersConverter(headersConverter1);
|
||||
// @formatter:off
|
||||
|
@ -280,7 +281,8 @@ public class WebClientReactiveRefreshTokenTokenResponseClientTests {
|
|||
this.tokenResponseClient.getTokenResponse(request).block();
|
||||
verify(headersConverter1).convert(request);
|
||||
RecordedRequest actualRequest = this.server.takeRequest();
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION)).isEqualTo("Basic CUSTOM");
|
||||
assertThat(actualRequest.getHeader(HttpHeaders.AUTHORIZATION))
|
||||
.isEqualTo("Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue