Skip to content

Commit be75f69

Browse files
committed
Added tests
1 parent ac9c18b commit be75f69

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

src/test/java/io/github/jopenlibs/vault/api/LogicalIT.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.github.jopenlibs.vault.Vault;
44
import io.github.jopenlibs.vault.VaultConfig;
55
import io.github.jopenlibs.vault.VaultException;
6+
import io.github.jopenlibs.vault.api.Logical.logicalOperations;
67
import io.github.jopenlibs.vault.response.AuthResponse;
78
import io.github.jopenlibs.vault.response.DataMetadata;
89
import io.github.jopenlibs.vault.response.LogicalResponse;
@@ -306,6 +307,43 @@ public void testList() throws VaultException {
306307
assertTrue(keys.contains("hello"));
307308
}
308309

310+
/**
311+
* Write a secret, and then verify that its key shows up in the list, returning their subkeys
312+
* when we use KV Engine version 2.
313+
*
314+
* @throws VaultException On error.
315+
*/
316+
@Test
317+
public void testListSubKeys() throws VaultException {
318+
final Vault vault = container.getRootVault();
319+
final Map<String, Object> testMap = Map.of("value", "world", "test", "done");
320+
321+
vault.logical().write("secret/hello", testMap);
322+
final List<String> keys = vault.logical()
323+
.list("secret/hello", logicalOperations.listSubKeys).getListSubkeys();
324+
assertTrue(keys.contains("test"));
325+
assertTrue(keys.contains("value"));
326+
}
327+
328+
/**
329+
* Write a secret, and then verify that its key shows up in the list, returning their subkeys
330+
* when we use KV Engine version 2.
331+
*
332+
* @throws VaultException On error.
333+
*/
334+
@Test
335+
public void testListSubKeysV1() throws VaultException {
336+
final Vault vault = container.getRootVaultWithCustomVaultConfig(
337+
new VaultConfig().engineVersion(1));
338+
final Map<String, Object> testMap = Map.of("value", "world");
339+
340+
vault.logical().write("secret/hello", testMap);
341+
final List<String> keys = vault.logical()
342+
.list("secret/hello", logicalOperations.listSubKeys).getListSubkeys();
343+
assertTrue(keys.contains("value"));
344+
}
345+
346+
309347
/**
310348
* Write a secret, and then verify that its key shows up in the list, using KV Engine version
311349
* 1.

0 commit comments

Comments
 (0)