Search in sources :

Example 6 with KeyVaultConfig

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

the class AzureKeyVaultHandlerTest method handleWithNullConfigOptions.

@Test
public void handleWithNullConfigOptions() {
    KeyVaultConfig keyVaultConfig = azureKeyVaultHandler.handle(null);
    assertThat(keyVaultConfig).isNotNull().isExactlyInstanceOf(AzureKeyVaultConfig.class);
    assertThat(keyVaultConfig.getProperties()).isEmpty();
}
Also used : AzureKeyVaultConfig(com.quorum.tessera.config.AzureKeyVaultConfig) KeyVaultConfig(com.quorum.tessera.config.KeyVaultConfig) Test(org.junit.Test)

Example 7 with KeyVaultConfig

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

the class HashicorpKeyVaultHandlerTest method handleNullOptions.

@Test
public void handleNullOptions() {
    KeyVaultConfig result = keyVaultHandler.handle(null);
    assertThat(result).isNotNull().isExactlyInstanceOf(HashicorpKeyVaultConfig.class);
}
Also used : KeyVaultConfig(com.quorum.tessera.config.KeyVaultConfig) HashicorpKeyVaultConfig(com.quorum.tessera.config.HashicorpKeyVaultConfig) Test(org.junit.Test)

Example 8 with KeyVaultConfig

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

the class AwsKeyVaultHandlerTest method handleNullConfig.

@Test
public void handleNullConfig() {
    KeyVaultConfig result = keyVaultHandler.handle(null);
    assertThat(result).isNotNull().isExactlyInstanceOf(DefaultKeyVaultConfig.class);
    assertThat(result.getKeyVaultType()).isEqualTo(KeyVaultType.AWS);
    assertThat(result.getProperty("endpoint")).isNotPresent();
}
Also used : DefaultKeyVaultConfig(com.quorum.tessera.config.DefaultKeyVaultConfig) KeyVaultConfig(com.quorum.tessera.config.KeyVaultConfig) Test(org.junit.Test)

Example 9 with KeyVaultConfig

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

the class AwsKeyVaultHandlerTest method handleWithVaultUrl.

@Test
public void handleWithVaultUrl() {
    KeyVaultConfigOptions keyVaultConfig = mock(KeyVaultConfigOptions.class);
    String endpointUrl = "http://someurl.com";
    when(keyVaultConfig.getVaultUrl()).thenReturn(endpointUrl);
    KeyVaultConfig result = keyVaultHandler.handle(keyVaultConfig);
    assertThat(result).isNotNull().isExactlyInstanceOf(DefaultKeyVaultConfig.class);
    assertThat(result.getKeyVaultType()).isEqualTo(KeyVaultType.AWS);
    assertThat(result.getProperty("endpoint")).contains(endpointUrl);
}
Also used : DefaultKeyVaultConfig(com.quorum.tessera.config.DefaultKeyVaultConfig) KeyVaultConfig(com.quorum.tessera.config.KeyVaultConfig) Test(org.junit.Test)

Example 10 with KeyVaultConfig

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

the class HashicorpKeyVaultServiceFactoryUtilTest method configureClientAuthenticationIfAllEnvVarsSetThenAppRoleMethod.

@Test
public void configureClientAuthenticationIfAllEnvVarsSetThenAppRoleMethod() {
    KeyVaultConfig keyVaultConfig = mock(KeyVaultConfig.class);
    EnvironmentVariableProvider envProvider = mock(EnvironmentVariableProvider.class);
    ClientHttpRequestFactory clientHttpRequestFactory = mock(ClientHttpRequestFactory.class);
    VaultEndpoint vaultEndpoint = mock(VaultEndpoint.class);
    when(envProvider.getEnv(HASHICORP_ROLE_ID)).thenReturn("role-id");
    when(envProvider.getEnv(HASHICORP_SECRET_ID)).thenReturn("secret-id");
    when(envProvider.getEnv(HASHICORP_TOKEN)).thenReturn("token");
    when(keyVaultConfig.getProperty("approlePath")).thenReturn(Optional.of("approle"));
    ClientAuthentication result = util.configureClientAuthentication(keyVaultConfig, envProvider, clientHttpRequestFactory, vaultEndpoint);
    assertThat(result).isInstanceOf(AppRoleAuthentication.class);
}
Also used : EnvironmentVariableProvider(com.quorum.tessera.config.util.EnvironmentVariableProvider) KeyVaultConfig(com.quorum.tessera.config.KeyVaultConfig) ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) OkHttp3ClientHttpRequestFactory(org.springframework.http.client.OkHttp3ClientHttpRequestFactory) ClientAuthentication(org.springframework.vault.authentication.ClientAuthentication) VaultEndpoint(org.springframework.vault.client.VaultEndpoint) Test(org.junit.Test)

Aggregations

KeyVaultConfig (com.quorum.tessera.config.KeyVaultConfig)15 Test (org.junit.Test)14 EnvironmentVariableProvider (com.quorum.tessera.config.util.EnvironmentVariableProvider)10 ClientHttpRequestFactory (org.springframework.http.client.ClientHttpRequestFactory)6 OkHttp3ClientHttpRequestFactory (org.springframework.http.client.OkHttp3ClientHttpRequestFactory)6 VaultEndpoint (org.springframework.vault.client.VaultEndpoint)6 DefaultKeyVaultConfig (com.quorum.tessera.config.DefaultKeyVaultConfig)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 ClientAuthentication (org.springframework.vault.authentication.ClientAuthentication)3 SslConfiguration (org.springframework.vault.support.SslConfiguration)3 Path (java.nio.file.Path)2 HttpLogDetailLevel (com.azure.core.http.policy.HttpLogDetailLevel)1 HttpLogOptions (com.azure.core.http.policy.HttpLogOptions)1 DefaultAzureCredentialBuilder (com.azure.identity.DefaultAzureCredentialBuilder)1 SecretClient (com.azure.security.keyvault.secrets.SecretClient)1 SecretClientBuilder (com.azure.security.keyvault.secrets.SecretClientBuilder)1 AzureKeyVaultConfig (com.quorum.tessera.config.AzureKeyVaultConfig)1 Config (com.quorum.tessera.config.Config)1 ConfigException (com.quorum.tessera.config.ConfigException)1 HashicorpKeyVaultConfig (com.quorum.tessera.config.HashicorpKeyVaultConfig)1