Update conditions for OAuth security config

Closes gh-11070
pull/11073/head
Madhura Bhave 7 years ago
parent 50a3c2fe2a
commit 551c08ebfe

@ -34,7 +34,6 @@ import org.springframework.security.oauth2.client.registration.ClientRegistratio
* @since 2.0.0
*/
@Configuration
@ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class)
@ConditionalOnBean(ClientRegistrationRepository.class)
class OAuth2WebSecurityConfiguration {
@ -46,7 +45,8 @@ class OAuth2WebSecurityConfiguration {
}
@Configuration
static class OAuth2WebSecurityConfigurationAdapter
@ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class)
static class OAuth2WebSecurityConfigurerAdapter
extends WebSecurityConfigurerAdapter {
@Override

@ -81,15 +81,6 @@ public class OAuth2WebSecurityConfigurationTests {
.run((context) -> assertThat(getAuthCodeFilters(context)).isEmpty());
}
@Test
public void securityConfigurerBacksOffWhenOtherWebSecurityAdapterPresent()
throws Exception {
this.contextRunner
.withUserConfiguration(TestWebSecurityConfigurerConfig.class,
OAuth2WebSecurityConfiguration.class)
.run((context) -> assertThat(getAuthCodeFilters(context)).isEmpty());
}
@Test
public void configurationRegistersAuthorizedClientServiceBean() throws Exception {
this.contextRunner.withUserConfiguration(ClientRepositoryConfiguration.class,
@ -103,6 +94,18 @@ public class OAuth2WebSecurityConfigurationTests {
});
}
@Test
public void securityConfigurerBacksOffWhenOtherWebSecurityAdapterPresent()
throws Exception {
this.contextRunner
.withUserConfiguration(TestWebSecurityConfigurerConfig.class,
OAuth2WebSecurityConfiguration.class)
.run((context) -> {
assertThat(getAuthCodeFilters(context)).isEmpty();
assertThat(context).getBean(OAuth2AuthorizedClientService.class).isNotNull();
});
}
@Test
public void authorizedClientServiceBeanIsConditionalOnMissingBean() throws Exception {
this.contextRunner

Loading…
Cancel
Save