Search in sources :

Example 1 with AWSProxyConfig

use of org.apache.druid.common.aws.AWSProxyConfig in project druid by druid-io.

the class TestAWSCredentialsProvider method testWithFileSessionCredentials.

@Test
public void testWithFileSessionCredentials() throws IOException {
    AWSCredentialsConfig config = EasyMock.createMock(AWSCredentialsConfig.class);
    EasyMock.expect(config.getAccessKey()).andReturn(new DefaultPasswordProvider(""));
    EasyMock.expect(config.getSecretKey()).andReturn(new DefaultPasswordProvider(""));
    File file = folder.newFile();
    try (BufferedWriter out = Files.newWriter(file, StandardCharsets.UTF_8)) {
        out.write("sessionToken=sessionTokenSample\nsecretKey=secretKeySample\naccessKey=accessKeySample\n");
    }
    EasyMock.expect(config.getFileSessionCredentials()).andReturn(file.getAbsolutePath()).atLeastOnce();
    EasyMock.replay(config);
    AWSCredentialsProvider provider = awsModule.getAWSCredentialsProvider(config);
    AWSCredentials credentials = provider.getCredentials();
    Assert.assertTrue(credentials instanceof AWSSessionCredentials);
    AWSSessionCredentials sessionCredentials = (AWSSessionCredentials) credentials;
    Assert.assertEquals("accessKeySample", sessionCredentials.getAWSAccessKeyId());
    Assert.assertEquals("secretKeySample", sessionCredentials.getAWSSecretKey());
    Assert.assertEquals("sessionTokenSample", sessionCredentials.getSessionToken());
    // try to create
    ServerSideEncryptingAmazonS3.Builder amazonS3ClientBuilder = s3Module.getServerSideEncryptingAmazonS3Builder(provider, new AWSProxyConfig(), new AWSEndpointConfig(), new AWSClientConfig(), new S3StorageConfig(new NoopServerSideEncryption()));
    s3Module.getAmazonS3Client(amazonS3ClientBuilder);
}
Also used : AWSClientConfig(org.apache.druid.common.aws.AWSClientConfig) AWSCredentialsConfig(org.apache.druid.common.aws.AWSCredentialsConfig) AWSCredentials(com.amazonaws.auth.AWSCredentials) BufferedWriter(java.io.BufferedWriter) AWSEndpointConfig(org.apache.druid.common.aws.AWSEndpointConfig) AWSSessionCredentials(com.amazonaws.auth.AWSSessionCredentials) AWSProxyConfig(org.apache.druid.common.aws.AWSProxyConfig) DefaultPasswordProvider(org.apache.druid.metadata.DefaultPasswordProvider) File(java.io.File) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 2 with AWSProxyConfig

use of org.apache.druid.common.aws.AWSProxyConfig in project druid by druid-io.

the class TestAWSCredentialsProvider method testWithFixedAWSKeys.

@Test
public void testWithFixedAWSKeys() {
    AWSCredentialsConfig config = EasyMock.createMock(AWSCredentialsConfig.class);
    EasyMock.expect(config.getAccessKey()).andReturn(new DefaultPasswordProvider("accessKeySample")).atLeastOnce();
    EasyMock.expect(config.getSecretKey()).andReturn(new DefaultPasswordProvider("secretKeySample")).atLeastOnce();
    EasyMock.replay(config);
    AWSCredentialsProvider provider = awsModule.getAWSCredentialsProvider(config);
    AWSCredentials credentials = provider.getCredentials();
    Assert.assertEquals("accessKeySample", credentials.getAWSAccessKeyId());
    Assert.assertEquals("secretKeySample", credentials.getAWSSecretKey());
    // try to create
    ServerSideEncryptingAmazonS3.Builder amazonS3ClientBuilder = s3Module.getServerSideEncryptingAmazonS3Builder(provider, new AWSProxyConfig(), new AWSEndpointConfig(), new AWSClientConfig(), new S3StorageConfig(new NoopServerSideEncryption()));
    s3Module.getAmazonS3Client(amazonS3ClientBuilder);
}
Also used : AWSEndpointConfig(org.apache.druid.common.aws.AWSEndpointConfig) AWSProxyConfig(org.apache.druid.common.aws.AWSProxyConfig) AWSClientConfig(org.apache.druid.common.aws.AWSClientConfig) DefaultPasswordProvider(org.apache.druid.metadata.DefaultPasswordProvider) AWSCredentialsConfig(org.apache.druid.common.aws.AWSCredentialsConfig) AWSCredentials(com.amazonaws.auth.AWSCredentials) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Aggregations

AWSCredentials (com.amazonaws.auth.AWSCredentials)2 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)2 AWSClientConfig (org.apache.druid.common.aws.AWSClientConfig)2 AWSCredentialsConfig (org.apache.druid.common.aws.AWSCredentialsConfig)2 AWSEndpointConfig (org.apache.druid.common.aws.AWSEndpointConfig)2 AWSProxyConfig (org.apache.druid.common.aws.AWSProxyConfig)2 DefaultPasswordProvider (org.apache.druid.metadata.DefaultPasswordProvider)2 Test (org.junit.Test)2 AWSSessionCredentials (com.amazonaws.auth.AWSSessionCredentials)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1