Search in sources :

Example 1 with HashicorpKeyVaultConfig

use of com.quorum.tessera.config.HashicorpKeyVaultConfig in project tessera by ConsenSys.

the class HashicorpKeyVaultHandlerTest method handle.

@Test
public void handle() {
    final KeyVaultConfigOptions keyVaultConfigOptions = mock(KeyVaultConfigOptions.class);
    final String vaultUrl = "vaultUrl";
    final String providedApprolePath = "providedApprolePath";
    final Path tlsKeystorePath = mock(Path.class);
    final Path tlsTrustStorePath = mock(Path.class);
    when(keyVaultConfigOptions.getVaultUrl()).thenReturn(vaultUrl);
    when(keyVaultConfigOptions.getHashicorpApprolePath()).thenReturn(providedApprolePath);
    when(keyVaultConfigOptions.getHashicorpTlsKeystore()).thenReturn(tlsKeystorePath);
    when(keyVaultConfigOptions.getHashicorpTlsTruststore()).thenReturn(tlsTrustStorePath);
    HashicorpKeyVaultConfig result = (HashicorpKeyVaultConfig) keyVaultHandler.handle(keyVaultConfigOptions);
    assertThat(result).isNotNull();
    assertThat(result.getApprolePath()).isEqualTo(providedApprolePath);
    assertThat(result.getUrl()).isEqualTo(vaultUrl);
    assertThat(result.getTlsKeyStorePath()).isEqualTo(tlsKeystorePath);
    assertThat(result.getTlsTrustStorePath()).isEqualTo(tlsTrustStorePath);
    verify(keyVaultConfigOptions).getVaultUrl();
    verify(keyVaultConfigOptions).getHashicorpApprolePath();
    verify(keyVaultConfigOptions).getHashicorpTlsKeystore();
    verify(keyVaultConfigOptions).getHashicorpTlsTruststore();
    verifyNoMoreInteractions(keyVaultConfigOptions);
}
Also used : Path(java.nio.file.Path) HashicorpKeyVaultConfig(com.quorum.tessera.config.HashicorpKeyVaultConfig) Test(org.junit.Test)

Example 2 with HashicorpKeyVaultConfig

use of com.quorum.tessera.config.HashicorpKeyVaultConfig in project tessera by ConsenSys.

the class HashicorpKeyVaultHandlerTest method handleEmptyOptions.

@Test
public void handleEmptyOptions() {
    KeyVaultConfigOptions keyVaultConfigOptions = mock(KeyVaultConfigOptions.class);
    HashicorpKeyVaultConfig result = (HashicorpKeyVaultConfig) keyVaultHandler.handle(keyVaultConfigOptions);
    assertThat(result).isNotNull();
    assertThat(result.getApprolePath()).isEqualTo("approle");
    assertThat(result.getUrl()).isNull();
    assertThat(result.getTlsKeyStorePath()).isNull();
    assertThat(result.getTlsTrustStorePath()).isNull();
    verify(keyVaultConfigOptions).getVaultUrl();
    verify(keyVaultConfigOptions).getHashicorpApprolePath();
    verify(keyVaultConfigOptions).getHashicorpTlsKeystore();
    verify(keyVaultConfigOptions).getHashicorpTlsTruststore();
    verifyNoMoreInteractions(keyVaultConfigOptions);
}
Also used : HashicorpKeyVaultConfig(com.quorum.tessera.config.HashicorpKeyVaultConfig) Test(org.junit.Test)

Aggregations

HashicorpKeyVaultConfig (com.quorum.tessera.config.HashicorpKeyVaultConfig)2 Test (org.junit.Test)2 Path (java.nio.file.Path)1