diff --git a/.travis.yml b/.travis.yml index af347a8d..93cc0ce0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/spring-vault-core/src/test/java/org/springframework/vault/core/ReactiveVaultTemplateGenericIntegrationTests.java b/spring-vault-core/src/test/java/org/springframework/vault/core/ReactiveVaultTemplateGenericIntegrationTests.java index 940e0b77..67f5c822 100644 --- a/spring-vault-core/src/test/java/org/springframework/vault/core/ReactiveVaultTemplateGenericIntegrationTests.java +++ b/spring-vault-core/src/test/java/org/springframework/vault/core/ReactiveVaultTemplateGenericIntegrationTests.java @@ -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; diff --git a/spring-vault-core/src/test/java/org/springframework/vault/core/VaultTemplateGenericIntegrationTests.java b/spring-vault-core/src/test/java/org/springframework/vault/core/VaultTemplateGenericIntegrationTests.java index 3addf82a..1cb9126f 100644 --- a/spring-vault-core/src/test/java/org/springframework/vault/core/VaultTemplateGenericIntegrationTests.java +++ b/spring-vault-core/src/test/java/org/springframework/vault/core/VaultTemplateGenericIntegrationTests.java @@ -122,6 +122,13 @@ public class VaultTemplateGenericIntegrationTests extends IntegrationTestSupport assertThat(keys).contains("mykey"); } + @Test + public void listShouldNotReturnAbsentKey() { + + List keys = vaultOperations.list("foo"); + assertThat(keys).isEmpty(); + } + @Test public void deleteShouldRemoveKey() throws Exception {