|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2024 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.
|
@@ -71,28 +71,39 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
|
71 | 71 | HealthEndpointAutoConfiguration.class, InfoEndpointAutoConfiguration.class,
|
72 | 72 | WebFluxAutoConfiguration.class, EnvironmentEndpointAutoConfiguration.class,
|
73 | 73 | EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class,
|
74 |
| - ReactiveSecurityAutoConfiguration.class, ReactiveManagementWebSecurityAutoConfiguration.class)) |
75 |
| - .withUserConfiguration(UserDetailsServiceConfiguration.class); |
| 74 | + ReactiveSecurityAutoConfiguration.class, ReactiveManagementWebSecurityAutoConfiguration.class)); |
76 | 75 |
|
77 | 76 | @Test
|
78 | 77 | void permitAllForHealth() {
|
79 |
| - this.contextRunner.run((context) -> assertThat(getAuthenticateHeader(context, "/actuator/health")).isNull()); |
| 78 | + this.contextRunner.withUserConfiguration(UserDetailsServiceConfiguration.class) |
| 79 | + .run((context) -> assertThat(getAuthenticateHeader(context, "/actuator/health")).isNull()); |
80 | 80 | }
|
81 | 81 |
|
82 | 82 | @Test
|
83 | 83 | void securesEverythingElse() {
|
| 84 | + this.contextRunner.withUserConfiguration(UserDetailsServiceConfiguration.class).run((context) -> { |
| 85 | + assertThat(getAuthenticateHeader(context, "/actuator").get(0)).contains("Basic realm="); |
| 86 | + assertThat(getAuthenticateHeader(context, "/foo").toString()).contains("Basic realm="); |
| 87 | + }); |
| 88 | + } |
| 89 | + |
| 90 | + @Test |
| 91 | + void noExistingAuthenticationManagerOrUserDetailsService() { |
84 | 92 | this.contextRunner.run((context) -> {
|
| 93 | + assertThat(getAuthenticateHeader(context, "/actuator/health")).isNull(); |
85 | 94 | assertThat(getAuthenticateHeader(context, "/actuator").get(0)).contains("Basic realm=");
|
86 | 95 | assertThat(getAuthenticateHeader(context, "/foo").toString()).contains("Basic realm=");
|
87 | 96 | });
|
88 | 97 | }
|
89 | 98 |
|
90 | 99 | @Test
|
91 | 100 | void usesMatchersBasedOffConfiguredActuatorBasePath() {
|
92 |
| - this.contextRunner.withPropertyValues("management.endpoints.web.base-path=/").run((context) -> { |
93 |
| - assertThat(getAuthenticateHeader(context, "/health")).isNull(); |
94 |
| - assertThat(getAuthenticateHeader(context, "/foo").get(0)).contains("Basic realm="); |
95 |
| - }); |
| 101 | + this.contextRunner.withUserConfiguration(UserDetailsServiceConfiguration.class) |
| 102 | + .withPropertyValues("management.endpoints.web.base-path=/") |
| 103 | + .run((context) -> { |
| 104 | + assertThat(getAuthenticateHeader(context, "/health")).isNull(); |
| 105 | + assertThat(getAuthenticateHeader(context, "/foo").get(0)).contains("Basic realm="); |
| 106 | + }); |
96 | 107 | }
|
97 | 108 |
|
98 | 109 | @Test
|
@@ -180,6 +191,11 @@ SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
180 | 191 | return http.build();
|
181 | 192 | }
|
182 | 193 |
|
| 194 | + @Bean |
| 195 | + ReactiveAuthenticationManager authenticationManager() { |
| 196 | + return mock(ReactiveAuthenticationManager.class); |
| 197 | + } |
| 198 | + |
183 | 199 | }
|
184 | 200 |
|
185 | 201 | @Configuration(proxyBeanMethods = false)
|
|
0 commit comments