mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Add SslAutoConfiguration to slice test annotations
`SslAutoConfiguration` has been added to `cassandra`, `couchbase`, `elasticsearch`, `mongo` and `redis` slice test annotations. See gh-36038
This commit is contained in:
parent
b9b314622f
commit
321c526bf7
@ -4,3 +4,4 @@ org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfigura
|
|||||||
org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration
|
org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveRepositoriesAutoConfiguration
|
org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveRepositoriesAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration
|
org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration
|
||||||
|
org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration
|
||||||
|
@ -5,3 +5,4 @@ org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfigura
|
|||||||
org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveDataAutoConfiguration
|
org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveDataAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveRepositoriesAutoConfiguration
|
org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveRepositoriesAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration
|
org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration
|
||||||
|
org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration
|
||||||
|
@ -7,3 +7,4 @@ org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAuto
|
|||||||
org.springframework.boot.autoconfigure.elasticsearch.ReactiveElasticsearchClientAutoConfiguration
|
org.springframework.boot.autoconfigure.elasticsearch.ReactiveElasticsearchClientAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
|
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration
|
org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration
|
||||||
|
org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration
|
||||||
|
@ -6,3 +6,4 @@ org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfigura
|
|||||||
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
|
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration
|
org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
|
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
|
||||||
|
org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration
|
||||||
|
@ -2,3 +2,4 @@
|
|||||||
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
|
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration
|
org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration
|
org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration
|
||||||
|
org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration
|
||||||
|
@ -7,6 +7,7 @@ description = "Spring Boot Data Cassandra smoke test"
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-cassandra"))
|
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-cassandra"))
|
||||||
|
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-cassandra-reactive"))
|
||||||
|
|
||||||
testImplementation(project(":spring-boot-project:spring-boot-test"))
|
testImplementation(project(":spring-boot-project:spring-boot-test"))
|
||||||
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2023 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 smoketest.data.cassandra;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.datastax.oss.driver.api.core.CqlSession;
|
||||||
|
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.testcontainers.junit.jupiter.Container;
|
||||||
|
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.test.context.TestConfiguration;
|
||||||
|
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.data.cassandra.core.ReactiveCassandraTemplate;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smoke tests for Cassandra with SSL.
|
||||||
|
*
|
||||||
|
* @author Eddú Meléndez
|
||||||
|
*/
|
||||||
|
@Testcontainers(disabledWithoutDocker = true)
|
||||||
|
@SpringBootTest(properties = { "spring.cassandra.schema-action=create-if-not-exists",
|
||||||
|
"spring.cassandra.connection.connect-timeout=60s", "spring.cassandra.connection.init-query-timeout=60s",
|
||||||
|
"spring.cassandra.request.timeout=60s", "spring.cassandra.ssl.bundle=client",
|
||||||
|
"spring.ssl.bundle.jks.client.keystore.location=classpath:ssl/test-client.p12",
|
||||||
|
"spring.ssl.bundle.jks.client.keystore.password=password",
|
||||||
|
"spring.ssl.bundle.jks.client.truststore.location=classpath:ssl/test-ca.p12",
|
||||||
|
"spring.ssl.bundle.jks.client.truststore.password=password" })
|
||||||
|
class SampleCassandraApplicationReactiveSslTests {
|
||||||
|
|
||||||
|
@Container
|
||||||
|
@ServiceConnection
|
||||||
|
static final SecureCassandraContainer secureCassandra = new SecureCassandraContainer();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ReactiveCassandraTemplate cassandraTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SampleRepository repository;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testRepository() {
|
||||||
|
SampleEntity entity = new SampleEntity();
|
||||||
|
entity.setDescription("Look, new @DataCassandraTest!");
|
||||||
|
String id = UUID.randomUUID().toString();
|
||||||
|
entity.setId(id);
|
||||||
|
SampleEntity savedEntity = this.repository.save(entity);
|
||||||
|
SampleEntity getEntity = this.cassandraTemplate.selectOneById(id, SampleEntity.class)
|
||||||
|
.block(Duration.ofSeconds(30));
|
||||||
|
assertThat(getEntity).isNotNull();
|
||||||
|
assertThat(getEntity.getId()).isNotNull();
|
||||||
|
assertThat(getEntity.getId()).isEqualTo(savedEntity.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestConfiguration(proxyBeanMethods = false)
|
||||||
|
static class KeyspaceTestConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
CqlSession cqlSession(CqlSessionBuilder cqlSessionBuilder) {
|
||||||
|
try (CqlSession session = cqlSessionBuilder.build()) {
|
||||||
|
session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test"
|
||||||
|
+ " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
|
||||||
|
}
|
||||||
|
return cqlSessionBuilder.withKeyspace("boot_test").build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,6 +25,7 @@ import org.testcontainers.junit.jupiter.Container;
|
|||||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.TestConfiguration;
|
import org.springframework.boot.test.context.TestConfiguration;
|
||||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||||
@ -37,9 +38,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* Smoke tests for Cassandra with SSL.
|
* Smoke tests for Cassandra with SSL.
|
||||||
*
|
*
|
||||||
* @author Scott Frederick
|
* @author Scott Frederick
|
||||||
|
* @author Eddú Meléndez
|
||||||
*/
|
*/
|
||||||
@Testcontainers(disabledWithoutDocker = true)
|
@Testcontainers(disabledWithoutDocker = true)
|
||||||
@SpringBootTest(properties = { "spring.cassandra.schema-action=create-if-not-exists",
|
@DataCassandraTest(properties = { "spring.cassandra.schema-action=create-if-not-exists",
|
||||||
"spring.cassandra.connection.connect-timeout=60s", "spring.cassandra.connection.init-query-timeout=60s",
|
"spring.cassandra.connection.connect-timeout=60s", "spring.cassandra.connection.init-query-timeout=60s",
|
||||||
"spring.cassandra.request.timeout=60s", "spring.cassandra.ssl.bundle=client",
|
"spring.cassandra.request.timeout=60s", "spring.cassandra.ssl.bundle=client",
|
||||||
"spring.ssl.bundle.jks.client.keystore.location=classpath:ssl/test-client.p12",
|
"spring.ssl.bundle.jks.client.keystore.location=classpath:ssl/test-client.p12",
|
||||||
|
@ -23,6 +23,7 @@ import org.testcontainers.junit.jupiter.Container;
|
|||||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||||
import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
||||||
@ -35,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* @author Scott Frederick
|
* @author Scott Frederick
|
||||||
*/
|
*/
|
||||||
@Testcontainers(disabledWithoutDocker = true)
|
@Testcontainers(disabledWithoutDocker = true)
|
||||||
@SpringBootTest(properties = { "spring.couchbase.env.ssl.bundle=client", "spring.couchbase.env.timeouts.connect=2m",
|
@DataCouchbaseTest(properties = { "spring.couchbase.env.ssl.bundle=client", "spring.couchbase.env.timeouts.connect=2m",
|
||||||
"spring.data.couchbase.bucket-name=cbbucket",
|
"spring.data.couchbase.bucket-name=cbbucket",
|
||||||
"spring.ssl.bundle.pem.client.keystore.certificate=classpath:ssl/test-client.crt",
|
"spring.ssl.bundle.pem.client.keystore.certificate=classpath:ssl/test-client.crt",
|
||||||
"spring.ssl.bundle.pem.client.keystore.private-key=classpath:ssl/test-client.key",
|
"spring.ssl.bundle.pem.client.keystore.private-key=classpath:ssl/test-client.key",
|
||||||
|
@ -22,7 +22,7 @@ import org.testcontainers.junit.jupiter.Container;
|
|||||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
|
||||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
|
||||||
@ -32,9 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* Smoke tests for MongoDB with SSL.
|
* Smoke tests for MongoDB with SSL.
|
||||||
*
|
*
|
||||||
* @author Scott Frederick
|
* @author Scott Frederick
|
||||||
|
* @author Eddú Meléndez
|
||||||
*/
|
*/
|
||||||
@Testcontainers(disabledWithoutDocker = true)
|
@Testcontainers(disabledWithoutDocker = true)
|
||||||
@SpringBootTest(properties = { "spring.data.mongodb.ssl.bundle=client",
|
@DataMongoTest(properties = { "spring.data.mongodb.ssl.bundle=client",
|
||||||
"spring.ssl.bundle.pem.client.keystore.certificate=classpath:ssl/test-client.crt",
|
"spring.ssl.bundle.pem.client.keystore.certificate=classpath:ssl/test-client.crt",
|
||||||
"spring.ssl.bundle.pem.client.keystore.private-key=classpath:ssl/test-client.key",
|
"spring.ssl.bundle.pem.client.keystore.private-key=classpath:ssl/test-client.key",
|
||||||
"spring.ssl.bundle.pem.client.truststore.certificate=classpath:ssl/test-ca.crt" })
|
"spring.ssl.bundle.pem.client.truststore.certificate=classpath:ssl/test-ca.crt" })
|
||||||
|
@ -24,6 +24,7 @@ import org.testcontainers.junit.jupiter.Container;
|
|||||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||||
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
||||||
@ -39,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*/
|
*/
|
||||||
@Testcontainers(disabledWithoutDocker = true)
|
@Testcontainers(disabledWithoutDocker = true)
|
||||||
@ClassPathExclusions("lettuce-core-*.jar")
|
@ClassPathExclusions("lettuce-core-*.jar")
|
||||||
@SpringBootTest(properties = { "spring.data.redis.ssl.bundle=client",
|
@DataRedisTest(properties = { "spring.data.redis.ssl.bundle=client",
|
||||||
"spring.ssl.bundle.pem.client.keystore.certificate=classpath:ssl/test-client.crt",
|
"spring.ssl.bundle.pem.client.keystore.certificate=classpath:ssl/test-client.crt",
|
||||||
"spring.ssl.bundle.pem.client.keystore.private-key=classpath:ssl/test-client.key",
|
"spring.ssl.bundle.pem.client.keystore.private-key=classpath:ssl/test-client.key",
|
||||||
"spring.ssl.bundle.pem.client.truststore.certificate=classpath:ssl/test-ca.crt" })
|
"spring.ssl.bundle.pem.client.truststore.certificate=classpath:ssl/test-ca.crt" })
|
||||||
|
Loading…
Reference in New Issue
Block a user