Polish
This commit is contained in:
parent
551c08ebfe
commit
a6cefc5ba0
|
@ -39,4 +39,5 @@ public class WebEndpointPropertiesTests {
|
||||||
properties.setBasePath("/");
|
properties.setBasePath("/");
|
||||||
assertThat(properties.getBasePath()).isEqualTo("");
|
assertThat(properties.getBasePath()).isEqualTo("");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,7 @@ class OAuth2WebSecurityConfiguration {
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class)
|
@ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class)
|
||||||
static class OAuth2WebSecurityConfigurerAdapter
|
static class OAuth2WebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
|
||||||
extends WebSecurityConfigurerAdapter {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
|
|
@ -78,7 +78,8 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
|
||||||
org.springframework.security.oauth2.core.ClientAuthenticationMethod.POST);
|
org.springframework.security.oauth2.core.ClientAuthenticationMethod.POST);
|
||||||
assertThat(adapted.getAuthorizationGrantType()).isEqualTo(
|
assertThat(adapted.getAuthorizationGrantType()).isEqualTo(
|
||||||
org.springframework.security.oauth2.core.AuthorizationGrantType.AUTHORIZATION_CODE);
|
org.springframework.security.oauth2.core.AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
assertThat(adapted.getRedirectUriTemplate()).isEqualTo("http://example.com/redirect");
|
assertThat(adapted.getRedirectUriTemplate())
|
||||||
|
.isEqualTo("http://example.com/redirect");
|
||||||
assertThat(adapted.getScopes()).containsExactly("scope");
|
assertThat(adapted.getScopes()).containsExactly("scope");
|
||||||
assertThat(adapted.getClientName()).isEqualTo("clientName");
|
assertThat(adapted.getClientName()).isEqualTo("clientName");
|
||||||
}
|
}
|
||||||
|
@ -111,8 +112,8 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
|
||||||
org.springframework.security.oauth2.core.ClientAuthenticationMethod.BASIC);
|
org.springframework.security.oauth2.core.ClientAuthenticationMethod.BASIC);
|
||||||
assertThat(adapted.getAuthorizationGrantType()).isEqualTo(
|
assertThat(adapted.getAuthorizationGrantType()).isEqualTo(
|
||||||
org.springframework.security.oauth2.core.AuthorizationGrantType.AUTHORIZATION_CODE);
|
org.springframework.security.oauth2.core.AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
assertThat(adapted.getRedirectUriTemplate()).isEqualTo(
|
assertThat(adapted.getRedirectUriTemplate())
|
||||||
"{baseUrl}/login/oauth2/code/{registrationId}");
|
.isEqualTo("{baseUrl}/login/oauth2/code/{registrationId}");
|
||||||
assertThat(adapted.getScopes()).containsExactly("openid", "profile", "email",
|
assertThat(adapted.getScopes()).containsExactly("openid", "profile", "email",
|
||||||
"address", "phone");
|
"address", "phone");
|
||||||
assertThat(adapted.getClientName()).isEqualTo("Google");
|
assertThat(adapted.getClientName()).isEqualTo("Google");
|
||||||
|
@ -151,7 +152,8 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
|
||||||
org.springframework.security.oauth2.core.ClientAuthenticationMethod.POST);
|
org.springframework.security.oauth2.core.ClientAuthenticationMethod.POST);
|
||||||
assertThat(adapted.getAuthorizationGrantType()).isEqualTo(
|
assertThat(adapted.getAuthorizationGrantType()).isEqualTo(
|
||||||
org.springframework.security.oauth2.core.AuthorizationGrantType.AUTHORIZATION_CODE);
|
org.springframework.security.oauth2.core.AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
assertThat(adapted.getRedirectUriTemplate()).isEqualTo("http://example.com/redirect");
|
assertThat(adapted.getRedirectUriTemplate())
|
||||||
|
.isEqualTo("http://example.com/redirect");
|
||||||
assertThat(adapted.getScopes()).containsExactly("scope");
|
assertThat(adapted.getScopes()).containsExactly("scope");
|
||||||
assertThat(adapted.getClientName()).isEqualTo("clientName");
|
assertThat(adapted.getClientName()).isEqualTo("clientName");
|
||||||
}
|
}
|
||||||
|
@ -195,7 +197,8 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
|
||||||
org.springframework.security.oauth2.core.ClientAuthenticationMethod.BASIC);
|
org.springframework.security.oauth2.core.ClientAuthenticationMethod.BASIC);
|
||||||
assertThat(adapted.getAuthorizationGrantType()).isEqualTo(
|
assertThat(adapted.getAuthorizationGrantType()).isEqualTo(
|
||||||
org.springframework.security.oauth2.core.AuthorizationGrantType.AUTHORIZATION_CODE);
|
org.springframework.security.oauth2.core.AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
assertThat(adapted.getRedirectUriTemplate()).isEqualTo("{baseUrl}/login/oauth2/code/{registrationId}");
|
assertThat(adapted.getRedirectUriTemplate())
|
||||||
|
.isEqualTo("{baseUrl}/login/oauth2/code/{registrationId}");
|
||||||
assertThat(adapted.getScopes()).containsExactly("openid", "profile", "email",
|
assertThat(adapted.getScopes()).containsExactly("openid", "profile", "email",
|
||||||
"address", "phone");
|
"address", "phone");
|
||||||
assertThat(adapted.getClientName()).isEqualTo("Google");
|
assertThat(adapted.getClientName()).isEqualTo("Google");
|
||||||
|
|
|
@ -97,12 +97,11 @@ public class OAuth2WebSecurityConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void securityConfigurerBacksOffWhenOtherWebSecurityAdapterPresent()
|
public void securityConfigurerBacksOffWhenOtherWebSecurityAdapterPresent()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
this.contextRunner
|
this.contextRunner.withUserConfiguration(TestWebSecurityConfigurerConfig.class,
|
||||||
.withUserConfiguration(TestWebSecurityConfigurerConfig.class,
|
OAuth2WebSecurityConfiguration.class).run((context) -> {
|
||||||
OAuth2WebSecurityConfiguration.class)
|
|
||||||
.run((context) -> {
|
|
||||||
assertThat(getAuthCodeFilters(context)).isEmpty();
|
assertThat(getAuthCodeFilters(context)).isEmpty();
|
||||||
assertThat(context).getBean(OAuth2AuthorizedClientService.class).isNotNull();
|
assertThat(context).getBean(OAuth2AuthorizedClientService.class)
|
||||||
|
.isNotNull();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,7 @@ import org.springframework.core.NestedExceptionUtils;
|
||||||
*/
|
*/
|
||||||
class ConfigurationPropertiesBindingException extends RuntimeException {
|
class ConfigurationPropertiesBindingException extends RuntimeException {
|
||||||
|
|
||||||
ConfigurationPropertiesBindingException(String message,
|
ConfigurationPropertiesBindingException(String message, Throwable cause) {
|
||||||
Throwable cause) {
|
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,8 +152,8 @@ public class ConfigurationPropertiesBinderBuilderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bind(ConfigurationPropertiesBinder binder, Object target) {
|
private void bind(ConfigurationPropertiesBinder binder, Object target) {
|
||||||
binder.bind(target, AnnotationUtils
|
binder.bind(target, AnnotationUtils.findAnnotation(target.getClass(),
|
||||||
.findAnnotation(target.getClass(), ConfigurationProperties.class));
|
ConfigurationProperties.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigurationProperties(prefix = "test")
|
@ConfigurationProperties(prefix = "test")
|
||||||
|
|
|
@ -268,8 +268,8 @@ public class ConfigurationPropertiesBinderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bind(ConfigurationPropertiesBinder binder, Object target) {
|
private void bind(ConfigurationPropertiesBinder binder, Object target) {
|
||||||
binder.bind(target, AnnotationUtils
|
binder.bind(target, AnnotationUtils.findAnnotation(target.getClass(),
|
||||||
.findAnnotation(target.getClass(), ConfigurationProperties.class));
|
ConfigurationProperties.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigurationProperties(value = "person", ignoreUnknownFields = false)
|
@ConfigurationProperties(value = "person", ignoreUnknownFields = false)
|
||||||
|
|
Loading…
Reference in New Issue