Search in sources :

Example 11 with AzureVaultKeyPair

use of com.quorum.tessera.config.keypairs.AzureVaultKeyPair in project tessera by ConsenSys.

the class AzureVaultKeyGeneratorTest method keysSavedInVaultWithProvidedVaultIdAndCorrectSuffix.

@Test
public void keysSavedInVaultWithProvidedVaultIdAndCorrectSuffix() {
    final String vaultId = "vaultId";
    final String pubVaultId = vaultId + "Pub";
    final String privVaultId = vaultId + "Key";
    final AzureVaultKeyPair result = azureVaultKeyGenerator.generate(vaultId, null, null);
    final ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
    verify(keyVaultService, times(2)).setSecret(captor.capture());
    List<Map> capturedArgs = captor.getAllValues();
    assertThat(capturedArgs).hasSize(2);
    Map<String, String> expectedDataPub = Map.of("secretName", pubVaultId, "secret", pub.encodeToBase64());
    Map<String, String> expectedDataPriv = Map.of("secretName", privVaultId, "secret", priv.encodeToBase64());
    assertThat(capturedArgs).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder(expectedDataPub, expectedDataPriv);
    verifyNoMoreInteractions(keyVaultService);
    final AzureVaultKeyPair expected = new AzureVaultKeyPair(pubVaultId, privVaultId, null, null);
    assertThat(result).isEqualToComparingFieldByFieldRecursively(expected);
}
Also used : AzureVaultKeyPair(com.quorum.tessera.config.keypairs.AzureVaultKeyPair) Map(java.util.Map) Test(org.junit.Test)

Aggregations

AzureVaultKeyPair (com.quorum.tessera.config.keypairs.AzureVaultKeyPair)11 Test (org.junit.Test)9 ConstraintViolation (jakarta.validation.ConstraintViolation)8 ConfigKeyPair (com.quorum.tessera.config.keypairs.ConfigKeyPair)2 KeyPair (com.quorum.tessera.encryption.KeyPair)2 DefaultKeyVaultConfig (com.quorum.tessera.config.DefaultKeyVaultConfig)1 KeyConfiguration (com.quorum.tessera.config.KeyConfiguration)1 KeyVaultConfig (com.quorum.tessera.config.KeyVaultConfig)1 AWSKeyPair (com.quorum.tessera.config.keypairs.AWSKeyPair)1 HashicorpVaultKeyPair (com.quorum.tessera.config.keypairs.HashicorpVaultKeyPair)1 KeyVaultService (com.quorum.tessera.key.vault.KeyVaultService)1 KeyVaultServiceFactory (com.quorum.tessera.key.vault.KeyVaultServiceFactory)1 UnsupportedCharsetException (java.nio.charset.UnsupportedCharsetException)1 Path (java.nio.file.Path)1 Map (java.util.Map)1