File tree 5 files changed +13
-21
lines changed
oauth2login/src/integration-test/java/sample
oauth2webclient/src/test/java/sample
oauth2webclient-webflux/src/test/java/sample
5 files changed +13
-21
lines changed Original file line number Diff line number Diff line change 41
41
import org .springframework .beans .factory .annotation .Autowired ;
42
42
import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
43
43
import org .springframework .boot .test .context .SpringBootTest ;
44
+ import org .springframework .boot .test .context .TestConfiguration ;
44
45
import org .springframework .http .HttpStatus ;
45
46
import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
46
47
import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
83
84
* @since 5.0
84
85
*/
85
86
@ RunWith (SpringRunner .class )
86
- @ SpringBootTest ( classes ={ OAuth2LoginApplication . class , OAuth2LoginApplicationTests . SecurityTestConfig . class })
87
+ @ SpringBootTest
87
88
@ AutoConfigureMockMvc
88
89
public class OAuth2LoginApplicationTests {
89
90
private static final String AUTHORIZATION_BASE_URI = "/oauth2/authorization" ;
@@ -326,6 +327,7 @@ private WebResponse followLinkDisableRedirects(HtmlAnchor anchorElement) throws
326
327
}
327
328
328
329
@ EnableWebSecurity
330
+ @ TestConfiguration
329
331
public static class SecurityTestConfig extends WebSecurityConfigurerAdapter {
330
332
331
333
// @formatter:off
Original file line number Diff line number Diff line change 22
22
import org .junit .Test ;
23
23
import org .junit .runner .RunWith ;
24
24
import sample .config .SecurityConfig ;
25
- import sample .web .OAuth2WebClientController ;
26
25
27
26
import org .springframework .beans .factory .annotation .Autowired ;
28
27
import org .springframework .boot .test .autoconfigure .web .reactive .AutoConfigureWebTestClient ;
29
28
import org .springframework .boot .test .autoconfigure .web .reactive .WebFluxTest ;
29
+ import org .springframework .boot .test .context .TestConfiguration ;
30
30
import org .springframework .boot .test .mock .mockito .MockBean ;
31
31
import org .springframework .context .annotation .Bean ;
32
- import org .springframework .context .annotation .Configuration ;
33
32
import org .springframework .context .annotation .Import ;
34
33
import org .springframework .security .oauth2 .client .registration .ReactiveClientRegistrationRepository ;
35
34
import org .springframework .test .context .junit4 .SpringRunner ;
40
39
import static org .springframework .security .test .web .reactive .server .SecurityMockServerConfigurers .mockOAuth2Login ;
41
40
42
41
@ WebFluxTest
43
- @ Import ({ SecurityConfig .class , OAuth2WebClientController . class } )
42
+ @ Import (SecurityConfig .class )
44
43
@ AutoConfigureWebTestClient
45
44
@ RunWith (SpringRunner .class )
46
45
public class OAuth2WebClientControllerTests {
@@ -94,7 +93,7 @@ public void publicImplicitWhenAuthenticatedThenUsesDefaultRegistration() throws
94
93
.expectStatus ().isOk ();
95
94
}
96
95
97
- @ Configuration
96
+ @ TestConfiguration
98
97
static class WebClientConfig {
99
98
@ Bean
100
99
WebClient web () {
Original file line number Diff line number Diff line change 22
22
import org .junit .Test ;
23
23
import org .junit .runner .RunWith ;
24
24
import sample .config .SecurityConfig ;
25
- import sample .web .RegisteredOAuth2AuthorizedClientController ;
26
25
27
26
import org .springframework .beans .factory .annotation .Autowired ;
28
27
import org .springframework .boot .test .autoconfigure .web .reactive .AutoConfigureWebTestClient ;
29
28
import org .springframework .boot .test .autoconfigure .web .reactive .WebFluxTest ;
29
+ import org .springframework .boot .test .context .TestConfiguration ;
30
30
import org .springframework .boot .test .mock .mockito .MockBean ;
31
31
import org .springframework .context .annotation .Bean ;
32
- import org .springframework .context .annotation .Configuration ;
33
32
import org .springframework .context .annotation .Import ;
34
33
import org .springframework .security .oauth2 .client .registration .ReactiveClientRegistrationRepository ;
35
34
import org .springframework .test .context .junit4 .SpringRunner ;
40
39
import static org .springframework .security .test .web .reactive .server .SecurityMockServerConfigurers .mockOAuth2Login ;
41
40
42
41
@ WebFluxTest
43
- @ Import ({ SecurityConfig .class , RegisteredOAuth2AuthorizedClientController . class } )
42
+ @ Import (SecurityConfig .class )
44
43
@ AutoConfigureWebTestClient
45
44
@ RunWith (SpringRunner .class )
46
45
public class RegisteredOAuth2AuthorizedClientControllerTests {
@@ -94,7 +93,7 @@ public void publicAnnotationImplicitWhenAuthenticatedThenUsesDefaultRegistration
94
93
.expectStatus ().isOk ();
95
94
}
96
95
97
- @ Configuration
96
+ @ TestConfiguration
98
97
static class WebClientConfig {
99
98
@ Bean
100
99
WebClient web () {
Original file line number Diff line number Diff line change 21
21
import org .junit .AfterClass ;
22
22
import org .junit .Test ;
23
23
import org .junit .runner .RunWith ;
24
- import sample .config .SecurityConfig ;
25
- import sample .web .OAuth2WebClientController ;
26
24
27
25
import org .springframework .beans .factory .annotation .Autowired ;
28
26
import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
29
27
import org .springframework .boot .test .autoconfigure .web .servlet .WebMvcTest ;
28
+ import org .springframework .boot .test .context .TestConfiguration ;
30
29
import org .springframework .boot .test .mock .mockito .MockBean ;
31
30
import org .springframework .context .annotation .Bean ;
32
- import org .springframework .context .annotation .Configuration ;
33
- import org .springframework .context .annotation .Import ;
34
31
import org .springframework .security .oauth2 .client .registration .ClientRegistrationRepository ;
35
32
import org .springframework .test .context .junit4 .SpringRunner ;
36
33
import org .springframework .test .web .servlet .MockMvc ;
42
39
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
43
40
44
41
@ WebMvcTest
45
- @ Import ({ SecurityConfig .class , OAuth2WebClientController .class })
46
42
@ AutoConfigureMockMvc
47
43
@ RunWith (SpringRunner .class )
48
44
public class OAuth2WebClientControllerTests {
@@ -92,7 +88,7 @@ public void publicImplicitWhenAuthenticatedThenUsesDefaultRegistration() throws
92
88
.andExpect (status ().isOk ());
93
89
}
94
90
95
- @ Configuration
91
+ @ TestConfiguration
96
92
static class WebClientConfig {
97
93
@ Bean
98
94
WebClient web () {
Original file line number Diff line number Diff line change 21
21
import org .junit .AfterClass ;
22
22
import org .junit .Test ;
23
23
import org .junit .runner .RunWith ;
24
- import sample .config .SecurityConfig ;
25
- import sample .web .RegisteredOAuth2AuthorizedClientController ;
26
24
27
25
import org .springframework .beans .factory .annotation .Autowired ;
28
26
import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
29
27
import org .springframework .boot .test .autoconfigure .web .servlet .WebMvcTest ;
28
+ import org .springframework .boot .test .context .TestConfiguration ;
30
29
import org .springframework .boot .test .mock .mockito .MockBean ;
31
30
import org .springframework .context .annotation .Bean ;
32
- import org .springframework .context .annotation .Configuration ;
33
- import org .springframework .context .annotation .Import ;
34
31
import org .springframework .security .oauth2 .client .registration .ClientRegistrationRepository ;
35
32
import org .springframework .test .context .junit4 .SpringRunner ;
36
33
import org .springframework .test .web .servlet .MockMvc ;
42
39
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
43
40
44
41
@ WebMvcTest
45
- @ Import ({ SecurityConfig .class , RegisteredOAuth2AuthorizedClientController .class })
46
42
@ AutoConfigureMockMvc
47
43
@ RunWith (SpringRunner .class )
48
44
public class RegisteredOAuth2AuthorizedClientControllerTests {
@@ -92,7 +88,7 @@ public void publicAnnotationImplicitWhenAuthenticatedThenUsesDefaultRegistration
92
88
.andExpect (status ().isOk ());
93
89
}
94
90
95
- @ Configuration
91
+ @ TestConfiguration
96
92
static class WebClientConfig {
97
93
@ Bean
98
94
WebClient web () {
You can’t perform that action at this time.
0 commit comments