use of com.quorum.tessera.key.vault.VaultSecretNotFoundException in project tessera by ConsenSys.
the class AzureKeyVaultService method getSecret.
@Override
public String getSecret(Map<String, String> azureGetSecretData) {
final String secretName = azureGetSecretData.get(SECRET_NAME_KEY);
final String secretVersion = azureGetSecretData.get(SECRET_VERSION_KEY);
final KeyVaultSecret secret;
try {
LOGGER.debug("SecretName : {} , SecretVersion: {}", secretName, secretVersion);
secret = secretClient.getSecret(secretName, secretVersion);
LOGGER.debug("secret.id {}", secret.getId());
} catch (ResourceNotFoundException e) {
throw new VaultSecretNotFoundException("Azure Key Vault secret " + secretName + " was not found in vault " + secretClient.getVaultUrl());
}
return secret.getValue();
}
use of com.quorum.tessera.key.vault.VaultSecretNotFoundException in project tessera by ConsenSys.
the class AWSKeyVaultServiceTest method getSecretSecretManagerRerurnsNull.
@Test
public void getSecretSecretManagerRerurnsNull() {
String secretName = "name";
Map<String, String> getSecretData = Map.of(AWSKeyVaultService.SECRET_NAME_KEY, secretName);
GetSecretValueResponse secretValueResponse = null;
when(secretsManager.getSecretValue(any(GetSecretValueRequest.class))).thenReturn(secretValueResponse);
try {
keyVaultService.getSecret(getSecretData);
failBecauseExceptionWasNotThrown(VaultSecretNotFoundException.class);
} catch (VaultSecretNotFoundException vaultSecretNotFoundException) {
verify(secretsManager).getSecretValue(any(GetSecretValueRequest.class));
assertThat(vaultSecretNotFoundException).hasMessage("The requested secret '" + secretName + "' was not found in AWS Secrets Manager");
}
}
use of com.quorum.tessera.key.vault.VaultSecretNotFoundException in project tessera by ConsenSys.
the class AWSKeyVaultService method getSecret.
@Override
public String getSecret(Map<String, String> getSecretData) {
final String secretName = getSecretData.get(SECRET_NAME_KEY);
GetSecretValueRequest getSecretValueRequest = GetSecretValueRequest.builder().secretId(secretName).build();
GetSecretValueResponse secretValueResponse;
try {
secretValueResponse = secretsManager.getSecretValue(getSecretValueRequest);
} catch (ResourceNotFoundException e) {
throw new VaultSecretNotFoundException("The requested secret '" + secretName + "' was not found in AWS Secrets Manager");
} catch (InvalidRequestException | InvalidParameterException e) {
throw new AWSSecretsManagerException(e);
}
if (secretValueResponse != null && secretValueResponse.secretString() != null) {
return secretValueResponse.secretString();
}
throw new VaultSecretNotFoundException("The requested secret '" + secretName + "' was not found in AWS Secrets Manager");
}
Aggregations