mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '4.0.x'
Closes gh-50635
This commit is contained in:
+2
-1
@@ -24,6 +24,7 @@ import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Configuration properties for Cassandra.
|
||||
@@ -237,7 +238,7 @@ public class CassandraProperties {
|
||||
private @Nullable String bundle;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return (this.enabled != null) ? this.enabled : this.bundle != null;
|
||||
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
|
||||
+7
@@ -58,4 +58,11 @@ class CassandraPropertiesTests {
|
||||
assertThat(driverDefaults.get(TypedDriverOption.HEARTBEAT_TIMEOUT)).isEqualTo(Duration.ofSeconds(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sslIsNotEnabledWhenBundleIsEmpty() {
|
||||
CassandraProperties properties = new CassandraProperties();
|
||||
properties.getSsl().setBundle("");
|
||||
assertThat(properties.getSsl().isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Configuration properties for Redis.
|
||||
@@ -463,7 +464,7 @@ public class DataRedisProperties {
|
||||
private @Nullable String bundle;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return (this.enabled != null) ? this.enabled : this.bundle != null;
|
||||
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
|
||||
+8
-1
@@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class RedisPropertiesTests {
|
||||
class DataRedisPropertiesTests {
|
||||
|
||||
@Test
|
||||
void lettuceDefaultsAreConsistent() {
|
||||
@@ -39,4 +39,11 @@ class RedisPropertiesTests {
|
||||
.isEqualTo(defaultClusterTopologyRefreshOptions.useDynamicRefreshSources());
|
||||
}
|
||||
|
||||
@Test
|
||||
void sslIsNotEnabledWhenBundleIsEmpty() {
|
||||
DataRedisProperties properties = new DataRedisProperties();
|
||||
properties.getSsl().setBundle("");
|
||||
assertThat(properties.getSsl().isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -73,7 +73,7 @@ class MailSenderPropertiesConfiguration {
|
||||
if (ssl.isEnabled()) {
|
||||
javaMailProperties.setProperty("mail." + protocol + ".ssl.enable", "true");
|
||||
}
|
||||
if (ssl.getBundle() != null) {
|
||||
if (StringUtils.hasLength(ssl.getBundle())) {
|
||||
Assert.state(sslBundles != null, "'sslBundles' must not be null");
|
||||
SslBundle sslBundle = sslBundles.getBundle(ssl.getBundle());
|
||||
javaMailProperties.put("mail." + protocol + ".ssl.socketFactory",
|
||||
|
||||
+15
@@ -245,6 +245,21 @@ class MailSenderAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithPackageResources("test.jks")
|
||||
void sslIsNotEnabledWhenBundleIsEmpty() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.mail.host:localhost", "spring.mail.ssl.bundle: ",
|
||||
"spring.ssl.bundle.jks.test-bundle.keystore.location:classpath:test.jks",
|
||||
"spring.ssl.bundle.jks.test-bundle.keystore.password:secret",
|
||||
"spring.ssl.bundle.jks.test-bundle.key.password:password")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
|
||||
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
|
||||
assertThat(mailSender.getJavaMailProperties().get("mail.smtp.ssl.socketFactory")).isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void smtpSslEnabled() {
|
||||
this.contextRunner.withPropertyValues("spring.mail.host:localhost", "spring.mail.ssl.enabled:true")
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import org.bson.UuidRepresentation;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Configuration properties for Mongo.
|
||||
@@ -238,7 +239,7 @@ public class MongoProperties {
|
||||
private @Nullable String bundle;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return (this.enabled != null) ? this.enabled : this.bundle != null;
|
||||
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
|
||||
+7
@@ -49,6 +49,13 @@ class MongoPropertiesTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void sslIsNotEnabledWhenBundleIsEmpty() {
|
||||
MongoProperties properties = new MongoProperties();
|
||||
properties.getSsl().setBundle("");
|
||||
assertThat(properties.getSsl().isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
private UuidRepresentation springDataDefaultUuidRepresentation() {
|
||||
return new MongoConfigurationSupport() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user