From 4baf5bc7f3e6142a911b38cbbe2f757320bf9c61 Mon Sep 17 00:00:00 2001 From: "f.shimich" Date: Fri, 26 Jul 2024 11:56:46 +0300 Subject: [PATCH] What? --- .../common/secret/VaultSecretServiceTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/test/java/dev/vality/adapter/common/secret/VaultSecretServiceTest.java b/src/test/java/dev/vality/adapter/common/secret/VaultSecretServiceTest.java index 7c5d790..f546a3c 100644 --- a/src/test/java/dev/vality/adapter/common/secret/VaultSecretServiceTest.java +++ b/src/test/java/dev/vality/adapter/common/secret/VaultSecretServiceTest.java @@ -123,6 +123,45 @@ public class VaultSecretServiceTest { } + @Test + void writeMultipleSecretAndReadCase1() { + SecretObj secretObj1 = new SecretObj(TEST_TOKEN_PATH, Map.of("test1", "value1")); + vaultService.writeSecret(SERVICE_NAME, secretObj1); + + SecretObj secretObj2 = new SecretObj(TEST_TOKEN_PATH, Map.of( + "test2", "value2", + "test1", "value1" + )); + vaultService.writeSecret(SERVICE_NAME, secretObj2); + + var secrets = vaultService.getVersionSecrets(SERVICE_NAME, TEST_TOKEN_PATH); + + assertNotNull(secrets); + assertEquals("value2", secrets.getSecretes().get("test2").getValue()); + assertEquals("value1", secrets.getSecretes().get("test1").getValue()); + + assertEquals("value2", vaultService.getSecret(SERVICE_NAME, new SecretRef(TEST_TOKEN_PATH, "test2")).getValue()); + assertEquals("value1", vaultService.getSecret(SERVICE_NAME, new SecretRef(TEST_TOKEN_PATH, "test1")).getValue()); + } + + @Test + void writeMultipleSecretAndReadCase2() { + SecretObj secretObj1 = new SecretObj(TEST_TOKEN_PATH, Map.of("test1", "value1")); + vaultService.writeSecret(SERVICE_NAME, secretObj1); + + SecretObj secretObj2 = new SecretObj(TEST_TOKEN_PATH, Map.of("test2", "value2")); + vaultService.writeSecret(SERVICE_NAME, secretObj2); + + var secrets = vaultService.getVersionSecrets(SERVICE_NAME, TEST_TOKEN_PATH); + + assertNotNull(secrets); + assertEquals("value2", secrets.getSecretes().get("test2").getValue()); + assertEquals("value1", secrets.getSecretes().get("test1").getValue()); + + assertEquals("value2", vaultService.getSecret(SERVICE_NAME, new SecretRef(TEST_TOKEN_PATH, "test2")).getValue()); + assertEquals("value1", vaultService.getSecret(SERVICE_NAME, new SecretRef(TEST_TOKEN_PATH, "test1")).getValue()); + } + @Test void writeMultipleSecret() { SecretObj secretObj = new SecretObj(