Merge branch 'master' into feature/shield-ui
Original commit: elastic/x-pack-elasticsearch@a512b397a7
This commit is contained in:
commit
124d0e0eee
|
@ -16,7 +16,7 @@ import org.elasticsearch.xpack.watcher.condition.script.ExecutableScriptConditio
|
|||
import org.elasticsearch.xpack.watcher.condition.script.ScriptCondition;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.Script;
|
||||
import org.elasticsearch.xpack.watcher.support.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
import org.junit.AfterClass;
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.elasticsearch.script.ScriptSettings;
|
|||
import org.elasticsearch.script.groovy.GroovyScriptEngineService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||
import org.elasticsearch.xpack.watcher.support.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
import org.junit.Ignore;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.elasticsearch.xpack.watcher.condition.script.ExecutableScriptConditio
|
|||
import org.elasticsearch.xpack.watcher.condition.script.ScriptCondition;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.Script;
|
||||
import org.elasticsearch.xpack.watcher.support.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
import org.junit.After;
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.elasticsearch.xpack.watcher.condition.script.ScriptCondition;
|
|||
import org.elasticsearch.xpack.watcher.condition.script.ScriptConditionFactory;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.Script;
|
||||
import org.elasticsearch.xpack.watcher.support.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.elasticsearch.xpack.watcher.input.search.SearchInputFactory;
|
|||
import org.elasticsearch.xpack.watcher.input.simple.ExecutableSimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.input.simple.SimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTrigger;
|
||||
import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTriggerEvent;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.script.mustache.MustachePlugin;
|
|||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.xpack.watcher.actions.ActionWrapper;
|
||||
import org.elasticsearch.xpack.watcher.actions.ExecutableActions;
|
||||
import org.elasticsearch.xpack.watcher.condition.always.ExecutableAlwaysCondition;
|
||||
import org.elasticsearch.xpack.watcher.execution.TriggeredExecutionContext;
|
||||
|
@ -39,7 +38,7 @@ import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
|||
import org.elasticsearch.xpack.watcher.input.simple.ExecutableSimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.input.simple.SimpleInput;
|
||||
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.transform.Transform;
|
||||
import org.elasticsearch.xpack.watcher.transform.TransformBuilders;
|
||||
import org.elasticsearch.xpack.watcher.transform.search.ExecutableSearchTransform;
|
||||
|
|
|
@ -51,7 +51,7 @@ public class WatcherWithShieldIT extends ESRestTestCase {
|
|||
public void startWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
InetSocketAddress address = cluster().httpAddresses()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, NetworkAddress.format(address.getAddress()), address.getPort(), "/_watcher/_start", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, NetworkAddress.format(address.getAddress()), address.getPort(), "/_xpack/watcher/_start", null, null));
|
||||
String token = basicAuthHeaderValue(TEST_ADMIN_USERNAME, new SecuredString(TEST_ADMIN_PASSWORD.toCharArray()));
|
||||
request.addHeader(UsernamePasswordToken.BASIC_AUTH_HEADER, token);
|
||||
client.execute(request);
|
||||
|
@ -62,7 +62,7 @@ public class WatcherWithShieldIT extends ESRestTestCase {
|
|||
public void stopWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
InetSocketAddress address = cluster().httpAddresses()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, NetworkAddress.format(address.getAddress()), address.getPort(), "/_watcher/_stop", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, NetworkAddress.format(address.getAddress()), address.getPort(), "/_xpack/watcher/_stop", null, null));
|
||||
String token = basicAuthHeaderValue(TEST_ADMIN_USERNAME, new SecuredString(TEST_ADMIN_PASSWORD.toCharArray()));
|
||||
request.addHeader(UsernamePasswordToken.BASIC_AUTH_HEADER, token);
|
||||
client.execute(request);
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class WatcherRestTestCase extends ESRestTestCase {
|
|||
public void startWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
URL url = getClusterUrls()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_watcher/_start", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/watcher/_start", null, null));
|
||||
client.execute(request);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public abstract class WatcherRestTestCase extends ESRestTestCase {
|
|||
public void stopWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
URL url = getClusterUrls()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_watcher/_stop", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/watcher/_stop", null, null));
|
||||
client.execute(request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class WatcherRestTestCase extends ESRestTestCase {
|
|||
public void startWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
URL url = getClusterUrls()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_watcher/_start", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/watcher/_start", null, null));
|
||||
client.execute(request);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public abstract class WatcherRestTestCase extends ESRestTestCase {
|
|||
public void stopWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
URL url = getClusterUrls()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_watcher/_stop", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/watcher/_stop", null, null));
|
||||
client.execute(request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ import org.elasticsearch.script.ScriptSettings;
|
|||
import org.elasticsearch.script.mustache.MustacheScriptEngineService;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||
import org.elasticsearch.xpack.watcher.support.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.watcher.support.text.DefaultTextTemplateEngine;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.common.text.DefaultTextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.junit.Before;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class WatcherRestTestCase extends ESRestTestCase {
|
|||
public void startWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
URL url = getClusterUrls()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_watcher/_start", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/watcher/_start", null, null));
|
||||
client.execute(request);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public abstract class WatcherRestTestCase extends ESRestTestCase {
|
|||
public void stopWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
URL url = getClusterUrls()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_watcher/_stop", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/watcher/_stop", null, null));
|
||||
client.execute(request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class WatcherWithShieldIT extends ESRestTestCase {
|
|||
public void startWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
URL url = getClusterUrls()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_watcher/_start", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/watcher/_start", null, null));
|
||||
String token = basicAuthHeaderValue(TEST_ADMIN_USERNAME, new SecuredString(TEST_ADMIN_PASSWORD.toCharArray()));
|
||||
request.addHeader(UsernamePasswordToken.BASIC_AUTH_HEADER, token);
|
||||
client.execute(request);
|
||||
|
@ -56,7 +56,7 @@ public class WatcherWithShieldIT extends ESRestTestCase {
|
|||
public void stopWatcher() throws Exception {
|
||||
try(CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
|
||||
URL url = getClusterUrls()[0];
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_watcher/_stop", null, null));
|
||||
HttpPut request = new HttpPut(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/watcher/_stop", null, null));
|
||||
String token = basicAuthHeaderValue(TEST_ADMIN_USERNAME, new SecuredString(TEST_ADMIN_PASSWORD.toCharArray()));
|
||||
request.addHeader(UsernamePasswordToken.BASIC_AUTH_HEADER, token);
|
||||
client.execute(request);
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.Version;
|
|||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.bulk.BulkRequest;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -131,11 +130,11 @@ public class HttpExporterTemplateTests extends AbstractExporterTemplateTestCase
|
|||
}
|
||||
return newResponse(200, "{\"errors\": false, \"msg\": \"successful bulk request\"}");
|
||||
default:
|
||||
String[] paths = Strings.splitStringToArray(request.getPath(), '/');
|
||||
String[] paths = request.getPath().split("/");
|
||||
|
||||
// Templates
|
||||
if ((paths != null) && (paths.length > 0) && ("_template".equals(paths[0]))) {
|
||||
String templateName = paths[1];
|
||||
if ((paths != null) && (paths.length > 1) && ("_template".equals(paths[1]))) {
|
||||
String templateName = paths[2];
|
||||
boolean templateExist = templates.containsKey(templateName);
|
||||
|
||||
if ("GET".equals(request.getMethod())) {
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.logging.LoggerMessageFormat;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
|
||||
import org.elasticsearch.index.engine.EngineException;
|
||||
|
@ -35,6 +37,7 @@ import org.elasticsearch.index.mapper.DocumentMapper;
|
|||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.internal.ParentFieldMapper;
|
||||
import org.elasticsearch.index.query.ParsedQuery;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.shard.IndexSearcherWrapper;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
@ -118,8 +121,11 @@ public class ShieldIndexSearcherWrapper extends IndexSearcherWrapper {
|
|||
BooleanQuery.Builder filter = new BooleanQuery.Builder();
|
||||
for (BytesReference bytesReference : permissions.getQueries()) {
|
||||
QueryShardContext queryShardContext = copyQueryShardContext(this.queryShardContext);
|
||||
ParsedQuery parsedQuery = queryShardContext.parse(bytesReference);
|
||||
filter.add(parsedQuery.query(), SHOULD);
|
||||
try (XContentParser parser = XContentFactory.xContent(bytesReference).createParser(bytesReference)) {
|
||||
QueryBuilder queryBuilder = queryShardContext.newParseContext(parser).parseInnerQueryBuilder();
|
||||
ParsedQuery parsedQuery = queryShardContext.toQuery(queryBuilder);
|
||||
filter.add(parsedQuery.query(), SHOULD);
|
||||
}
|
||||
}
|
||||
// at least one of the queries should match
|
||||
filter.setMinimumNumberShouldMatch(1);
|
||||
|
|
|
@ -1,225 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.integration;
|
||||
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Setting.Property;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.http.HttpServerTransport;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.shield.authc.support.SecuredString;
|
||||
import org.elasticsearch.shield.authc.support.UsernamePasswordToken;
|
||||
import org.elasticsearch.shield.ssl.SSLConfiguration.Global;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ShieldIntegTestCase;
|
||||
import org.elasticsearch.test.ShieldSettingsSource;
|
||||
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
|
||||
import org.elasticsearch.test.rest.client.http.HttpResponse;
|
||||
import org.junit.After;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@ClusterScope(scope = SUITE)
|
||||
public class SettingsFilterTests extends ShieldIntegTestCase {
|
||||
private CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
|
||||
@After
|
||||
public void cleanup() throws IOException {
|
||||
httpClient.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||
Collection<Class<? extends Plugin>> classes = super.nodePlugins();
|
||||
ArrayList<Class<? extends Plugin>> newClasses = new ArrayList<>(classes);
|
||||
newClasses.add(TestPlugin.class);
|
||||
return newClasses;
|
||||
}
|
||||
|
||||
public static class TestPlugin extends Plugin {
|
||||
|
||||
public TestPlugin() {}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "test_settings_adder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "adds some settings this test uses";
|
||||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
module.registerSetting(Setting.simpleString("foo.bar", Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("foo.baz", Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("bar.baz", Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("baz.foo", Property.NodeScope));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
int clientProfilePort = randomIntBetween(49000, 65400);
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
|
||||
|
||||
.put("xpack.security.authc.realms.file.type", "file")
|
||||
|
||||
// ldap realm filtering
|
||||
.put("xpack.security.authc.realms.ldap1.type", "ldap")
|
||||
.put("xpack.security.authc.realms.ldap1.enabled", "false")
|
||||
.put("xpack.security.authc.realms.ldap1.url", "ldap://host.domain")
|
||||
.put("xpack.security.authc.realms.ldap1.hostname_verification", randomAsciiOfLength(5))
|
||||
.put("xpack.security.authc.realms.ldap1.bind_dn", randomAsciiOfLength(5))
|
||||
.put("xpack.security.authc.realms.ldap1.bind_password", randomAsciiOfLength(5))
|
||||
|
||||
// active directory filtering
|
||||
.put("xpack.security.authc.realms.ad1.type", "active_directory")
|
||||
.put("xpack.security.authc.realms.ad1.enabled", "false")
|
||||
.put("xpack.security.authc.realms.ad1.url", "ldap://host.domain")
|
||||
.put("xpack.security.authc.realms.ad1.hostname_verification", randomAsciiOfLength(5))
|
||||
|
||||
// pki filtering
|
||||
.put("xpack.security.authc.realms.pki1.type", "pki")
|
||||
.put("xpack.security.authc.realms.pki1.order", "0")
|
||||
.put("xpack.security.authc.realms.pki1.truststore.path",
|
||||
getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/truststore-testnode-only.jks"))
|
||||
.put("xpack.security.authc.realms.pki1.truststore.password", "truststore-testnode-only")
|
||||
.put("xpack.security.authc.realms.pki1.truststore.algorithm", "SunX509")
|
||||
|
||||
.put("xpack.security.ssl.keystore.path", "/path/to/keystore")
|
||||
.put("xpack.security.ssl.ciphers", "_ciphers")
|
||||
.put("xpack.security.ssl.supported_protocols", randomFrom(Global.DEFAULT_SUPPORTED_PROTOCOLS))
|
||||
.put("xpack.security.ssl.keystore.password", randomAsciiOfLength(5))
|
||||
.put("xpack.security.ssl.keystore.algorithm", "_algorithm")
|
||||
.put("xpack.security.ssl.keystore.key_password", randomAsciiOfLength(5))
|
||||
.put("xpack.security.ssl.truststore.password", randomAsciiOfLength(5))
|
||||
.put("xpack.security.ssl.truststore.algorithm", "_algorithm")
|
||||
|
||||
// client profile
|
||||
.put("transport.profiles.client.port", clientProfilePort + "-" + (clientProfilePort + 100))
|
||||
.put("transport.profiles.client.xpack.security.keystore.path", "/path/to/keystore")
|
||||
.put("transport.profiles.client.xpack.security.ciphers", "_ciphers")
|
||||
.put("transport.profiles.client.xpack.security.supported_protocols",
|
||||
randomFrom(Global.DEFAULT_SUPPORTED_PROTOCOLS))
|
||||
.put("transport.profiles.client.xpack.security.keystore.password", randomAsciiOfLength(5))
|
||||
.put("transport.profiles.client.xpack.security.keystore.algorithm", "_algorithm")
|
||||
.put("transport.profiles.client.xpack.security.keystore.key_password", randomAsciiOfLength(5))
|
||||
.put("transport.profiles.client.xpack.security.truststore.password", randomAsciiOfLength(5))
|
||||
.put("transport.profiles.client.xpack.security.truststore.algorithm", "_algorithm")
|
||||
|
||||
// custom settings
|
||||
.put("foo.bar", "_secret")
|
||||
.put("foo.baz", "_secret")
|
||||
.put("bar.baz", "_secret")
|
||||
.put("baz.foo", "_not_a_secret") // should not be filtered
|
||||
.put("xpack.security.hide_settings", "foo.*,bar.baz")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean sslTransportEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void testFiltering() throws Exception {
|
||||
HttpResponse response = executeRequest("GET", "/_nodes", null, Collections.<String, String>emptyMap());
|
||||
List<Settings> list = extractSettings(response.getBody());
|
||||
for (Settings settings : list) {
|
||||
|
||||
assertThat(settings.get("xpack.security.authc.realms.ldap1.hostname_verification"), nullValue());
|
||||
assertThat(settings.get("xpack.security.authc.realms.ldap1.bind_password"), nullValue());
|
||||
assertThat(settings.get("xpack.security.authc.realms.ldap1.bind_dn"), nullValue());
|
||||
assertThat(settings.get("xpack.security.authc.realms.ldap1.url"), is("ldap://host.domain"));
|
||||
|
||||
assertThat(settings.get("xpack.security.authc.realms.ad1.hostname_verification"), nullValue());
|
||||
assertThat(settings.get("xpack.security.authc.realms.ad1.url"), is("ldap://host.domain"));
|
||||
|
||||
assertThat(settings.get("xpack.security.authc.realms.pki1.truststore.path"), nullValue());
|
||||
assertThat(settings.get("xpack.security.authc.realms.pki1.truststore.password"), nullValue());
|
||||
assertThat(settings.get("xpack.security.authc.realms.pki1.truststore.algorithm"), nullValue());
|
||||
assertThat(settings.get("xpack.security.authc.realms.pki1.type"), is("pki"));
|
||||
|
||||
assertThat(settings.get("xpack.security.ssl.keystore.path"), nullValue());
|
||||
assertThat(settings.get("xpack.security.ssl.ciphers"), nullValue());
|
||||
assertThat(settings.get("xpack.security.ssl.supported_protocols"), nullValue());
|
||||
assertThat(settings.get("xpack.security.ssl.keystore.password"), nullValue());
|
||||
assertThat(settings.get("xpack.security.ssl.keystore.algorithm"), nullValue());
|
||||
assertThat(settings.get("xpack.security.ssl.keystore.key_password"), nullValue());
|
||||
assertThat(settings.get("xpack.security.ssl.truststore.password"), nullValue());
|
||||
assertThat(settings.get("xpack.security.ssl.truststore.algorithm"), nullValue());
|
||||
|
||||
// the client profile settings is also filtered out
|
||||
assertThat(settings.get("transport.profiles.client.port"), notNullValue());
|
||||
assertThat(settings.get("transport.profiles.client.xpack.security.keystore.path"), nullValue());
|
||||
assertThat(settings.get("transport.profiles.client.xpack.security.ciphers"), nullValue());
|
||||
assertThat(settings.get("transport.profiles.client.xpack.security.supported_protocols"), nullValue());
|
||||
assertThat(settings.get("transport.profiles.client.xpack.security.keystore.password"), nullValue());
|
||||
assertThat(settings.get("transport.profiles.client.xpack.security.keystore.algorithm"), nullValue());
|
||||
assertThat(settings.get("transport.profiles.client.xpack.security.keystore.key_password"), nullValue());
|
||||
assertThat(settings.get("transport.profiles.client.xpack.security.truststore.password"), nullValue());
|
||||
assertThat(settings.get("transport.profiles.client.xpack.security.truststore.algorithm"), nullValue());
|
||||
|
||||
assertThat(settings.get("xpack.security.hide_settings"), nullValue());
|
||||
assertThat(settings.get("foo.bar"), nullValue());
|
||||
assertThat(settings.get("foo.baz"), nullValue());
|
||||
assertThat(settings.get("bar.baz"), nullValue());
|
||||
assertThat(settings.get("baz.foo"), is("_not_a_secret"));
|
||||
}
|
||||
}
|
||||
|
||||
static List<Settings> extractSettings(String data) throws Exception {
|
||||
List<Settings> settingsList = new ArrayList<>();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(data.getBytes(StandardCharsets.UTF_8));
|
||||
XContentParser.Token token = null;
|
||||
while ((token = parser.nextToken()) != null) {
|
||||
if (token == XContentParser.Token.FIELD_NAME && parser.currentName().equals("settings")) {
|
||||
parser.nextToken();
|
||||
XContentBuilder builder = XContentBuilder.builder(parser.contentType().xContent());
|
||||
settingsList.add(Settings.builder().loadFromSource(builder.copyCurrentStructure(parser).bytes().toUtf8()).build());
|
||||
}
|
||||
}
|
||||
return settingsList;
|
||||
}
|
||||
|
||||
protected HttpResponse executeRequest(String method, String uri, String body, Map<String, String> params) throws IOException {
|
||||
HttpServerTransport httpServerTransport = internalCluster().getDataNodeInstance(HttpServerTransport.class);
|
||||
HttpRequestBuilder requestBuilder = new HttpRequestBuilder(httpClient)
|
||||
.httpTransport(httpServerTransport)
|
||||
.method(method)
|
||||
.path(uri);
|
||||
|
||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||
requestBuilder.addParam(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (body != null) {
|
||||
requestBuilder.body(body);
|
||||
}
|
||||
requestBuilder.addHeader(UsernamePasswordToken.BASIC_AUTH_HEADER,
|
||||
UsernamePasswordToken.basicAuthHeaderValue(ShieldSettingsSource.DEFAULT_USER_NAME,
|
||||
new SecuredString(ShieldSettingsSource.DEFAULT_PASSWORD.toCharArray())));
|
||||
return requestBuilder.execute();
|
||||
}
|
||||
}
|
|
@ -21,15 +21,18 @@ import org.apache.lucene.search.TotalHitCountCollector;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.Accountable;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.ParsedQuery;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.query.TermQueryBuilder;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.shield.SecurityLicenseState;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -60,6 +63,7 @@ public class ShieldIndexSearcherWrapperIntegrationTests extends ESTestCase {
|
|||
singleton(new BytesArray("{}")));
|
||||
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(shardId.getIndex(), Settings.EMPTY);
|
||||
QueryShardContext queryShardContext = mock(QueryShardContext.class);
|
||||
QueryParseContext queryParseContext = mock(QueryParseContext.class);
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings("_index", Settings.EMPTY);
|
||||
BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(settings, new BitsetFilterCache.Listener() {
|
||||
@Override
|
||||
|
@ -133,7 +137,9 @@ public class ShieldIndexSearcherWrapperIntegrationTests extends ESTestCase {
|
|||
DirectoryReader directoryReader = ElasticsearchDirectoryReader.wrap(DirectoryReader.open(directory), shardId);
|
||||
for (int i = 0; i < numValues; i++) {
|
||||
ParsedQuery parsedQuery = new ParsedQuery(new TermQuery(new Term("field", values[i])));
|
||||
when(queryShardContext.parse(any(BytesReference.class))).thenReturn(parsedQuery);
|
||||
when(queryShardContext.newParseContext(any(XContentParser.class))).thenReturn(queryParseContext);
|
||||
when(queryParseContext.parseInnerQueryBuilder()).thenReturn((QueryBuilder) new TermQueryBuilder("field", values[i]));
|
||||
when(queryShardContext.toQuery(any(QueryBuilder.class))).thenReturn(parsedQuery);
|
||||
DirectoryReader wrappedDirectoryReader = wrapper.wrap(directoryReader);
|
||||
IndexSearcher indexSearcher = wrapper.wrap(new IndexSearcher(wrappedDirectoryReader));
|
||||
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.test;
|
||||
|
||||
import org.elasticsearch.common.inject.Guice;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.shield.ssl.SSLConfiguration;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.hamcrest.Matcher;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class SettingsFilterTests extends ESTestCase {
|
||||
|
||||
private Settings.Builder configuredSettingsBuilder = Settings.builder();
|
||||
private Map<String, Matcher> settingsMatcherMap = new HashMap<>();
|
||||
|
||||
public void testFiltering() {
|
||||
configureUnfilteredSetting("xpack.security.authc.realms.file.type", "file");
|
||||
|
||||
// ldap realm filtering
|
||||
configureUnfilteredSetting("xpack.security.authc.realms.ldap1.type", "ldap");
|
||||
configureUnfilteredSetting("xpack.security.authc.realms.ldap1.enabled", "false");
|
||||
configureUnfilteredSetting("xpack.security.authc.realms.ldap1.url", "ldap://host.domain");
|
||||
configureFilteredSetting("xpack.security.authc.realms.ldap1.hostname_verification", randomAsciiOfLength(5));
|
||||
configureFilteredSetting("xpack.security.authc.realms.ldap1.bind_dn", randomAsciiOfLength(5));
|
||||
configureFilteredSetting("xpack.security.authc.realms.ldap1.bind_password", randomAsciiOfLength(5));
|
||||
|
||||
// active directory filtering
|
||||
configureUnfilteredSetting("xpack.security.authc.realms.ad1.type", "active_directory");
|
||||
configureUnfilteredSetting("xpack.security.authc.realms.ad1.enabled", "false");
|
||||
configureUnfilteredSetting("xpack.security.authc.realms.ad1.url", "ldap://host.domain");
|
||||
configureFilteredSetting("xpack.security.authc.realms.ad1.hostname_verification", randomAsciiOfLength(5));
|
||||
|
||||
// pki filtering
|
||||
configureUnfilteredSetting("xpack.security.authc.realms.pki1.type", "pki");
|
||||
configureUnfilteredSetting("xpack.security.authc.realms.pki1.order", "0");
|
||||
configureFilteredSetting("xpack.security.authc.realms.pki1.truststore.path",
|
||||
getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/truststore-testnode-only.jks").toString());
|
||||
configureFilteredSetting("xpack.security.authc.realms.pki1.truststore.password", "truststore-testnode-only");
|
||||
configureFilteredSetting("xpack.security.authc.realms.pki1.truststore.algorithm", "SunX509");
|
||||
|
||||
configureFilteredSetting("xpack.security.ssl.keystore.path", "/path/to/keystore");
|
||||
configureFilteredSetting("xpack.security.ssl.ciphers", "_ciphers");
|
||||
configureFilteredSetting("xpack.security.ssl.supported_protocols", randomFrom(SSLConfiguration.Global.DEFAULT_SUPPORTED_PROTOCOLS));
|
||||
configureFilteredSetting("xpack.security.ssl.keystore.password", randomAsciiOfLength(5));
|
||||
configureFilteredSetting("xpack.security.ssl.keystore.algorithm", "_algorithm");
|
||||
configureFilteredSetting("xpack.security.ssl.keystore.key_password", randomAsciiOfLength(5));
|
||||
configureFilteredSetting("xpack.security.ssl.truststore.password", randomAsciiOfLength(5));
|
||||
configureFilteredSetting("xpack.security.ssl.truststore.algorithm", "_algorithm");
|
||||
|
||||
// client profile
|
||||
configureUnfilteredSetting("transport.profiles.client.port", "9500-9600");
|
||||
configureFilteredSetting("transport.profiles.client.xpack.security.keystore.path", "/path/to/keystore");
|
||||
configureFilteredSetting("transport.profiles.client.xpack.security.ciphers", "_ciphers");
|
||||
configureFilteredSetting("transport.profiles.client.xpack.security.supported_protocols",
|
||||
randomFrom(SSLConfiguration.Global.DEFAULT_SUPPORTED_PROTOCOLS));
|
||||
configureFilteredSetting("transport.profiles.client.xpack.security.keystore.password", randomAsciiOfLength(5));
|
||||
configureFilteredSetting("transport.profiles.client.xpack.security.keystore.algorithm", "_algorithm");
|
||||
configureFilteredSetting("transport.profiles.client.xpack.security.keystore.key_password", randomAsciiOfLength(5));
|
||||
configureFilteredSetting("transport.profiles.client.xpack.security.truststore.password", randomAsciiOfLength(5));
|
||||
configureFilteredSetting("transport.profiles.client.xpack.security.truststore.algorithm", "_algorithm");
|
||||
|
||||
// custom settings, potentially added by a plugin
|
||||
configureFilteredSetting("foo.bar", "_secret");
|
||||
configureFilteredSetting("foo.baz", "_secret");;
|
||||
configureFilteredSetting("bar.baz", "_secret");
|
||||
configureUnfilteredSetting("baz.foo", "_not_a_secret");
|
||||
configureFilteredSetting("xpack.security.hide_settings", "foo.*,bar.baz");
|
||||
|
||||
Settings settings = Settings.builder()
|
||||
.put("path.home", createTempDir())
|
||||
.put(configuredSettingsBuilder.build())
|
||||
.build();
|
||||
|
||||
XPackPlugin xPackPlugin = new XPackPlugin(settings);
|
||||
SettingsModule settingsModule = new SettingsModule(settings);
|
||||
// custom settings, potentially added by a plugin
|
||||
settingsModule.registerSetting(Setting.simpleString("foo.bar", Setting.Property.NodeScope));
|
||||
settingsModule.registerSetting(Setting.simpleString("foo.baz", Setting.Property.NodeScope));
|
||||
settingsModule.registerSetting(Setting.simpleString("bar.baz", Setting.Property.NodeScope));
|
||||
settingsModule.registerSetting(Setting.simpleString("baz.foo", Setting.Property.NodeScope));
|
||||
xPackPlugin.onModule(settingsModule);
|
||||
|
||||
Injector injector = Guice.createInjector(settingsModule);
|
||||
SettingsFilter settingsFilter = injector.getInstance(SettingsFilter.class);
|
||||
|
||||
Settings filteredSettings = settingsFilter.filter(settings);
|
||||
for (Map.Entry<String, Matcher> entry : settingsMatcherMap.entrySet()) {
|
||||
assertThat(filteredSettings.get(entry.getKey()), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void configureUnfilteredSetting(String settingName, String value) {
|
||||
configureSetting(settingName, value, is(value));
|
||||
}
|
||||
|
||||
private void configureFilteredSetting(String settingName, String value) {
|
||||
configureSetting(settingName, value, is(nullValue()));
|
||||
}
|
||||
|
||||
private void configureSetting(String settingName, String value, Matcher expectedMatcher) {
|
||||
configuredSettingsBuilder.put(settingName, value);
|
||||
settingsMatcherMap.put(settingName, expectedMatcher);
|
||||
}
|
||||
}
|
|
@ -7,8 +7,6 @@ package org.elasticsearch.xpack;
|
|||
|
||||
import org.elasticsearch.common.SuppressForbidden;
|
||||
import org.elasticsearch.common.io.PathUtils;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
|
|
|
@ -26,14 +26,18 @@ import org.elasticsearch.plugins.Plugin;
|
|||
import org.elasticsearch.script.ScriptModule;
|
||||
import org.elasticsearch.shield.Security;
|
||||
import org.elasticsearch.shield.authc.AuthenticationModule;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.action.TransportXPackInfoAction;
|
||||
import org.elasticsearch.xpack.action.XPackInfoAction;
|
||||
import org.elasticsearch.xpack.common.http.HttpClientModule;
|
||||
import org.elasticsearch.xpack.common.init.LazyInitializationModule;
|
||||
import org.elasticsearch.xpack.common.init.LazyInitializationService;
|
||||
import org.elasticsearch.xpack.common.secret.SecretModule;
|
||||
import org.elasticsearch.xpack.extensions.XPackExtension;
|
||||
import org.elasticsearch.xpack.extensions.XPackExtensionsService;
|
||||
import org.elasticsearch.xpack.notification.Notification;
|
||||
import org.elasticsearch.xpack.rest.action.RestXPackInfoAction;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateModule;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.security.AccessController;
|
||||
|
@ -88,20 +92,21 @@ public class XPackPlugin extends Plugin {
|
|||
protected Monitoring monitoring;
|
||||
protected Watcher watcher;
|
||||
protected Graph graph;
|
||||
protected Notification notification;
|
||||
|
||||
public XPackPlugin(Settings settings) {
|
||||
this.settings = settings;
|
||||
transportClientMode = transportClientMode(settings);
|
||||
this.transportClientMode = transportClientMode(settings);
|
||||
this.licensing = new Licensing(settings);
|
||||
this.security = new Security(settings);
|
||||
this.monitoring = new Monitoring(settings);
|
||||
this.watcher = new Watcher(settings);
|
||||
this.graph = new Graph(settings);
|
||||
this.notification = new Notification(settings);
|
||||
// Check if the node is a transport client.
|
||||
if (transportClientMode(settings) == false) {
|
||||
if (transportClientMode == false) {
|
||||
Environment env = new Environment(settings);
|
||||
this.extensionsService =
|
||||
new XPackExtensionsService(settings, resolveXPackExtensionsFile(env), getExtensions());
|
||||
this.extensionsService = new XPackExtensionsService(settings, resolveXPackExtensionsFile(env), getExtensions());
|
||||
} else {
|
||||
this.extensionsService = null;
|
||||
}
|
||||
|
@ -124,11 +129,18 @@ public class XPackPlugin extends Plugin {
|
|||
public Collection<Module> nodeModules() {
|
||||
ArrayList<Module> modules = new ArrayList<>();
|
||||
modules.add(new LazyInitializationModule());
|
||||
modules.addAll(notification.nodeModules());
|
||||
modules.addAll(licensing.nodeModules());
|
||||
modules.addAll(security.nodeModules());
|
||||
modules.addAll(watcher.nodeModules());
|
||||
modules.addAll(monitoring.nodeModules());
|
||||
modules.addAll(graph.nodeModules());
|
||||
|
||||
if (transportClientMode == false) {
|
||||
modules.add(new HttpClientModule());
|
||||
modules.add(new SecretModule(settings));
|
||||
modules.add(new TextTemplateModule());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
|
@ -139,6 +151,7 @@ public class XPackPlugin extends Plugin {
|
|||
// as other services may depend on one of the initialized
|
||||
// constructs
|
||||
services.add(LazyInitializationService.class);
|
||||
services.addAll(notification.nodeServices());
|
||||
services.addAll(licensing.nodeServices());
|
||||
services.addAll(security.nodeServices());
|
||||
services.addAll(watcher.nodeServices());
|
||||
|
@ -161,10 +174,16 @@ public class XPackPlugin extends Plugin {
|
|||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
|
||||
// we add the `xpack.version` setting to all internal indices
|
||||
module.registerSetting(Setting.simpleString("index.xpack.version", Setting.Property.IndexScope));
|
||||
|
||||
// http settings
|
||||
module.registerSetting(Setting.simpleString("xpack.http.default_read_timeout", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.http.default_connection_timeout", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.groupSetting("xpack.http.ssl.", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.groupSetting("xpack.http.proxy.", Setting.Property.NodeScope));
|
||||
|
||||
notification.onModule(module);
|
||||
security.onModule(module);
|
||||
monitoring.onModule(module);
|
||||
watcher.onModule(module);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support;
|
||||
package org.elasticsearch.xpack.common;
|
||||
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -13,6 +13,7 @@ import org.elasticsearch.script.ScriptContext;
|
|||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.shield.SecurityContext;
|
||||
import org.elasticsearch.shield.user.XPackUser;
|
||||
import org.elasticsearch.xpack.watcher.support.Script;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.ElasticsearchTimeoutException;
|
||||
|
@ -15,8 +15,8 @@ import org.elasticsearch.common.io.Streams;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.ApplicableHttpAuth;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.common.http.auth.ApplicableHttpAuth;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.KeyManager;
|
||||
|
@ -48,8 +48,8 @@ import java.util.Map;
|
|||
*/
|
||||
public class HttpClient extends AbstractLifecycleComponent<HttpClient> {
|
||||
|
||||
static final String SETTINGS_SSL_PREFIX = "xpack.watcher.http.ssl.";
|
||||
static final String SETTINGS_PROXY_PREFIX = "xpack.watcher.http.proxy.";
|
||||
static final String SETTINGS_SSL_PREFIX = "xpack.http.ssl.";
|
||||
static final String SETTINGS_PROXY_PREFIX = "xpack.http.proxy.";
|
||||
static final String SETTINGS_SSL_SHIELD_PREFIX = "xpack.security.ssl.";
|
||||
|
||||
public static final String SETTINGS_SSL_PROTOCOL = SETTINGS_SSL_PREFIX + "protocol";
|
||||
|
@ -84,8 +84,8 @@ public class HttpClient extends AbstractLifecycleComponent<HttpClient> {
|
|||
super(settings);
|
||||
this.httpAuthRegistry = httpAuthRegistry;
|
||||
this.env = env;
|
||||
defaultConnectionTimeout = settings.getAsTime("xpack.watcher.http.default_connection_timeout", TimeValue.timeValueSeconds(10));
|
||||
defaultReadTimeout = settings.getAsTime("xpack.watcher.http.default_read_timeout", TimeValue.timeValueSeconds(10));
|
||||
defaultConnectionTimeout = settings.getAsTime("xpack.http.default_connection_timeout", TimeValue.timeValueSeconds(10));
|
||||
defaultReadTimeout = settings.getAsTime("xpack.http.default_read_timeout", TimeValue.timeValueSeconds(10));
|
||||
}
|
||||
|
||||
@Override
|
|
@ -3,14 +3,14 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.multibindings.MapBinder;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthFactory;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.basic.BasicAuth;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.basic.BasicAuthFactory;
|
||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuth;
|
||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuthFactory;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthFactory;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
|
||||
|
||||
/**
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.ParseField;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
|
@ -18,10 +18,10 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.rest.support.RestUtils;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuth;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
|
@ -16,12 +16,11 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.rest.support.RestUtils;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuth;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest.Field;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuth;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -165,40 +164,40 @@ public class HttpRequestTemplate implements ToXContent {
|
|||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
|
||||
builder.startObject();
|
||||
builder.field(Field.SCHEME.getPreferredName(), scheme, params);
|
||||
builder.field(Field.HOST.getPreferredName(), host);
|
||||
builder.field(Field.PORT.getPreferredName(), port);
|
||||
builder.field(Field.METHOD.getPreferredName(), method, params);
|
||||
builder.field(HttpRequest.Field.SCHEME.getPreferredName(), scheme, params);
|
||||
builder.field(HttpRequest.Field.HOST.getPreferredName(), host);
|
||||
builder.field(HttpRequest.Field.PORT.getPreferredName(), port);
|
||||
builder.field(HttpRequest.Field.METHOD.getPreferredName(), method, params);
|
||||
if (path != null) {
|
||||
builder.field(Field.PATH.getPreferredName(), path, params);
|
||||
builder.field(HttpRequest.Field.PATH.getPreferredName(), path, params);
|
||||
}
|
||||
if (this.params != null) {
|
||||
builder.startObject(Field.PARAMS.getPreferredName());
|
||||
builder.startObject(HttpRequest.Field.PARAMS.getPreferredName());
|
||||
for (Map.Entry<String, TextTemplate> entry : this.params.entrySet()) {
|
||||
builder.field(entry.getKey(), entry.getValue(), params);
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
if (headers != null) {
|
||||
builder.startObject(Field.HEADERS.getPreferredName());
|
||||
builder.startObject(HttpRequest.Field.HEADERS.getPreferredName());
|
||||
for (Map.Entry<String, TextTemplate> entry : headers.entrySet()) {
|
||||
builder.field(entry.getKey(), entry.getValue(), params);
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
if (auth != null) {
|
||||
builder.startObject(Field.AUTH.getPreferredName())
|
||||
builder.startObject(HttpRequest.Field.AUTH.getPreferredName())
|
||||
.field(auth.type(), auth, params)
|
||||
.endObject();
|
||||
}
|
||||
if (body != null) {
|
||||
builder.field(Field.BODY.getPreferredName(), body, params);
|
||||
builder.field(HttpRequest.Field.BODY.getPreferredName(), body, params);
|
||||
}
|
||||
if (connectionTimeout != null) {
|
||||
builder.field(Field.CONNECTION_TIMEOUT.getPreferredName(), connectionTimeout);
|
||||
builder.field(HttpRequest.Field.CONNECTION_TIMEOUT.getPreferredName(), connectionTimeout);
|
||||
}
|
||||
if (readTimeout != null) {
|
||||
builder.field(Field.READ_TIMEOUT.getPreferredName(), readTimeout);
|
||||
builder.field(HttpRequest.Field.READ_TIMEOUT.getPreferredName(), readTimeout);
|
||||
}
|
||||
if (proxy != null) {
|
||||
proxy.toXContent(builder, params);
|
||||
|
@ -270,52 +269,53 @@ public class HttpRequestTemplate implements ToXContent {
|
|||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PROXY)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.PROXY)) {
|
||||
builder.proxy(HttpProxy.parse(parser));
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PATH)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.PATH)) {
|
||||
builder.path(parseFieldTemplate(currentFieldName, parser));
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.HEADERS)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.HEADERS)) {
|
||||
builder.putHeaders(parseFieldTemplates(currentFieldName, parser));
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PARAMS)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.PARAMS)) {
|
||||
builder.putParams(parseFieldTemplates(currentFieldName, parser));
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.BODY)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.BODY)) {
|
||||
builder.body(parseFieldTemplate(currentFieldName, parser));
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.URL)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.URL)) {
|
||||
builder.fromUrl(parser.text());
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.CONNECTION_TIMEOUT)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.CONNECTION_TIMEOUT)) {
|
||||
try {
|
||||
builder.connectionTimeout(WatcherDateTimeUtils.parseTimeValue(parser, Field.CONNECTION_TIMEOUT.toString()));
|
||||
builder.connectionTimeout(WatcherDateTimeUtils.parseTimeValue(parser,
|
||||
HttpRequest.Field.CONNECTION_TIMEOUT.toString()));
|
||||
} catch (ElasticsearchParseException pe) {
|
||||
throw new ElasticsearchParseException("could not parse http request template. invalid time value for [{}] field",
|
||||
pe, currentFieldName);
|
||||
}
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.READ_TIMEOUT)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.READ_TIMEOUT)) {
|
||||
try {
|
||||
builder.readTimeout(WatcherDateTimeUtils.parseTimeValue(parser, Field.READ_TIMEOUT.toString()));
|
||||
builder.readTimeout(WatcherDateTimeUtils.parseTimeValue(parser, HttpRequest.Field.READ_TIMEOUT.toString()));
|
||||
} catch (ElasticsearchParseException pe) {
|
||||
throw new ElasticsearchParseException("could not parse http request template. invalid time value for [{}] field",
|
||||
pe, currentFieldName);
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.AUTH)) {
|
||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.AUTH)) {
|
||||
builder.auth(httpAuthRegistry.parse(parser));
|
||||
} else {
|
||||
throw new ElasticsearchParseException("could not parse http request template. unexpected object field [{}]",
|
||||
currentFieldName);
|
||||
}
|
||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.SCHEME)) {
|
||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.SCHEME)) {
|
||||
builder.scheme(Scheme.parse(parser.text()));
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.METHOD)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.METHOD)) {
|
||||
builder.method(HttpMethod.parse(parser.text()));
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.HOST)) {
|
||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.HOST)) {
|
||||
builder.host = parser.text();
|
||||
} else {
|
||||
throw new ElasticsearchParseException("could not parse http request template. unexpected string field [{}]",
|
||||
currentFieldName);
|
||||
}
|
||||
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.PORT)) {
|
||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, HttpRequest.Field.PORT)) {
|
||||
builder.port = parser.intValue();
|
||||
} else {
|
||||
throw new ElasticsearchParseException("could not parse http request template. unexpected numeric field [{}]",
|
||||
|
@ -329,11 +329,11 @@ public class HttpRequestTemplate implements ToXContent {
|
|||
|
||||
if (builder.host == null) {
|
||||
throw new ElasticsearchParseException("could not parse http request template. missing required [{}] string field",
|
||||
Field.HOST.getPreferredName());
|
||||
HttpRequest.Field.HOST.getPreferredName());
|
||||
}
|
||||
if (builder.port <= 0) {
|
||||
throw new ElasticsearchParseException("could not parse http request template. wrong port for [{}]",
|
||||
Field.PORT.getPreferredName());
|
||||
HttpRequest.Field.PORT.getPreferredName());
|
||||
}
|
||||
|
||||
return builder.build();
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http.auth;
|
||||
package org.elasticsearch.xpack.common.http.auth;
|
||||
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http.auth;
|
||||
package org.elasticsearch.xpack.common.http.auth;
|
||||
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http.auth;
|
||||
package org.elasticsearch.xpack.common.http.auth;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http.auth;
|
||||
package org.elasticsearch.xpack.common.http.auth;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
|
@ -3,11 +3,11 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http.auth.basic;
|
||||
package org.elasticsearch.xpack.common.http.auth.basic;
|
||||
|
||||
import org.elasticsearch.common.Base64;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.ApplicableHttpAuth;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.http.auth.ApplicableHttpAuth;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
|
@ -3,14 +3,14 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http.auth.basic;
|
||||
package org.elasticsearch.xpack.common.http.auth.basic;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuth;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.Secret;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuth;
|
||||
import org.elasticsearch.xpack.common.secret.Secret;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherParams;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherXContentParser;
|
||||
|
|
@ -3,12 +3,12 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http.auth.basic;
|
||||
package org.elasticsearch.xpack.common.http.auth.basic;
|
||||
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthFactory;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthFactory;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.secret;
|
||||
package org.elasticsearch.xpack.common.secret;
|
||||
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.secret;
|
||||
package org.elasticsearch.xpack.common.secret;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
|
@ -3,11 +3,10 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.secret;
|
||||
package org.elasticsearch.xpack.common.secret;
|
||||
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.shield.crypto.CryptoService;
|
||||
|
||||
|
@ -44,24 +43,21 @@ public interface SecretService {
|
|||
class Secure extends AbstractComponent implements SecretService {
|
||||
|
||||
private final CryptoService cryptoService;
|
||||
private final boolean encryptSensitiveData;
|
||||
public static final Setting<Boolean> ENCRYPT_SENSITIVE_DATA_SETTING =
|
||||
Setting.boolSetting("xpack.watcher.shield.encrypt_sensitive_data", false, Setting.Property.NodeScope);
|
||||
|
||||
@Inject
|
||||
public Secure(Settings settings, CryptoService cryptoService) {
|
||||
super(settings);
|
||||
this.encryptSensitiveData = ENCRYPT_SENSITIVE_DATA_SETTING.get(settings);
|
||||
this.cryptoService = cryptoService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] encrypt(char[] text) {
|
||||
return encryptSensitiveData ? cryptoService.encrypt(text) : text;
|
||||
return cryptoService.encrypt(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] decrypt(char[] text) {
|
||||
return encryptSensitiveData ? cryptoService.decrypt(text) : text;
|
||||
return cryptoService.decrypt(text);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.text;
|
||||
package org.elasticsearch.xpack.common.text;
|
||||
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
|
@ -13,7 +13,7 @@ import org.elasticsearch.common.xcontent.XContentType;
|
|||
import org.elasticsearch.script.CompiledScript;
|
||||
import org.elasticsearch.script.ExecutableScript;
|
||||
import org.elasticsearch.script.Template;
|
||||
import org.elasticsearch.xpack.watcher.support.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.text;
|
||||
package org.elasticsearch.xpack.common.text;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.Nullable;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.text;
|
||||
package org.elasticsearch.xpack.common.text;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -3,9 +3,10 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.text;
|
||||
package org.elasticsearch.xpack.common.text;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -14,6 +15,7 @@ public class TextTemplateModule extends AbstractModule {
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ScriptServiceProxy.class).asEagerSingleton();
|
||||
bind(DefaultTextTemplateEngine.class).asEagerSingleton();
|
||||
bind(TextTemplateEngine.class).to(DefaultTextTemplateEngine.class);
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.notification;
|
||||
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.notification.email.EmailService;
|
||||
import org.elasticsearch.xpack.notification.email.InternalEmailService;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatService;
|
||||
import org.elasticsearch.xpack.notification.hipchat.InternalHipChatService;
|
||||
import org.elasticsearch.xpack.notification.pagerduty.InternalPagerDutyService;
|
||||
import org.elasticsearch.xpack.notification.pagerduty.PagerDutyAccount;
|
||||
import org.elasticsearch.xpack.notification.pagerduty.PagerDutyService;
|
||||
import org.elasticsearch.xpack.notification.slack.InternalSlackService;
|
||||
import org.elasticsearch.xpack.notification.slack.SlackService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Notification {
|
||||
|
||||
private final boolean transportClient;
|
||||
|
||||
public Notification(Settings settings) {
|
||||
this.transportClient = "transport".equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey()));
|
||||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
module.registerSetting(InternalSlackService.SLACK_ACCOUNT_SETTING);
|
||||
module.registerSetting(InternalEmailService.EMAIL_ACCOUNT_SETTING);
|
||||
module.registerSetting(InternalHipChatService.HIPCHAT_ACCOUNT_SETTING);
|
||||
module.registerSetting(InternalPagerDutyService.PAGERDUTY_ACCOUNT_SETTING);
|
||||
|
||||
module.registerSettingsFilter("xpack.notification.email.account.*.smtp.password");
|
||||
module.registerSettingsFilter("xpack.notification.slack.account.*.url");
|
||||
module.registerSettingsFilter("xpack.notification.pagerduty.account.*.url");
|
||||
module.registerSettingsFilter("xpack.notification.pagerduty." + PagerDutyAccount.SERVICE_KEY_SETTING);
|
||||
module.registerSettingsFilter("xpack.notification.pagerduty.account.*." + PagerDutyAccount.SERVICE_KEY_SETTING);
|
||||
module.registerSettingsFilter("xpack.notification.hipchat.account.*.auth_token");
|
||||
}
|
||||
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
if (transportClient) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.<Class<? extends LifecycleComponent>>asList(
|
||||
HttpClient.class,
|
||||
EmailService.class,
|
||||
HipChatService.class,
|
||||
SlackService.class,
|
||||
PagerDutyService.class
|
||||
);
|
||||
}
|
||||
|
||||
public Collection<? extends Module> nodeModules() {
|
||||
if (transportClient) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Module> modules = new ArrayList<>();
|
||||
modules.add(new NotificationModule());
|
||||
return modules;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.notification;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.multibindings.MapBinder;
|
||||
import org.elasticsearch.xpack.notification.email.EmailService;
|
||||
import org.elasticsearch.xpack.notification.email.HtmlSanitizer;
|
||||
import org.elasticsearch.xpack.notification.email.InternalEmailService;
|
||||
import org.elasticsearch.xpack.notification.email.attachment.DataAttachmentParser;
|
||||
import org.elasticsearch.xpack.notification.email.attachment.EmailAttachmentParser;
|
||||
import org.elasticsearch.xpack.notification.email.attachment.EmailAttachmentsParser;
|
||||
import org.elasticsearch.xpack.notification.email.attachment.HttpEmailAttachementParser;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatService;
|
||||
import org.elasticsearch.xpack.notification.hipchat.InternalHipChatService;
|
||||
import org.elasticsearch.xpack.notification.pagerduty.InternalPagerDutyService;
|
||||
import org.elasticsearch.xpack.notification.pagerduty.PagerDutyService;
|
||||
import org.elasticsearch.xpack.notification.slack.InternalSlackService;
|
||||
import org.elasticsearch.xpack.notification.slack.SlackService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class NotificationModule extends AbstractModule {
|
||||
|
||||
private final Map<String, Class<? extends EmailAttachmentParser>> emailAttachmentParsers = new HashMap<>();
|
||||
|
||||
|
||||
public NotificationModule() {
|
||||
registerEmailAttachmentParser(HttpEmailAttachementParser.TYPE, HttpEmailAttachementParser.class);
|
||||
registerEmailAttachmentParser(DataAttachmentParser.TYPE, DataAttachmentParser.class);
|
||||
}
|
||||
|
||||
public void registerEmailAttachmentParser(String type, Class<? extends EmailAttachmentParser> parserClass) {
|
||||
emailAttachmentParsers.put(type, parserClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
// email
|
||||
bind(HtmlSanitizer.class).asEagerSingleton();
|
||||
bind(InternalEmailService.class).asEagerSingleton();
|
||||
bind(EmailService.class).to(InternalEmailService.class).asEagerSingleton();
|
||||
|
||||
MapBinder<String, EmailAttachmentParser> emailParsersBinder = MapBinder.newMapBinder(binder(), String.class,
|
||||
EmailAttachmentParser.class);
|
||||
for (Map.Entry<String, Class<? extends EmailAttachmentParser>> entry : emailAttachmentParsers.entrySet()) {
|
||||
emailParsersBinder.addBinding(entry.getKey()).to(entry.getValue()).asEagerSingleton();
|
||||
}
|
||||
bind(EmailAttachmentsParser.class).asEagerSingleton();
|
||||
|
||||
// hipchat
|
||||
bind(InternalHipChatService.class).asEagerSingleton();
|
||||
bind(HipChatService.class).to(InternalHipChatService.class);
|
||||
|
||||
// slack
|
||||
bind(InternalSlackService.class).asEagerSingleton();
|
||||
bind(SlackService.class).to(InternalSlackService.class);
|
||||
|
||||
// pager duty
|
||||
bind(InternalPagerDutyService.class).asEagerSingleton();
|
||||
bind(PagerDutyService.class).to(InternalPagerDutyService.class);
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
|
||||
import javax.activation.CommandMap;
|
||||
import javax.activation.MailcapCommandMap;
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.notification.email;
|
|||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.notification.email;
|
||||
|
||||
import org.elasticsearch.xpack.watcher.support.secret.Secret;
|
||||
import org.elasticsearch.xpack.common.secret.Secret;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import org.elasticsearch.common.ParseFieldMatcher;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.Variables;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
import org.elasticsearch.xpack.notification.email.Attachment;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.notification.email.attachment;
|
|||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.elasticsearch.common.settings.SettingsException;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatAccount.Profile;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -13,8 +13,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
package org.elasticsearch.xpack.notification.hipchat;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -17,12 +17,12 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
|||
import org.elasticsearch.xpack.watcher.actions.hipchat.HipChatAction;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatMessage.Color;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatMessage.Format;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.support.http.Scheme;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -8,8 +8,8 @@ package org.elasticsearch.xpack.notification.hipchat;
|
|||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -17,12 +17,12 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
|||
import org.elasticsearch.xpack.watcher.actions.hipchat.HipChatAction;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatMessage.Color;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatMessage.Format;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.support.http.Scheme;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -13,12 +13,12 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.xpack.watcher.actions.hipchat.HipChatAction;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatMessage.Color;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatMessage.Format;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.support.http.Scheme;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -13,11 +13,11 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.Scheme;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -13,8 +13,8 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -8,9 +8,9 @@ package org.elasticsearch.xpack.notification.pagerduty;
|
|||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.notification.pagerduty;
|
|||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -14,8 +14,8 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.xpack.watcher.actions.pagerduty.PagerDutyAction;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -8,8 +8,8 @@ package org.elasticsearch.xpack.notification.slack;
|
|||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.notification.slack.message.SlackMessage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -11,10 +11,10 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.support.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
import org.elasticsearch.xpack.notification.slack.message.Attachment;
|
||||
import org.elasticsearch.xpack.notification.slack.message.SlackMessage;
|
||||
import org.elasticsearch.xpack.notification.slack.message.SlackMessageDefaults;
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.notification.slack;
|
|||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.elasticsearch.common.ParseFieldMatcher;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.ParseField;
|
|||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.elasticsearch.common.ParseFieldMatcher;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.elasticsearch.common.ParseFieldMatcher;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
|
@ -16,10 +16,10 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.junit.annotations.Network;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.basic.BasicAuth;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.basic.BasicAuthFactory;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuth;
|
||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuthFactory;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.ElasticsearchTimeoutException;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -11,7 +11,10 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.junit.annotations.Network;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
|
@ -51,7 +54,7 @@ public class HttpConnectionTimeoutTests extends ESTestCase {
|
|||
public void testDefaultTimeoutCustom() throws Exception {
|
||||
Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build());
|
||||
HttpClient httpClient = new HttpClient(Settings.builder()
|
||||
.put("xpack.watcher.http.default_connection_timeout", "5s")
|
||||
.put("xpack.http.default_connection_timeout", "5s")
|
||||
.build()
|
||||
, mock(HttpAuthRegistry.class), environment).start();
|
||||
|
||||
|
@ -78,7 +81,7 @@ public class HttpConnectionTimeoutTests extends ESTestCase {
|
|||
public void testTimeoutCustomPerRequest() throws Exception {
|
||||
Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build());
|
||||
HttpClient httpClient = new HttpClient(Settings.builder()
|
||||
.put("xpack.watcher.http.default_connection_timeout", "10s")
|
||||
.put("xpack.http.default_connection_timeout", "10s")
|
||||
.build()
|
||||
, mock(HttpAuthRegistry.class), environment).start();
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import com.squareup.okhttp.mockwebserver.Dispatcher;
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
|
@ -14,7 +14,10 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
|
@ -55,29 +58,23 @@ public class HttpReadTimeoutTests extends ESTestCase {
|
|||
.build();
|
||||
|
||||
long start = System.nanoTime();
|
||||
try {
|
||||
httpClient.execute(request);
|
||||
fail("expected read timeout after 10 seconds (default)");
|
||||
} catch (ElasticsearchTimeoutException ete) {
|
||||
// expected
|
||||
expectThrows(ElasticsearchTimeoutException.class, () -> httpClient.execute(request));
|
||||
TimeValue timeout = TimeValue.timeValueNanos(System.nanoTime() - start);
|
||||
logger.info("http connection timed out after {}", timeout.format());
|
||||
|
||||
TimeValue timeout = TimeValue.timeValueNanos(System.nanoTime() - start);
|
||||
logger.info("http connection timed out after {}", timeout.format());
|
||||
// it's supposed to be 10, but we'll give it an error margin of 2 seconds
|
||||
assertThat(timeout.seconds(), greaterThan(8L));
|
||||
assertThat(timeout.seconds(), lessThan(12L));
|
||||
|
||||
// it's supposed to be 10, but we'll give it an error margin of 2 seconds
|
||||
assertThat(timeout.seconds(), greaterThan(8L));
|
||||
assertThat(timeout.seconds(), lessThan(12L));
|
||||
|
||||
// lets enqueue a response to relese the server.
|
||||
webServer.enqueue(new MockResponse());
|
||||
}
|
||||
// lets enqueue a response to relese the server.
|
||||
webServer.enqueue(new MockResponse());
|
||||
}
|
||||
|
||||
public void testDefaultTimeoutCustom() throws Exception {
|
||||
Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build());
|
||||
|
||||
HttpClient httpClient = new HttpClient(Settings.builder()
|
||||
.put("xpack.watcher.http.default_read_timeout", "3s")
|
||||
.put("xpack.http.default_read_timeout", "3s")
|
||||
.build()
|
||||
, mock(HttpAuthRegistry.class), environment).start();
|
||||
|
||||
|
@ -92,19 +89,13 @@ public class HttpReadTimeoutTests extends ESTestCase {
|
|||
.build();
|
||||
|
||||
long start = System.nanoTime();
|
||||
try {
|
||||
httpClient.execute(request);
|
||||
fail("expected read timeout after 3 seconds (default)");
|
||||
} catch (ElasticsearchTimeoutException ete) {
|
||||
// expected
|
||||
expectThrows(ElasticsearchTimeoutException.class, () -> httpClient.execute(request));
|
||||
TimeValue timeout = TimeValue.timeValueNanos(System.nanoTime() - start);
|
||||
logger.info("http connection timed out after {}", timeout.format());
|
||||
|
||||
TimeValue timeout = TimeValue.timeValueNanos(System.nanoTime() - start);
|
||||
logger.info("http connection timed out after {}", timeout.format());
|
||||
|
||||
// it's supposed to be 3, but we'll give it an error margin of 2 seconds
|
||||
assertThat(timeout.seconds(), greaterThan(1L));
|
||||
assertThat(timeout.seconds(), lessThan(5L));
|
||||
}
|
||||
// it's supposed to be 3, but we'll give it an error margin of 2 seconds
|
||||
assertThat(timeout.seconds(), greaterThan(1L));
|
||||
assertThat(timeout.seconds(), lessThan(5L));
|
||||
|
||||
if (!latch.await(sleepTime.seconds(), TimeUnit.SECONDS)) {
|
||||
// should never happen
|
||||
|
@ -116,7 +107,7 @@ public class HttpReadTimeoutTests extends ESTestCase {
|
|||
Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build());
|
||||
|
||||
HttpClient httpClient = new HttpClient(Settings.builder()
|
||||
.put("xpack.watcher.http.default_read_timeout", "10s")
|
||||
.put("xpack.http.default_read_timeout", "10s")
|
||||
.build()
|
||||
, mock(HttpAuthRegistry.class), environment).start();
|
||||
|
||||
|
@ -132,19 +123,13 @@ public class HttpReadTimeoutTests extends ESTestCase {
|
|||
.build();
|
||||
|
||||
long start = System.nanoTime();
|
||||
try {
|
||||
httpClient.execute(request);
|
||||
fail("expected read timeout after 5 seconds");
|
||||
} catch (ElasticsearchTimeoutException ete) {
|
||||
// expected
|
||||
expectThrows(ElasticsearchTimeoutException.class, () -> httpClient.execute(request));
|
||||
TimeValue timeout = TimeValue.timeValueNanos(System.nanoTime() - start);
|
||||
logger.info("http connection timed out after {}", timeout.format());
|
||||
|
||||
TimeValue timeout = TimeValue.timeValueNanos(System.nanoTime() - start);
|
||||
logger.info("http connection timed out after {}", timeout.format());
|
||||
|
||||
// it's supposed to be 5, but we'll give it an error margin of 2 seconds
|
||||
assertThat(timeout.seconds(), greaterThan(3L));
|
||||
assertThat(timeout.seconds(), lessThan(7L));
|
||||
}
|
||||
// it's supposed to be 5, but we'll give it an error margin of 2 seconds
|
||||
assertThat(timeout.seconds(), greaterThan(3L));
|
||||
assertThat(timeout.seconds(), lessThan(7L));
|
||||
|
||||
if (!latch.await(sleepTime.seconds(), TimeUnit.SECONDS)) {
|
||||
// should never happen
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
@ -13,11 +13,11 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.basic.BasicAuth;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.basic.BasicAuthFactory;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuth;
|
||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuthFactory;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.test.MockTextTemplateEngine;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
@ -11,7 +11,9 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.hamcrest.Matchers.containsString;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.http;
|
||||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
|
@ -13,7 +13,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.watcher.support.text;
|
||||
package org.elasticsearch.xpack.common.text;
|
||||
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
|
@ -17,7 +17,7 @@ import org.elasticsearch.script.ExecutableScript;
|
|||
import org.elasticsearch.script.ScriptService.ScriptType;
|
||||
import org.elasticsearch.script.Template;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.Collections;
|
|
@ -10,8 +10,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.notification.email.support.EmailServer;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.Secret;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.secret.Secret;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.notification.email;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.xpack.watcher.client.WatcherClient;
|
||||
import org.elasticsearch.xpack.watcher.execution.ActionExecutionMode;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.XContentSource;
|
||||
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||
import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchResponse;
|
||||
|
@ -69,7 +69,7 @@ public class EmailSecretsIntegrationTests extends AbstractWatcherIntegrationTest
|
|||
.put("xpack.notification.email.account.test.smtp.auth", true)
|
||||
.put("xpack.notification.email.account.test.smtp.port", server.port())
|
||||
.put("xpack.notification.email.account.test.smtp.host", "localhost")
|
||||
.put("xpack.watcher.shield.encrypt_sensitive_data", encryptSensitiveData)
|
||||
.put("xpack.watcher.encrypt_sensitive_data", encryptSensitiveData)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.elasticsearch.common.xcontent.XContentFactory;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -9,8 +9,8 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.Secret;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.secret.Secret;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -14,8 +14,8 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||
import org.elasticsearch.xpack.notification.email.Attachment;
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.basic.BasicAuth;
|
||||
import org.elasticsearch.xpack.watcher.support.http.auth.basic.BasicAuthFactory;
|
||||
import org.elasticsearch.xpack.watcher.support.secret.SecretService;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuth;
|
||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuthFactory;
|
||||
import org.elasticsearch.xpack.common.secret.SecretService;
|
||||
import org.elasticsearch.xpack.watcher.test.MockTextTemplateEngine;
|
||||
import org.junit.Before;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.notification.hipchat;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.junit.Before;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.xcontent.XContentUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -12,11 +12,11 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.support.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -12,12 +12,12 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.support.http.Scheme;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.test.MockTextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -9,11 +9,11 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.watcher.support.http.Scheme;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.hamcrest.Matchers.arrayContaining;
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.notification.pagerduty;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.notification.slack.message.SlackMessageDefaultsTests;
|
||||
import org.junit.Before;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.notification.slack;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.notification.slack.message.SlackMessageDefaultsTests;
|
||||
import org.junit.Before;
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.watcher.support.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.watcher.test.MockTextTemplateEngine;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -60,7 +60,7 @@ public abstract class XPackRestTestCase extends ESRestTestCase {
|
|||
null,
|
||||
url.getHost(),
|
||||
url.getPort(),
|
||||
"/_watcher/_start", null, null));
|
||||
"/_xpack/watcher/_start", null, null));
|
||||
request.addHeader("Authorization", BASIC_AUTH_VALUE);
|
||||
try (CloseableHttpResponse response = client.execute(request)) {
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public abstract class XPackRestTestCase extends ESRestTestCase {
|
|||
null,
|
||||
url.getHost(),
|
||||
url.getPort(),
|
||||
"/_watcher/_stop", null, null));
|
||||
"/_xpack/watcher/_stop", null, null));
|
||||
request.addHeader("Authorization", BASIC_AUTH_VALUE);
|
||||
try (CloseableHttpResponse response = client.execute(request)) {
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue