Move SSL auto-configuration out of actuator-autoconfigure-all
Issue: 46071
This commit is contained in:
parent
29d1fe24ec
commit
d19d1b9dee
|
@ -3,8 +3,6 @@ org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.CloudFoundry
|
|||
org.springframework.boot.actuate.autoconfigure.observability.ObservabilityAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.security.reactive.ReactiveManagementWebSecurityAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.ssl.SslHealthContributorAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.ssl.SslObservabilityAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.tracing.BraveAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.tracing.MicrometerTracingAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.tracing.NoopTracerAutoConfiguration
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.ssl;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
|
||||
import org.springframework.boot.info.SslInfo;
|
||||
import org.springframework.boot.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration;
|
||||
import org.springframework.boot.metrics.autoconfigure.MetricsAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SslObservabilityAutoConfiguration}.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class SslObservabilityAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(
|
||||
AutoConfigurations.of(MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class,
|
||||
SslAutoConfiguration.class, SslObservabilityAutoConfiguration.class));
|
||||
|
||||
private final ApplicationContextRunner contextRunnerWithoutSslBundles = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class,
|
||||
CompositeMeterRegistryAutoConfiguration.class, SslObservabilityAutoConfiguration.class));
|
||||
|
||||
private final ApplicationContextRunner contextRunnerWithoutMeterRegistry = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(SslAutoConfiguration.class, SslObservabilityAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void shouldSupplyBeans() {
|
||||
this.contextRunner
|
||||
.run((context) -> assertThat(context).hasSingleBean(SslMeterBinder.class).hasSingleBean(SslInfo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldBackOffIfSslBundlesIsMissing() {
|
||||
this.contextRunnerWithoutSslBundles
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(SslMeterBinder.class).doesNotHaveBean(SslInfo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldBackOffIfMeterRegistryIsMissing() {
|
||||
this.contextRunnerWithoutMeterRegistry
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(SslMeterBinder.class).doesNotHaveBean(SslInfo.class));
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,7 @@ org.springframework.boot.actuate.autoconfigure.management.HeapDumpWebEndpointAut
|
|||
org.springframework.boot.actuate.autoconfigure.management.ThreadDumpEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.sbom.SbomEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.ssl.SslHealthContributorAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.startup.StartupEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthContributorAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.web.exchanges.HttpExchangesEndpointAutoConfiguration
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.ssl;
|
||||
package org.springframework.boot.metrics.autoconfigure.ssl;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
|
@ -14,44 +14,37 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.ssl;
|
||||
package org.springframework.boot.metrics.autoconfigure.ssl;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.info.SslInfo;
|
||||
import org.springframework.boot.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration;
|
||||
import org.springframework.boot.metrics.autoconfigure.MetricsAutoConfiguration;
|
||||
import org.springframework.boot.ssl.SslBundles;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for SSL observability.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for SSL metrics.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @since 3.5.0
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration(after = SslAutoConfiguration.class,
|
||||
afterName = { "org.springframework.boot.metrics.autoconfigure.MetricsAutoConfiguration",
|
||||
"org.springframework.boot.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration" })
|
||||
@AutoConfiguration(after = { CompositeMeterRegistryAutoConfiguration.class, MetricsAutoConfiguration.class,
|
||||
SslAutoConfiguration.class })
|
||||
@ConditionalOnClass(MeterRegistry.class)
|
||||
@ConditionalOnBean({ MeterRegistry.class, SslBundles.class })
|
||||
@EnableConfigurationProperties(SslHealthIndicatorProperties.class)
|
||||
public class SslObservabilityAutoConfiguration {
|
||||
public class SslMetricsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
SslMeterBinder sslMeterBinder(SslInfo sslInfo, SslBundles sslBundles) {
|
||||
return new SslMeterBinder(sslInfo, sslBundles);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
SslInfo sslInfoProvider(SslBundles sslBundles, SslHealthIndicatorProperties properties) {
|
||||
return new SslInfo(sslBundles);
|
||||
SslMeterBinder sslMeterBinder(SslBundles sslBundles, ObjectProvider<SslInfo> sslInfo) {
|
||||
return new SslMeterBinder(sslInfo.getIfAvailable(() -> new SslInfo(sslBundles)), sslBundles);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2012-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for SSL metrics.
|
||||
*/
|
||||
package org.springframework.boot.metrics.autoconfigure.ssl;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.ssl;
|
||||
package org.springframework.boot.metrics.autoconfigure.ssl;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright 2012-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.metrics.autoconfigure.ssl;
|
||||
|
||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SslMetricsAutoConfiguration}.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class SslMetricsAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(SslMetricsAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void shouldSupplyMeterBinder() {
|
||||
this.contextRunner.withConfiguration(AutoConfigurations.of(SslAutoConfiguration.class))
|
||||
.withBean(SimpleMeterRegistry.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(SslMeterBinder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldBackOffIfSslBundlesIsMissing() {
|
||||
this.contextRunner.withBean(SimpleMeterRegistry.class)
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(SslMeterBinder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldBackOffIfMeterRegistryIsMissing() {
|
||||
this.contextRunner.withConfiguration(AutoConfigurations.of(SslAutoConfiguration.class))
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(SslMeterBinder.class));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue