Test: also run shield with http input integration test
Original commit: elastic/x-pack-elasticsearch@6c2dbc75e1
This commit is contained in:
parent
3a37ebca41
commit
54380478e5
|
@ -14,6 +14,7 @@ import org.elasticsearch.watcher.client.WatchSourceBuilder;
|
||||||
import org.elasticsearch.watcher.client.WatcherClient;
|
import org.elasticsearch.watcher.client.WatcherClient;
|
||||||
import org.elasticsearch.watcher.history.HistoryStore;
|
import org.elasticsearch.watcher.history.HistoryStore;
|
||||||
import org.elasticsearch.watcher.input.http.HttpInput;
|
import org.elasticsearch.watcher.input.http.HttpInput;
|
||||||
|
import org.elasticsearch.watcher.support.http.auth.BasicAuth;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
|
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
|
||||||
import org.elasticsearch.watcher.support.template.ScriptTemplate;
|
import org.elasticsearch.watcher.support.template.ScriptTemplate;
|
||||||
import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests;
|
import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests;
|
||||||
|
@ -48,26 +49,23 @@ public class HttpInputIntegrationTest extends AbstractWatcherIntegrationTests {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean shieldEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHttpInput() throws Exception {
|
public void testHttpInput() throws Exception {
|
||||||
ScriptServiceProxy sc = scriptService();
|
ScriptServiceProxy sc = scriptService();
|
||||||
client().prepareIndex("index", "type", "id").setSource("{}").setRefresh(true).get();
|
client().prepareIndex("index", "type", "id").setSource("{}").setRefresh(true).get();
|
||||||
|
|
||||||
InetSocketAddress address = internalTestCluster().httpAddresses()[0];
|
InetSocketAddress address = internalTestCluster().httpAddresses()[0];
|
||||||
String body = jsonBuilder().startObject().field("size", 1).endObject().string();
|
HttpInput.SourceBuilder input = httpInput()
|
||||||
|
.setHost(address.getHostName())
|
||||||
|
.setPort(address.getPort())
|
||||||
|
.setPath(new ScriptTemplate(sc, "/index/_search"))
|
||||||
|
.setBody(new ScriptTemplate(sc, jsonBuilder().startObject().field("size", 1).endObject().string()));
|
||||||
|
if (shieldEnabled()) {
|
||||||
|
input.setAuth(new BasicAuth("test", "changeme"));
|
||||||
|
}
|
||||||
WatchSourceBuilder source = watchSourceBuilder()
|
WatchSourceBuilder source = watchSourceBuilder()
|
||||||
.trigger(TriggerBuilders.schedule(interval("5s")))
|
.trigger(TriggerBuilders.schedule(interval("5s")))
|
||||||
.input(httpInput()
|
.input(input)
|
||||||
.setHost(address.getHostName())
|
|
||||||
.setPort(address.getPort())
|
|
||||||
.setPath(new ScriptTemplate(sc, "/index/_search"))
|
|
||||||
.setBody(new ScriptTemplate(sc, body))
|
|
||||||
)
|
|
||||||
.condition(scriptCondition("ctx.payload.hits.total == 1"))
|
.condition(scriptCondition("ctx.payload.hits.total == 1"))
|
||||||
.addAction(indexAction("idx", "action"));
|
.addAction(indexAction("idx", "action"));
|
||||||
watcherClient().preparePutWatch("_name")
|
watcherClient().preparePutWatch("_name")
|
||||||
|
@ -100,6 +98,9 @@ public class HttpInputIntegrationTest extends AbstractWatcherIntegrationTests {
|
||||||
.setPath(new ScriptTemplate(sc, "/idx/_search"))
|
.setPath(new ScriptTemplate(sc, "/idx/_search"))
|
||||||
.setBody(new ScriptTemplate(sc, body))
|
.setBody(new ScriptTemplate(sc, body))
|
||||||
.addExtractKey("hits.total");
|
.addExtractKey("hits.total");
|
||||||
|
if (shieldEnabled()) {
|
||||||
|
httpInputBuilder.setAuth(new BasicAuth("test", "changeme"));
|
||||||
|
}
|
||||||
|
|
||||||
watcherClient.preparePutWatch("_name1")
|
watcherClient.preparePutWatch("_name1")
|
||||||
.source(watchSourceBuilder()
|
.source(watchSourceBuilder()
|
||||||
|
|
Loading…
Reference in New Issue