use of org.apache.pulsar.io.core.SinkContext in project pulsar by apache.
the class KinesisSinkConfigTests method loadFromMapCredentialFromSecretTest.
@Test
public final void loadFromMapCredentialFromSecretTest() throws IOException {
Map<String, Object> map = new HashMap<String, Object>();
map.put("awsEndpoint", "https://some.endpoint.aws");
map.put("awsRegion", "us-east-1");
map.put("awsKinesisStreamName", "my-stream");
SinkContext sinkContext = Mockito.mock(SinkContext.class);
Mockito.when(sinkContext.getSecret("awsCredentialPluginParam")).thenReturn("{\"accessKey\":\"myKey\",\"secretKey\":\"my-Secret\"}");
KinesisSinkConfig config = IOConfigUtils.loadWithSecrets(map, KinesisSinkConfig.class, sinkContext);
assertNotNull(config);
assertEquals(config.getAwsEndpoint(), "https://some.endpoint.aws");
assertEquals(config.getAwsRegion(), "us-east-1");
assertEquals(config.getAwsKinesisStreamName(), "my-stream");
assertEquals(config.getAwsCredentialPluginParam(), "{\"accessKey\":\"myKey\",\"secretKey\":\"my-Secret\"}");
}
use of org.apache.pulsar.io.core.SinkContext in project pulsar-io-cloud-storage by streamnative.
the class ConnectorConfigTest method loadFromMapCredentialFromSecretTest.
@Test
public final void loadFromMapCredentialFromSecretTest() throws IOException {
Map<String, Object> config = new HashMap<>();
config.put("provider", "aws-s3");
config.put("bucket", "testbucket");
config.put("region", "localhost");
config.put("endpoint", "us-standard");
config.put("formatType", "avro");
config.put("partitionerType", "default");
config.put("timePartitionPattern", "yyyy-MM-dd");
config.put("timePartitionDuration", "2d");
config.put("batchSize", 10);
SinkContext sinkContext = Mockito.mock(SinkContext.class);
Mockito.when(sinkContext.getSecret("accessKeyId")).thenReturn("myKeyId");
Mockito.when(sinkContext.getSecret("secretAccessKey")).thenReturn("myAccessKey");
CloudStorageSinkConfig sinkConfig = IOConfigUtils.loadWithSecrets(config, CloudStorageSinkConfig.class, sinkContext);
Assert.assertNotNull(sinkConfig);
Assert.assertEquals(sinkConfig.getProvider(), "aws-s3");
Assert.assertEquals(sinkConfig.getBucket(), "testbucket");
Assert.assertEquals(sinkConfig.getSecretAccessKey(), "myAccessKey");
Assert.assertEquals(sinkConfig.getAccessKeyId(), "myKeyId");
}
Aggregations