Polishing
Add tests for write and delete. Closes gh-503 Closes gh-511
This commit is contained in:
@@ -7,7 +7,6 @@ sudo: required
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- VAULT_VER=0.6.0
|
||||
- VAULT_VER=0.6.5
|
||||
- VAULT_VER=0.7.0
|
||||
- VAULT_VER=0.7.3
|
||||
|
||||
@@ -30,6 +30,7 @@ import reactor.test.StepVerifier;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.vault.VaultException;
|
||||
import org.springframework.vault.util.IntegrationTestSupport;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -54,37 +55,31 @@ public class ReactiveVaultTemplateGenericIntegrationTests extends IntegrationTes
|
||||
@Test
|
||||
public void readShouldReturnExistingKey() {
|
||||
|
||||
StepVerifier.create(
|
||||
vaultOperations.write("secret/mykey",
|
||||
Collections.singletonMap("hello", "world"))).verifyComplete();
|
||||
StepVerifier.create(vaultOperations.write("secret/mykey",
|
||||
Collections.singletonMap("hello", "world"))).verifyComplete();
|
||||
|
||||
StepVerifier
|
||||
.create(vaultOperations.read("secret/mykey"))
|
||||
.consumeNextWith(
|
||||
actual -> assertThat(actual.getData()).containsEntry("hello",
|
||||
"world")).verifyComplete();
|
||||
StepVerifier.create(vaultOperations.read("secret/mykey")).consumeNextWith(
|
||||
actual -> assertThat(actual.getData()).containsEntry("hello", "world"))
|
||||
.verifyComplete();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readShouldReturnNestedPropertiesKey() throws IOException {
|
||||
|
||||
Map map = new ObjectMapper()
|
||||
.readValue(
|
||||
"{ \"hello.array[0]\":\"array-value0\", \"hello.array[1]\":\"array-value1\" }",
|
||||
Map.class);
|
||||
Map map = new ObjectMapper().readValue(
|
||||
"{ \"hello.array[0]\":\"array-value0\", \"hello.array[1]\":\"array-value1\" }",
|
||||
Map.class);
|
||||
|
||||
StepVerifier.create(vaultOperations.write("secret/mykey", map)).verifyComplete();
|
||||
|
||||
StepVerifier
|
||||
.create(vaultOperations.read("secret/mykey"))
|
||||
.consumeNextWith(
|
||||
actual -> {
|
||||
assertThat(actual.getData()).containsEntry("hello.array[0]",
|
||||
"array-value0");
|
||||
assertThat(actual.getData()).containsEntry("hello.array[1]",
|
||||
"array-value1");
|
||||
}).verifyComplete();
|
||||
StepVerifier.create(vaultOperations.read("secret/mykey"))
|
||||
.consumeNextWith(actual -> {
|
||||
assertThat(actual.getData()).containsEntry("hello.array[0]",
|
||||
"array-value0");
|
||||
assertThat(actual.getData()).containsEntry("hello.array[1]",
|
||||
"array-value1");
|
||||
}).verifyComplete();
|
||||
|
||||
}
|
||||
|
||||
@@ -126,12 +121,18 @@ public class ReactiveVaultTemplateGenericIntegrationTests extends IntegrationTes
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listShouldNotReturnAbsentKey() {
|
||||
|
||||
vaultOperations.list("foo").collectList().as(StepVerifier::create)
|
||||
.consumeNextWith(actual -> assertThat(actual).isEmpty()).verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listShouldReturnExistingKey() {
|
||||
|
||||
StepVerifier.create(
|
||||
vaultOperations.write("secret/mykey",
|
||||
Collections.singletonMap("hello", "world"))).verifyComplete();
|
||||
StepVerifier.create(vaultOperations.write("secret/mykey",
|
||||
Collections.singletonMap("hello", "world"))).verifyComplete();
|
||||
|
||||
StepVerifier.create(vaultOperations.list("secret").collectList())
|
||||
.consumeNextWith(actual -> assertThat(actual).contains("mykey"))
|
||||
@@ -141,9 +142,8 @@ public class ReactiveVaultTemplateGenericIntegrationTests extends IntegrationTes
|
||||
@Test
|
||||
public void deleteShouldRemoveKey() {
|
||||
|
||||
StepVerifier.create(
|
||||
vaultOperations.write("secret/mykey",
|
||||
Collections.singletonMap("hello", "world"))).verifyComplete();
|
||||
StepVerifier.create(vaultOperations.write("secret/mykey",
|
||||
Collections.singletonMap("hello", "world"))).verifyComplete();
|
||||
|
||||
StepVerifier.create(vaultOperations.delete("secret/mykey")).verifyComplete();
|
||||
|
||||
@@ -161,6 +161,20 @@ public class ReactiveVaultTemplateGenericIntegrationTests extends IntegrationTes
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteUnknownPathShouldFail() {
|
||||
|
||||
vaultOperations.delete("foobar").as(StepVerifier::create)
|
||||
.verifyError(VaultException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeUnknownPathShouldFail() {
|
||||
|
||||
vaultOperations.write("foobar").as(StepVerifier::create)
|
||||
.verifyError(VaultException.class);
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
String firstname;
|
||||
|
||||
@@ -122,6 +122,13 @@ public class VaultTemplateGenericIntegrationTests extends IntegrationTestSupport
|
||||
assertThat(keys).contains("mykey");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listShouldNotReturnAbsentKey() {
|
||||
|
||||
List<String> keys = vaultOperations.list("foo");
|
||||
assertThat(keys).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteShouldRemoveKey() throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user