BUS-24:Add vault (#5)

* BUS-24:Add vault

* fix pom

* fix test
This commit is contained in:
malkoas 2023-06-14 09:47:23 +03:00 committed by GitHub
parent e35c7734a7
commit a586b4bb0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 18 deletions

28
pom.xml
View File

@ -27,8 +27,22 @@
<db.password>postgres</db.password> <db.password>postgres</db.password>
<db.schema>alert_tg_bot</db.schema> <db.schema>alert_tg_bot</db.schema>
<testcontainers.annotations.version>1.4.3</testcontainers.annotations.version> <testcontainers.annotations.version>1.4.3</testcontainers.annotations.version>
<spring-cloud.version>2021.0.7</spring-cloud.version>
</properties> </properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<!--vality--> <!--vality-->
<dependency> <dependency>
@ -61,11 +75,6 @@
<groupId>dev.vality.geck</groupId> <groupId>dev.vality.geck</groupId>
<artifactId>migrator</artifactId> <artifactId>migrator</artifactId>
</dependency> </dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>adapter-common-lib</artifactId>
<version>1.2.8</version>
</dependency>
<dependency> <dependency>
<groupId>dev.vality</groupId> <groupId>dev.vality</groupId>
<artifactId>damsel</artifactId> <artifactId>damsel</artifactId>
@ -73,11 +82,6 @@
</dependency> </dependency>
<!--spring--> <!--spring-->
<dependency>
<groupId>org.springframework.vault</groupId>
<artifactId>spring-vault-core</artifactId>
<version>2.3.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>spring-boot-starter</artifactId>
@ -109,6 +113,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId> <artifactId>spring-boot-starter-jooq</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-vault-config</artifactId>
</dependency>
<!--third party--> <!--third party-->
<dependency> <dependency>

View File

@ -1,18 +1,14 @@
package dev.vality.alert.tg.bot.config.properties; package dev.vality.alert.tg.bot.config.properties;
import lombok.Getter; import lombok.Data;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@Data
@Configuration @Configuration
@ConfigurationProperties(prefix = "bot") @ConfigurationProperties(prefix = "bot")
@Validated
@Getter
@Setter
public class AlertBotProperties { public class AlertBotProperties {
@NotNull @NotNull

View File

@ -35,6 +35,14 @@ spring:
url: jdbc:postgresql://localhost:5432/alert_tg_bot url: jdbc:postgresql://localhost:5432/alert_tg_bot
username: postgres username: postgres
password: postgres password: postgres
cloud:
vault:
kv:
enabled: true
uri: https://vault.empayre.com:443
authentication: TOKEN
scheme: http
token: "123456"
info: info:
version: '@project.version@' version: '@project.version@'
@ -45,6 +53,6 @@ mayday:
networkTimeout: 5000 networkTimeout: 5000
bot: bot:
token: test token: ${botToken}
name: AlertBot name: AlertBot
chatId: test chatId: ${chatId}

View File

@ -13,6 +13,7 @@ import dev.vality.alerting.mayday.ParameterType;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
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.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@ -35,6 +36,7 @@ import static org.mockito.Mockito.*;
@Import(ExcludeDataSourceConfiguration.class) @Import(ExcludeDataSourceConfiguration.class)
@ContextConfiguration(classes = {CallbackHandler.class, MenuCallbackMapper.class, ParametersCallbackMapper.class, @ContextConfiguration(classes = {CallbackHandler.class, MenuCallbackMapper.class, ParametersCallbackMapper.class,
JsonMapper.class}) JsonMapper.class})
@SpringBootTest(properties = {"spring.config.location=classpath:/application.yml"})
public class CallbackHandlerTest { public class CallbackHandlerTest {
@MockBean @MockBean
private ParametersDao parametersDao; private ParametersDao parametersDao;

View File

@ -4,6 +4,7 @@ import dev.vality.alert.tg.bot.config.ExcludeDataSourceConfiguration;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit.jupiter.SpringExtension;
@ -18,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@Import(ExcludeDataSourceConfiguration.class) @Import(ExcludeDataSourceConfiguration.class)
@ContextConfiguration(classes = {MainMenuHandler.class}) @ContextConfiguration(classes = {MainMenuHandler.class})
@SpringBootTest(properties = {"spring.config.location=classpath:/application.yml"})
public class MainMenuHandlerTest { public class MainMenuHandlerTest {
@Autowired @Autowired

View File

@ -5,6 +5,7 @@ import dev.vality.alert.tg.bot.dao.StateDataDao;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
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.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@ -23,6 +24,7 @@ import static org.mockito.Mockito.verify;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@Import(ExcludeDataSourceConfiguration.class) @Import(ExcludeDataSourceConfiguration.class)
@ContextConfiguration(classes = {MessageHandler.class}) @ContextConfiguration(classes = {MessageHandler.class})
@SpringBootTest(properties = {"spring.config.location=classpath:/application.yml"})
public class MessageHandlerTest { public class MessageHandlerTest {
@MockBean @MockBean

View File

@ -9,6 +9,7 @@ import dev.vality.alert.tg.bot.service.MayDayService;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
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.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@ -27,6 +28,7 @@ import static org.mockito.Mockito.*;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@Import(ExcludeDataSourceConfiguration.class) @Import(ExcludeDataSourceConfiguration.class)
@ContextConfiguration(classes = {ReplyHandler.class, ReplyMessagesMapper.class, JsonMapper.class}) @ContextConfiguration(classes = {ReplyHandler.class, ReplyMessagesMapper.class, JsonMapper.class})
@SpringBootTest(properties = {"spring.config.location=classpath:/application.yml"})
public class ReplyHandlerTest { public class ReplyHandlerTest {
@MockBean @MockBean

View File

@ -8,6 +8,7 @@ import org.apache.thrift.TException;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
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.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@ -26,6 +27,7 @@ import static org.mockito.Mockito.*;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@Import(ExcludeDataSourceConfiguration.class) @Import(ExcludeDataSourceConfiguration.class)
@ContextConfiguration(classes = {MenuCallbackMapper.class}) @ContextConfiguration(classes = {MenuCallbackMapper.class})
@SpringBootTest(properties = {"spring.config.location=classpath:/application.yml"})
public class MenuCallbackMapperTest { public class MenuCallbackMapperTest {
@MockBean @MockBean

View File

@ -10,6 +10,7 @@ import dev.vality.alerting.mayday.ParameterType;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
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.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@ -28,6 +29,7 @@ import static org.mockito.Mockito.*;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@Import(ExcludeDataSourceConfiguration.class) @Import(ExcludeDataSourceConfiguration.class)
@ContextConfiguration(classes = {ParametersCallbackMapper.class, JsonMapper.class}) @ContextConfiguration(classes = {ParametersCallbackMapper.class, JsonMapper.class})
@SpringBootTest(properties = {"spring.config.location=classpath:/application.yml"})
public class ParametersCallbackMapperTest { public class ParametersCallbackMapperTest {
@MockBean @MockBean

View File

@ -10,6 +10,7 @@ import dev.vality.alerting.mayday.ParameterType;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
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.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@ -31,6 +32,7 @@ import static org.mockito.Mockito.*;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@Import(ExcludeDataSourceConfiguration.class) @Import(ExcludeDataSourceConfiguration.class)
@ContextConfiguration(classes = {ReplyMessagesMapper.class, JsonMapper.class}) @ContextConfiguration(classes = {ReplyMessagesMapper.class, JsonMapper.class})
@SpringBootTest(properties = {"spring.config.location=classpath:/application.yml"})
public class ReplyMessageMapperTest { public class ReplyMessageMapperTest {
@MockBean @MockBean