use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder in project tessera by ConsenSys.
the class AWSKeyVaultServiceFactory method getAwsSecretsManager.
private SecretsManagerClient getAwsSecretsManager(KeyVaultConfig keyVaultConfig) {
SecretsManagerClientBuilder secretsManagerClient = SecretsManagerClient.builder();
Optional<String> endpoint = keyVaultConfig.getProperty("endpoint");
endpoint.ifPresent(s -> {
final URI uri;
try {
uri = new URI(s);
} catch (URISyntaxException e) {
throw new ConfigException(new RuntimeException("Invalid AWS endpoint URL provided"));
}
if (Objects.isNull(uri.getScheme())) {
throw new ConfigException(new RuntimeException("Invalid AWS endpoint URL provided - no scheme"));
}
secretsManagerClient.endpointOverride(uri);
});
return secretsManagerClient.build();
}
use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder in project secrets-manager by bancolombia.
the class AWSSecretManagerConnector method buildClient.
private SecretsManagerClient buildClient() {
SecretsManagerClientBuilder clientBuilder = SecretsManagerClient.builder().credentialsProvider(getProviderChain()).region(region);
endpoint.ifPresent(clientBuilder::endpointOverride);
return clientBuilder.build();
}
use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder in project secrets-manager by bancolombia.
the class AWSSecretManagerConnectorTest method prepareClient.
private void prepareClient(String data) {
SecretsManagerClientBuilder clientBuilderMock = Mockito.mock(SecretsManagerClientBuilder.class);
SecretsManagerClient clientMock = Mockito.mock(SecretsManagerClient.class);
GetSecretValueResponse responseMock = GetSecretValueResponse.builder().secretString(data).build();
PowerMockito.mockStatic(SecretsManagerClient.class);
when(SecretsManagerClient.builder()).thenReturn(clientBuilderMock);
when(clientBuilderMock.credentialsProvider(any())).thenReturn(clientBuilderMock);
when(clientBuilderMock.region(any())).thenReturn(clientBuilderMock);
when(clientBuilderMock.build()).thenReturn(clientMock);
when(clientMock.getSecretValue(any(GetSecretValueRequest.class))).thenReturn(responseMock);
}
Aggregations