Skip to content

Commit c182ec0

Browse files
authored
Merge pull request #4 from kmin4/feature/vault-integration-test
Feature/vault integration test
2 parents 231c590 + 2ba1807 commit c182ec0

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

oscka/simple-api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 231c59038194262c7898820f82043e676111c068

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.6.1</version>
8+
<version>3.1.1</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.example</groupId>
@@ -45,6 +45,11 @@
4545
<artifactId>spring-boot-starter-test</artifactId>
4646
<scope>test</scope>
4747
</dependency>
48+
<dependency>
49+
<groupId>org.springframework.cloud</groupId>
50+
<artifactId>spring-cloud-starter-vault-config</artifactId>
51+
<version>4.0.1</version>
52+
</dependency>
4853
</dependencies>
4954

5055
<build>

src/main/java/com/example/simpleapi/controller/SimpleApiController.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.springframework.web.bind.annotation.GetMapping;
77
import org.springframework.web.bind.annotation.RequestMapping;
88
import org.springframework.web.bind.annotation.RestController;
9+
import org.springframework.beans.factory.annotation.Value;
910

1011
import com.example.simpleapi.model.Simple;
1112

@@ -15,9 +16,14 @@
1516
@RequestMapping("/api")
1617
@Slf4j
1718
public class SimpleApiController {
19+
@Value("${password}")
20+
private String password;
21+
22+
@Value("${username}")
23+
private String username;
24+
1825
@GetMapping("/hello")
1926
public String hello() throws Exception {
20-
2127
log.info("==========simple-api hello world");
2228
return "hello world!!!";
2329

@@ -42,4 +48,12 @@ public String version() {
4248

4349
}
4450

51+
@GetMapping("/vault")
52+
public String vault() {
53+
log.info(username);
54+
log.info(password);
55+
return "username = "+username+"\npassword = "+password;
56+
57+
}
58+
4559
}

src/main/resources/config/application.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ app-info:
1515
version: '@project.version@'
1616
timestamp: '@app.build.timestamp@'
1717

18+
spring.cloud.vault:
19+
uri: http://192.168.56.20:8200 # vault 서버 주소
20+
token: hvs.CAESIIDNVNLB9sjwVQH_xv7KlkpI1036DSRFhlZYi5yJ9yncGh4KHGh2cy5TSVRqaVB4WmpZSVZpZWRpbjBBVjJvam8 # vault token
21+
connection-timeout: 5000
22+
read-timeout: 15000
23+
kv:
24+
backend: board-secret
25+
default-context: simple-api
26+
application-name: simple-api
27+
28+
spring.config.import: vault://
1829

1930
logging:
2031
level:

0 commit comments

Comments
 (0)