use of com.hazelcast.jet.elastic.CommonElasticSinksTest.TestItem in project hazelcast by hazelcast.
the class AuthElasticSinksTest method given_clientWithWrongPassword_whenWriteToElasticSink_thenFailWithAuthenticationException.
@Test
public void given_clientWithWrongPassword_whenWriteToElasticSink_thenFailWithAuthenticationException() {
ElasticsearchContainer container = ElasticSupport.secureElastic.get();
String containerIp = container.getContainerIpAddress();
Integer port = container.getMappedPort(PORT);
Sink<TestItem> elasticSink = new ElasticSinkBuilder<>().clientFn(() -> client("elastic", "WrongPassword", containerIp, port)).bulkRequestFn(() -> new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE)).mapToRequestFn((TestItem item) -> new IndexRequest("my-index").source(item.asMap())).retries(0).build();
Pipeline p = Pipeline.create();
p.readFrom(TestSources.items(new TestItem("id", "Frantisek"))).writeTo(elasticSink);
assertThatThrownBy(() -> submitJob(p)).hasRootCauseInstanceOf(ElasticsearchStatusException.class).hasStackTraceContaining("unable to authenticate user [elastic]");
}
use of com.hazelcast.jet.elastic.CommonElasticSinksTest.TestItem in project hazelcast by hazelcast.
the class AuthElasticSinksTest method given_authenticatedClient_whenWriteToElasticSink_thenFinishSuccessfully.
@Test
public void given_authenticatedClient_whenWriteToElasticSink_thenFinishSuccessfully() throws IOException {
Sink<TestItem> elasticSink = new ElasticSinkBuilder<>().clientFn(elasticClientSupplier()).bulkRequestFn(() -> new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE)).mapToRequestFn((TestItem item) -> new IndexRequest("my-index").source(item.asMap())).build();
Pipeline p = Pipeline.create();
p.readFrom(TestSources.items(new TestItem("id", "Frantisek"))).writeTo(elasticSink);
submitJob(p);
assertSingleDocument();
}
use of com.hazelcast.jet.elastic.CommonElasticSinksTest.TestItem in project hazelcast by hazelcast.
the class AuthElasticSinksTest method given_clientWithoutAuthentication_whenWriteToElasticSink_thenFailWithAuthenticationException.
@Test
public void given_clientWithoutAuthentication_whenWriteToElasticSink_thenFailWithAuthenticationException() {
ElasticsearchContainer container = ElasticSupport.secureElastic.get();
String containerIp = container.getContainerIpAddress();
Integer port = container.getMappedPort(PORT);
Sink<TestItem> elasticSink = new ElasticSinkBuilder<>().clientFn(() -> client(containerIp, port)).bulkRequestFn(() -> new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE)).mapToRequestFn((TestItem item) -> new IndexRequest("my-index").source(item.asMap())).retries(0).build();
Pipeline p = Pipeline.create();
p.readFrom(TestSources.items(new TestItem("id", "Frantisek"))).writeTo(elasticSink);
assertThatThrownBy(() -> submitJob(p)).hasRootCauseInstanceOf(ElasticsearchStatusException.class).hasStackTraceContaining("missing authentication credentials");
}
Aggregations