Code for [BAEL-455]

This commit is contained in:
Philippe 2018-09-12 22:51:27 -03:00
parent 80f92e0742
commit 38a995658e
7 changed files with 14 additions and 82 deletions

@ -1 +0,0 @@
Subproject commit f9673ef0c11c51b327555aaca61ee196935f998b

View File

@ -29,15 +29,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
@ -45,6 +37,11 @@
<artifactId>spring-cloud-starter-vault-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-vault-config-databases</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@ -59,6 +56,10 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
</dependencies>
<dependencyManagement>

View File

@ -1,58 +0,0 @@
package org.baeldung.spring.cloud.vaultsample.domain;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
@Entity
public class Account {
@Id
private Long id;
@NotNull
private String name;
@NotNull
private Long branchId;
@NotNull
private Long customerId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getBranchId() {
return branchId;
}
public void setBranchId(Long branchId) {
this.branchId = branchId;
}
public Long getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
}

View File

@ -1,10 +0,0 @@
package org.baeldung.spring.cloud.vaultsample.repository;
import org.baeldung.spring.cloud.vaultsample.domain.Account;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel="accounts", path="accounts")
public interface AccountRepository extends PagingAndSortingRepository<Account, Long> {
}

View File

@ -7,7 +7,6 @@ spring:
config:
order: -10
token: b93d1b0d-15b5-f69e-d311-352a65fa7bc8
ssl:
trust-store: classpath:/vault.jks
trust-store-password: changeit
@ -17,13 +16,14 @@ spring:
application-name: fakebank
kv:
enabled: true
enabled: false
backend: kv
application-name: fakebank
database:
enabled: true
role: fakebank-accounts-rw
# backend: database
# username-property: spring.datasource.username
# password-property: spring.datasource.password

View File

@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.vault.annotation.VaultPropertySource;
@RunWith(SpringRunner.class)
@SpringBootTest
@ -26,11 +25,12 @@ public class VaultSampleApplicationLiveTest {
@Autowired
DataSource datasource;
@Test
public void whenGenericBackendEnabled_thenEnvHasAccessToVaultSecrets() {
String fooValue = env.getProperty("foo");
assertEquals("bar", fooValue);
assertEquals("test-bar", fooValue);
}

View File

@ -1,3 +1,3 @@
#spring.cloud.vault.token=b93d1b0d-15b5-f69e-d311-352a65fa7bc8
spring.cloud.vault.token=b93d1b0d-15b5-f69e-d311-352a65fa7bc8
logging.level.org.springframework=INFO