|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
30 | 30 | import org.springframework.context.annotation.Bean;
|
31 | 31 | import org.springframework.context.annotation.Configuration;
|
32 | 32 | import org.springframework.context.annotation.Import;
|
33 |
| -import org.springframework.security.authentication.*; |
| 33 | +import org.springframework.security.authentication.AuthenticationManager; |
| 34 | +import org.springframework.security.authentication.AuthenticationManagerResolver; |
| 35 | +import org.springframework.security.authentication.AuthenticationProvider; |
| 36 | +import org.springframework.security.authentication.ProviderManager; |
| 37 | +import org.springframework.security.authentication.TestingAuthenticationProvider; |
| 38 | +import org.springframework.security.authentication.TestingAuthenticationToken; |
34 | 39 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
35 | 40 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
36 | 41 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
@@ -79,6 +84,12 @@ void defaultUserNotCreatedIfAuthenticationManagerBeanPresent(CapturedOutput outp
|
79 | 84 | });
|
80 | 85 | }
|
81 | 86 |
|
| 87 | + @Test |
| 88 | + void defaultUserNotCreatedIfAuthenticationManagerResolverBeanPresent(CapturedOutput output) { |
| 89 | + this.contextRunner.withUserConfiguration(TestAuthenticationManagerResolverConfiguration.class) |
| 90 | + .run((context) -> assertThat(output).doesNotContain("Using generated security password: ")); |
| 91 | + } |
| 92 | + |
82 | 93 | @Test
|
83 | 94 | void defaultUserNotCreatedIfUserDetailsServiceBeanPresent(CapturedOutput output) {
|
84 | 95 | this.contextRunner.withUserConfiguration(TestUserDetailsServiceConfiguration.class).run((context) -> {
|
@@ -151,12 +162,6 @@ void generatedPasswordShouldNotBePrintedIfAuthenticationManagerBuilderIsUsed(Cap
|
151 | 162 | .run(((context) -> assertThat(output).doesNotContain("Using generated security password: ")));
|
152 | 163 | }
|
153 | 164 |
|
154 |
| - @Test |
155 |
| - void userDetailsServiceShouldNotBePresentWhenAuthenticationManagerResolverBeanIsPresent() { |
156 |
| - this.contextRunner.withUserConfiguration(TestAuthenticationManagerResolverConfiguration.class) |
157 |
| - .run(((context) -> assertThat(context).doesNotHaveBean(InMemoryUserDetailsManager.class))); |
158 |
| - } |
159 |
| - |
160 | 165 | private void testPasswordEncoding(Class<?> configClass, String providedPassword, String expectedPassword) {
|
161 | 166 | this.contextRunner.withUserConfiguration(configClass)
|
162 | 167 | .withPropertyValues("spring.security.user.password=" + providedPassword).run(((context) -> {
|
@@ -272,7 +277,7 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
272 | 277 | static class TestAuthenticationManagerResolverConfiguration {
|
273 | 278 |
|
274 | 279 | @Bean
|
275 |
| - AuthenticationManagerResolver<?> myAuthenticationManagerResolver() { |
| 280 | + AuthenticationManagerResolver<?> authenticationManagerResolver() { |
276 | 281 | return mock(AuthenticationManagerResolver.class);
|
277 | 282 | }
|
278 | 283 |
|
|
0 commit comments