use of org.testcontainers.elasticsearch.ElasticsearchContainer in project hazelcast by hazelcast.
the class AuthElasticSourcesTest method given_clientWithWrongPassword_whenReadFromElasticSource_thenFailWithAuthenticationException.
@Test
public void given_clientWithWrongPassword_whenReadFromElasticSource_thenFailWithAuthenticationException() {
ElasticsearchContainer container = ElasticSupport.secureElastic.get();
String containerIp = container.getContainerIpAddress();
Integer port = container.getMappedPort(PORT);
Pipeline p = Pipeline.create();
p.readFrom(elasticSource(() -> client("elastic", "WrongPassword", containerIp, port))).writeTo(Sinks.list(results));
assertThatThrownBy(() -> submitJob(p)).hasRootCauseInstanceOf(ResponseException.class).hasStackTraceContaining("unable to authenticate user [elastic]");
}
use of org.testcontainers.elasticsearch.ElasticsearchContainer in project beam by apache.
the class HadoopFormatIOElasticIT method setElasticsearchContainer.
private static void setElasticsearchContainer() throws IOException {
elasticsearch = new ElasticsearchContainer(DockerImageName.parse("docker.elastic.co/elasticsearch/elasticsearch").withTag("7.9.2"));
elasticsearch.start();
options.setElasticUserName("");
options.setElasticPassword("");
options.setElasticServerIp(elasticsearch.getContainerIpAddress());
options.setElasticServerPort(elasticsearch.getMappedPort(9200));
prepareElasticIndex();
}
use of org.testcontainers.elasticsearch.ElasticsearchContainer 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