use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project aws-athena-query-federation by awslabs.
the class HiveRecordHandlerTest method setup.
@Before
public void setup() {
this.amazonS3 = Mockito.mock(AmazonS3.class);
this.secretsManager = Mockito.mock(AWSSecretsManager.class);
this.athena = Mockito.mock(AmazonAthena.class);
Mockito.when(this.secretsManager.getSecretValue(Mockito.eq(new GetSecretValueRequest().withSecretId("testSecret")))).thenReturn(new GetSecretValueResult().withSecretString("{\"username\": \"testUser\", \"password\": \"testPassword\"}"));
this.connection = Mockito.mock(Connection.class);
this.jdbcConnectionFactory = Mockito.mock(JdbcConnectionFactory.class);
Mockito.when(this.jdbcConnectionFactory.getConnection(Mockito.mock(JdbcCredentialProvider.class))).thenReturn(this.connection);
jdbcSplitQueryBuilder = new HiveQueryStringBuilder("`");
final DatabaseConnectionConfig databaseConnectionConfig = new DatabaseConnectionConfig("testCatalog", HiveConstants.HIVE_NAME, "hive2://jdbc:hive2://54.89.6.2:10000/authena;AuthMech=3;UID=hive;PWD=hive");
this.hiveRecordHandler = new HiveRecordHandler(databaseConnectionConfig, amazonS3, secretsManager, athena, jdbcConnectionFactory, jdbcSplitQueryBuilder);
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project aws-athena-query-federation by awslabs.
the class DataLakeGen2MetadataHandlerTest method setup.
@Before
public void setup() {
System.setProperty("aws.region", "us-east-1");
this.jdbcConnectionFactory = Mockito.mock(JdbcConnectionFactory.class, Mockito.RETURNS_DEEP_STUBS);
this.connection = Mockito.mock(Connection.class, Mockito.RETURNS_DEEP_STUBS);
logger.info(" this.connection.." + this.connection);
Mockito.when(this.jdbcConnectionFactory.getConnection(Mockito.any(JdbcCredentialProvider.class))).thenReturn(this.connection);
this.secretsManager = Mockito.mock(AWSSecretsManager.class);
this.athena = Mockito.mock(AmazonAthena.class);
Mockito.when(this.secretsManager.getSecretValue(Mockito.eq(new GetSecretValueRequest().withSecretId("testSecret")))).thenReturn(new GetSecretValueResult().withSecretString("{\"user\": \"testUser\", \"password\": \"testPassword\"}"));
this.dataLakeGen2MetadataHandler = new DataLakeGen2MetadataHandler(databaseConnectionConfig, this.secretsManager, this.athena, this.jdbcConnectionFactory);
this.federatedIdentity = Mockito.mock(FederatedIdentity.class);
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project spring-cloud-aws by awspring.
the class AwsSecretsManagerPropertySourceTest method shouldParseSecretValue.
@Test
void shouldParseSecretValue() {
GetSecretValueResult secretValueResult = new GetSecretValueResult();
secretValueResult.setSecretString("{\"key1\": \"value1\", \"key2\": \"value2\"}");
when(client.getSecretValue(any(GetSecretValueRequest.class))).thenReturn(secretValueResult);
propertySource.init();
assertThat(propertySource.getPropertyNames()).containsExactly("key1", "key2");
assertThat(propertySource.getProperty("key1")).isEqualTo("value1");
assertThat(propertySource.getProperty("key2")).isEqualTo("value2");
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project spring-cloud-aws by awspring.
the class AwsSecretsManagerPropertySourceLocatorTest method contextExpectSpecificOrderAndEmptyPrefix.
@Test
void contextExpectSpecificOrderAndEmptyPrefix() {
AwsSecretsManagerProperties properties = new AwsSecretsManagerPropertiesBuilder().withDefaultContext("application").withPrefix("").withName("messaging-service").build();
GetSecretValueResult secretValueResult = new GetSecretValueResult();
secretValueResult.setSecretString("{\"key1\": \"value1\", \"key2\": \"value2\"}");
when(smClient.getSecretValue(any(GetSecretValueRequest.class))).thenReturn(secretValueResult);
AwsSecretsManagerPropertySourceLocator locator = new AwsSecretsManagerPropertySourceLocator(smClient, properties);
env.setActiveProfiles("test");
locator.locate(env);
List<String> contextToBeTested = new ArrayList<>(locator.getContexts());
assertThat(contextToBeTested.get(0)).isEqualTo("/messaging-service_test");
assertThat(contextToBeTested.get(1)).isEqualTo("/messaging-service");
assertThat(contextToBeTested.get(2)).isEqualTo("/application_test");
assertThat(contextToBeTested.get(3)).isEqualTo("/application");
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project spring-cloud-aws by awspring.
the class AwsSecretsManagerPropertySourceLocatorTest method locate_nameNotSpecifiedInConstructor_returnsPropertySourceWithDefaultName.
@Test
void locate_nameNotSpecifiedInConstructor_returnsPropertySourceWithDefaultName() {
GetSecretValueResult secretValueResult = new GetSecretValueResult();
secretValueResult.setSecretString("{\"key1\": \"value1\", \"key2\": \"value2\"}");
when(smClient.getSecretValue(any(GetSecretValueRequest.class))).thenReturn(secretValueResult);
AwsSecretsManagerProperties properties = new AwsSecretsManagerProperties();
AwsSecretsManagerPropertySourceLocator locator = new AwsSecretsManagerPropertySourceLocator(smClient, properties);
PropertySource propertySource = locator.locate(env);
assertThat(propertySource.getName()).isEqualTo("aws-secrets-manager");
}
Aggregations