Unverified Commit 9abe6b4b authored by EL HAJJIOUI Nabil's avatar EL HAJJIOUI Nabil Committed by GitHub
Browse files

[VAS] item 8925 Bump Spring Core, Spring Boot, Spring Security (#552)

* Bump Spring Core, Spring Boot, Spring Security
parent c10a4af3
......@@ -17,7 +17,6 @@
<rpm.skip>false</rpm.skip>
<swagger.dir>api-internal</swagger.dir>
<swagger.skip>false</swagger.skip>
<spring.data.mongo.version>3.1.7</spring.data.mongo.version>
</properties>
<dependencies>
......@@ -95,20 +94,20 @@
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-mongo</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</dependency>
<!-- Metrics -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<!-- Spring Data Mongo-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${spring.data.mongo.version}</version>
</dependency>
<!-- PAC4J -->
<dependency>
<groupId>org.pac4j</groupId>
......@@ -156,11 +155,6 @@
<artifactId>iam-external-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-test</artifactId>
......@@ -178,6 +172,11 @@
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -31,12 +31,15 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@ActiveProfiles("test")
@ImportAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
public class ApiArchivesSearchInternalApplicationTest {
@Autowired
......
......@@ -81,7 +81,8 @@ public class TestMongoConfig extends AbstractMongoClientConfiguration {
public void initIt() throws Exception {
port = Network.getFreeServerPort();
_mongodExe = starter.prepare(new MongodConfigBuilder().version(Version.Main.PRODUCTION)
_mongodExe = starter.prepare(new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(MONGO_HOST, port, Network.localhostIsIPv6()))
.build());
......
......@@ -32,12 +32,13 @@ import fr.gouv.vitam.access.external.client.v2.AccessExternalClientV2;
import fr.gouv.vitam.ingest.external.client.IngestExternalClient;
import fr.gouv.vitamui.archive.internal.server.service.ArchiveSearchAgenciesInternalService;
import fr.gouv.vitamui.archive.internal.server.service.ArchiveSearchInternalService;
import fr.gouv.vitamui.commons.api.application.AbstractContextConfiguration;
import fr.gouv.vitamui.commons.vitam.api.administration.AgencyService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ActiveProfiles;
......@@ -47,7 +48,8 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@ActiveProfiles("test")
public class ApiArchiveSearchInternalServerConfigTest extends AbstractContextConfiguration {
@ImportAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
public class ApiArchiveSearchInternalServerConfigTest {
@MockBean(name = "adminExternalClient")
private AdminExternalClient adminExternalClient;
......
......@@ -46,16 +46,18 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@ActiveProfiles("test")
@ImportAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
public class SearchCriteriaHistoryInternalServerConfigTest {
@MockBean(name = "adminExternalClient")
......
......@@ -33,6 +33,8 @@ server:
client-auth: need
enabled-protocols: TLSv1.1,TLSv1.2,TLSv1.3
ciphers: ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384
error:
path: /error
management:
server:
......
......@@ -135,12 +135,23 @@
</dependency>
<!-- Spring Data Mongo-->
<!-- TODO adapt this library to be conforme with spring boot versions in futur spring stack bumps-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${spring.data.mongo.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- UTIL -->
<dependency>
<groupId>org.projectlombok</groupId>
......
......@@ -25,6 +25,8 @@ server-identity:
server:
host:
port: 7083
error:
path: /error
management:
server:
......
......@@ -45,7 +45,8 @@ public class TestMongoConfig extends AbstractMongoClientConfiguration {
public void initIt() throws Exception {
port = Network.getFreeServerPort();
_mongodExe = starter.prepare(new MongodConfigBuilder().version(Version.Main.PRODUCTION)
_mongodExe = starter.prepare(new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(MONGO_HOST, port, Network.localhostIsIPv6()))
.build());
......
......@@ -10,11 +10,12 @@ import fr.gouv.vitamui.commons.security.client.password.PasswordValidator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.mongodb.MongoTransactionManager;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
......@@ -22,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@ActiveProfiles("test")
@ImportAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
public class ApiIamServerConfigTest {
@MockBean
private AdminExternalClient adminExternalClient;
......
......@@ -44,6 +44,8 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
......@@ -51,7 +53,6 @@ import org.springframework.data.mongodb.MongoTransactionManager;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
......@@ -67,6 +68,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest
@Import({ TestMongoConfig.class })
@ActiveProfiles(value = "test")
@ImportAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
public class InitCustomerServiceIntegrationTest {
private static final String PROFILE_NAME_1 = "profile1";
......
......@@ -46,6 +46,8 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ActiveProfiles;
......@@ -54,6 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@ActiveProfiles("test")
@ImportAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
public class ApiIngestInternalServerConfigTest {
......
......@@ -34,6 +34,8 @@ server:
client-auth: need
enabled-protocols: TLSv1.1,TLSv1.2,TLSv1.3
ciphers: ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384
error:
path: /error
management:
server:
......
......@@ -25,6 +25,8 @@ server:
host:
port: 7087
tomcat.connection-timeout: 60000
error:
path: /error
management:
server:
......
......@@ -97,6 +97,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-web-starter</artifactId>
......
......@@ -18,6 +18,9 @@ server-identity:
server:
port: 8084
error:
path: /error
management:
server:
address: localhost
......
package fr.gouv.vitamui.security.server;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("test")
@ImportAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
public class ApiSecurityApplicationTest {
@Autowired
......
......@@ -12,7 +12,6 @@ import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.process.runtime.Network;
import fr.gouv.vitamui.commons.api.converter.OffsetDateTimeToStringConverter;
import fr.gouv.vitamui.commons.api.converter.StringToOffsetDateTimeConverter;
import fr.gouv.vitamui.commons.logbook.dao.EventRepository;
import fr.gouv.vitamui.commons.mongo.repository.CommonsMongoRepository;
import fr.gouv.vitamui.commons.mongo.repository.impl.VitamUIRepositoryImpl;
import org.springframework.context.annotation.Configuration;
......@@ -48,9 +47,9 @@ public class TestMongoConfig extends AbstractMongoClientConfiguration {
port = Network.getFreeServerPort();
_mongodExe = starter.prepare(new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(MONGO_HOST, port, Network.localhostIsIPv6()))
.build());
.version(Version.Main.PRODUCTION)
.net(new Net(MONGO_HOST, port, Network.localhostIsIPv6()))
.build());
_mongod = _mongodExe.start();
}
......
......@@ -12,6 +12,9 @@
<artifactId>commons-parent</artifactId>
<version>5.0-SNAPSHOT</version>
</parent>
<properties>
<spring.data.mongo.version>3.1.7</spring.data.mongo.version>
</properties>
<dependencies>
<!-- VITAMUI -->
......@@ -23,13 +26,16 @@
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-utils</artifactId>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<scope>provided</scope>
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-vitam</artifactId>
</dependency>
<dependency>
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-rest</artifactId>
</dependency>
<!-- SPRING BOOT -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
......@@ -41,16 +47,31 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
<scope>provided</scope>
</dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<scope>provided</scope>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<scope>provided</scope>
</dependency>
<!-- Spring Data Mongo-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${spring.data.mongo.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
<!-- Utils -->
<dependency>
<groupId>org.apache.commons</groupId>
......@@ -133,7 +154,17 @@
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-test</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
......
package fr.gouv.vitamui.commons.mongo.config;
package fr.gouv.vitamui.commons.mongo;
import com.mongodb.MongoClientSettings;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoClient;
import com.mongodb.connection.ClusterSettings;
import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodProcess;
......@@ -13,23 +12,24 @@ import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.process.runtime.Network;
import fr.gouv.vitamui.commons.api.converter.OffsetDateTimeToStringConverter;
import fr.gouv.vitamui.commons.api.converter.StringToOffsetDateTimeConverter;
import fr.gouv.vitamui.commons.api.identity.ServerIdentityAutoConfiguration;
import fr.gouv.vitamui.commons.mongo.repository.CommonsMongoRepository;
import fr.gouv.vitamui.commons.mongo.repository.impl.VitamUIRepositoryImpl;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.validation.constraints.NotNull;
import java.util.Collections;
@Configuration
@EnableMongoRepositories(basePackages = {
"fr.gouv.vitamui.commons.mongo.dao",
"fr.gouv.vitamui.commons.mongo.repository"
}, repositoryBaseClass = VitamUIRepositoryImpl.class)
@EnableMongoRepositories(basePackageClasses = {CommonsMongoRepository.class}, repositoryBaseClass = VitamUIRepositoryImpl.class)
@Import({ServerIdentityAutoConfiguration.class})
public class TestMongoConfig extends AbstractMongoClientConfiguration {
private static final MongodStarter starter = MongodStarter.getDefaultInstance();
......@@ -54,11 +54,13 @@ public class TestMongoConfig extends AbstractMongoClientConfiguration {
@PreDestroy
public void close() {
if (_mongod != null)
if (_mongod != null) {
_mongod.stop();
}
if (_mongodExe != null)
if (_mongodExe != null) {
_mongodExe.stop();
}
}
@Override
......@@ -69,9 +71,10 @@ public class TestMongoConfig extends AbstractMongoClientConfiguration {
builder.applyToClusterSettings(b -> b.applySettings(clusterSettings));
}
@NotNull
@Override
protected String getDatabaseName() {
return "test";
return "db";
}
@Override
......@@ -80,11 +83,5 @@ public class TestMongoConfig extends AbstractMongoClientConfiguration {
converterConfigurationAdapter.registerConverter(new StringToOffsetDateTimeConverter());
}
@Override
protected String getMappingBasePackage() {
return "fr.gouv.vitamui.commons.mongo";
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment