Merge branch 'master' into feature/http_client
Original commit: elastic/x-pack-elasticsearch@9c8cfc915f
This commit is contained in:
commit
966fff2009
|
@ -14,7 +14,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.script.ScriptContextRegistry;
|
||||
import org.elasticsearch.script.ScriptEngineRegistry;
|
||||
import org.elasticsearch.script.ScriptEngineService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.script.ScriptSettings;
|
||||
import org.elasticsearch.script.groovy.GroovyScriptEngineService;
|
||||
|
@ -25,8 +24,7 @@ import org.junit.Ignore;
|
|||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Collections;
|
||||
|
||||
@Ignore // not a test.
|
||||
@SuppressForbidden(reason = "gradle is broken and tries to run me as a test")
|
||||
|
@ -38,19 +36,13 @@ public final class MessyTestUtils {
|
|||
.put("path.home", LuceneTestCase.createTempDir())
|
||||
.build();
|
||||
GroovyScriptEngineService groovyScriptEngineService = new GroovyScriptEngineService(settings);
|
||||
Set<ScriptEngineService> engineServiceSet = new HashSet<>();
|
||||
engineServiceSet.add(groovyScriptEngineService);
|
||||
ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(
|
||||
Arrays.asList(
|
||||
new ScriptEngineRegistry.ScriptEngineRegistration(GroovyScriptEngineService.class, GroovyScriptEngineService.NAME)
|
||||
)
|
||||
);
|
||||
ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singleton(groovyScriptEngineService));
|
||||
ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Arrays.asList(ScriptServiceProxy.INSTANCE));
|
||||
|
||||
ClusterService clusterService = Mockito.mock(ClusterService.class);
|
||||
Mockito.when(clusterService.state()).thenReturn(ClusterState.builder(new ClusterName("_name")).build());
|
||||
ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
|
||||
return ScriptServiceProxy.of(new ScriptService(settings, new Environment(settings), engineServiceSet,
|
||||
return ScriptServiceProxy.of(new ScriptService(settings, new Environment(settings),
|
||||
new ResourceWatcherService(settings, tp), scriptEngineRegistry, scriptContextRegistry, scriptSettings),
|
||||
clusterService);
|
||||
}
|
||||
|
|
|
@ -49,18 +49,14 @@ public class WatcherTemplateTests extends ESTestCase {
|
|||
public void init() throws Exception {
|
||||
Settings setting = Settings.builder().put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING, true).build();
|
||||
Environment environment = Mockito.mock(Environment.class);
|
||||
Set<ScriptEngineService> engines = Collections.singleton(new MustacheScriptEngineService(setting));
|
||||
ResourceWatcherService resourceWatcherService = Mockito.mock(ResourceWatcherService.class);
|
||||
ScriptContextRegistry registry = new ScriptContextRegistry(Collections.singletonList(ScriptServiceProxy.INSTANCE));
|
||||
|
||||
ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(
|
||||
Arrays.asList(
|
||||
new ScriptEngineRegistry.ScriptEngineRegistration(MustacheScriptEngineService.class,
|
||||
MustacheScriptEngineService.NAME)
|
||||
)
|
||||
Collections.singleton(new MustacheScriptEngineService(setting))
|
||||
);
|
||||
ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, registry);
|
||||
ScriptService scriptService = new ScriptService(setting, environment, engines, resourceWatcherService, scriptEngineRegistry,
|
||||
ScriptService scriptService = new ScriptService(setting, environment, resourceWatcherService, scriptEngineRegistry,
|
||||
registry, scriptSettings);
|
||||
ClusterService clusterService = Mockito.mock(ClusterService.class);
|
||||
Mockito.when(clusterService.state()).thenReturn(ClusterState.builder(new ClusterName("_name")).build());
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.elasticsearch.xpack.graph.rest.action.RestGraphAction;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Graph extends Plugin {
|
||||
|
||||
|
@ -31,16 +32,6 @@ public class Graph extends Plugin {
|
|||
public Graph(Settings settings) {
|
||||
this.transportClientMode = XPackPlugin.transportClientMode(settings);
|
||||
enabled = enabled(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Elasticsearch Graph Plugin";
|
||||
}
|
||||
|
||||
public static boolean enabled(Settings settings) {
|
||||
|
@ -69,10 +60,12 @@ public class Graph extends Plugin {
|
|||
if (enabled && transportClientMode == false) {
|
||||
module.registerRestHandler(RestGraphAction.class);
|
||||
}
|
||||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
module.registerSetting(Setting.boolSetting(XPackPlugin.featureEnabledSetting(NAME), true, Setting.Property.NodeScope));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Setting<?>> getSettings() {
|
||||
return Collections.singletonList(Setting.boolSetting(XPackPlugin.featureEnabledSetting(NAME), true, Setting.Property.NodeScope));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.index.query.QueryBuilders;
|
|||
import org.elasticsearch.index.query.ScriptQueryBuilder;
|
||||
import org.elasticsearch.marvel.Monitoring;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.plugins.ScriptPlugin;
|
||||
import org.elasticsearch.script.AbstractSearchScript;
|
||||
import org.elasticsearch.script.ExecutableScript;
|
||||
import org.elasticsearch.script.NativeScriptFactory;
|
||||
|
@ -34,6 +35,8 @@ import org.elasticsearch.xpack.graph.action.Vertex;
|
|||
import org.elasticsearch.xpack.graph.action.VertexRequest;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
||||
|
@ -346,19 +349,10 @@ public class GraphTests extends ESSingleNodeTestCase {
|
|||
assertThat(why, strongVertex.getWeight(), greaterThan(weakVertex.getWeight()));
|
||||
}
|
||||
|
||||
public static class ScriptedTimeoutPlugin extends Plugin {
|
||||
public static class ScriptedTimeoutPlugin extends Plugin implements ScriptPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "test-scripted-graph-timeout";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Test for scripted timeouts on graph searches";
|
||||
}
|
||||
|
||||
public void onModule(ScriptModule module) {
|
||||
module.registerScript(NativeTestScriptedTimeout.TEST_NATIVE_SCRIPT_TIMEOUT, NativeTestScriptedTimeout.Factory.class);
|
||||
public List<NativeScriptFactory> getNativeScripts() {
|
||||
return Collections.singletonList(new NativeTestScriptedTimeout.Factory());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,6 +371,11 @@ public class GraphTests extends ESSingleNodeTestCase {
|
|||
public boolean needsScores() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return TEST_NATIVE_SCRIPT_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.license.plugin.rest.RestPutLicenseAction;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.xpack.XPackPlugin.isTribeClientNode;
|
||||
import static org.elasticsearch.xpack.XPackPlugin.isTribeNode;
|
||||
|
@ -80,8 +81,8 @@ public class Licensing {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
public List<Setting<?>> getSettings() {
|
||||
// TODO convert this wildcard to a real setting
|
||||
module.registerSetting(Setting.groupSetting("license.", Setting.Property.NodeScope));
|
||||
return Collections.singletonList(Setting.groupSetting("license.", Setting.Property.NodeScope));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,11 +28,6 @@ public class EagerLicenseRegistrationConsumerPlugin extends TestConsumerPluginBa
|
|||
return EagerLicenseRegistrationPluginService.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String pluginName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id() {
|
||||
return EagerLicenseRegistrationPluginService.ID;
|
||||
|
|
|
@ -16,8 +16,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
*/
|
||||
public class LazyLicenseRegistrationConsumerPlugin extends TestConsumerPluginBase {
|
||||
|
||||
public static String NAME = "test_consumer_plugin_2";
|
||||
|
||||
@Inject
|
||||
public LazyLicenseRegistrationConsumerPlugin(Settings settings) {
|
||||
super(settings);
|
||||
|
@ -28,11 +26,6 @@ public class LazyLicenseRegistrationConsumerPlugin extends TestConsumerPluginBas
|
|||
return LazyLicenseRegistrationPluginService.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String pluginName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id() {
|
||||
return LazyLicenseRegistrationPluginService.ID;
|
||||
|
|
|
@ -14,7 +14,9 @@ import org.elasticsearch.common.settings.SettingsModule;
|
|||
import org.elasticsearch.plugins.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class TestConsumerPluginBase extends Plugin {
|
||||
|
||||
|
@ -24,17 +26,6 @@ public abstract class TestConsumerPluginBase extends Plugin {
|
|||
this.isEnabled = TransportClient.CLIENT_TYPE.equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey())) == false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return pluginName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "test licensing consumer plugin";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<>();
|
||||
|
@ -44,18 +35,14 @@ public abstract class TestConsumerPluginBase extends Plugin {
|
|||
return services;
|
||||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
try {
|
||||
module.registerSetting(Setting.simpleString("_trial_license_duration_in_seconds", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("_grace_duration_in_seconds", Setting.Property.NodeScope));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// already loaded
|
||||
}
|
||||
@Override
|
||||
public List<Setting<?>> getSettings() {
|
||||
return Arrays.asList(Setting.simpleString("_trial_license_duration_in_seconds", Setting.Property.NodeScope,
|
||||
Setting.Property.Shared), Setting.simpleString("_grace_duration_in_seconds", Setting.Property.NodeScope,
|
||||
Setting.Property.Shared));
|
||||
}
|
||||
|
||||
public abstract Class<? extends TestPluginServiceBase> service();
|
||||
|
||||
protected abstract String pluginName();
|
||||
|
||||
public abstract String id();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.elasticsearch.action.ActionModule;
|
|||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.marvel.action.MonitoringBulkAction;
|
||||
|
@ -80,7 +81,6 @@ public class Monitoring {
|
|||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
MonitoringSettings.register(module);
|
||||
}
|
||||
|
||||
public void onModule(ActionModule module) {
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.common.settings.SettingsModule;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
@ -125,22 +126,23 @@ public class MonitoringSettings extends AbstractComponent {
|
|||
public static final Setting<Settings> EXPORTERS_SETTINGS =
|
||||
groupSetting(key("agent.exporters."), Property.Dynamic, Property.NodeScope);
|
||||
|
||||
static void register(SettingsModule module) {
|
||||
module.registerSetting(INDICES);
|
||||
module.registerSetting(INTERVAL);
|
||||
module.registerSetting(INDEX_RECOVERY_TIMEOUT);
|
||||
module.registerSetting(INDEX_STATS_TIMEOUT);
|
||||
module.registerSetting(INDICES_STATS_TIMEOUT);
|
||||
module.registerSetting(INDEX_RECOVERY_ACTIVE_ONLY);
|
||||
module.registerSetting(COLLECTORS);
|
||||
module.registerSetting(CLUSTER_STATE_TIMEOUT);
|
||||
module.registerSetting(CLUSTER_STATS_TIMEOUT);
|
||||
module.registerSetting(HISTORY_DURATION);
|
||||
module.registerSetting(EXPORTERS_SETTINGS);
|
||||
module.registerSetting(ENABLED);
|
||||
public static List<Setting<?>> getSettings() {
|
||||
return Arrays.asList(INDICES,
|
||||
INTERVAL,
|
||||
INDEX_RECOVERY_TIMEOUT,
|
||||
INDEX_STATS_TIMEOUT,
|
||||
INDICES_STATS_TIMEOUT,
|
||||
INDEX_RECOVERY_ACTIVE_ONLY,
|
||||
COLLECTORS,
|
||||
CLUSTER_STATE_TIMEOUT,
|
||||
CLUSTER_STATS_TIMEOUT,
|
||||
HISTORY_DURATION,
|
||||
EXPORTERS_SETTINGS,
|
||||
ENABLED);
|
||||
}
|
||||
|
||||
module.registerSettingsFilter("xpack.monitoring.agent.exporters.*.auth.*");
|
||||
module.registerSettingsFilter("xpack.monitoring.agent.exporters.*.ssl.*");
|
||||
public static List<String> getSettingsFilter() {
|
||||
return Arrays.asList("xpack.monitoring.agent.exporters.*.auth.*", "xpack.monitoring.agent.exporters.*.ssl.*");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public class MarvelPluginTests extends MarvelIntegTestCase {
|
|||
for (PluginInfo plugin : nodeInfo.getPlugins().getPluginInfos()) {
|
||||
assertNotNull(plugin);
|
||||
|
||||
if (XPackPlugin.NAME.equals(plugin.getName())) {
|
||||
if (XPackPlugin.class.getName().equals(plugin.getName())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.elasticsearch.common.regex.Regex;
|
|||
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.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.index.IndexModule;
|
||||
import org.elasticsearch.shield.action.ShieldActionModule;
|
||||
|
@ -188,62 +187,70 @@ public class Security {
|
|||
return settingsBuilder.build();
|
||||
}
|
||||
|
||||
public void onModule(SettingsModule settingsModule) {
|
||||
public List<Setting<?>> getSettings() {
|
||||
List<Setting<?>> settingsList = new ArrayList<>();
|
||||
// always register for both client and node modes
|
||||
XPackPlugin.registerFeatureEnabledSettings(settingsModule, NAME, true);
|
||||
settingsModule.registerSetting(USER_SETTING);
|
||||
XPackPlugin.addFeatureEnabledSettings(settingsList, NAME, true);
|
||||
settingsList.add(USER_SETTING);
|
||||
|
||||
// SSL settings
|
||||
SSLConfiguration.Global.registerSettings(settingsModule);
|
||||
SSLConfiguration.Global.addSettings(settingsList);
|
||||
|
||||
// transport settings
|
||||
ShieldNettyTransport.registerSettings(settingsModule);
|
||||
ShieldNettyTransport.addSettings(settingsList);
|
||||
|
||||
if (transportClientMode) {
|
||||
return;
|
||||
return settingsList;
|
||||
}
|
||||
|
||||
// The following just apply in node mode
|
||||
XPackPlugin.registerFeatureEnabledSettings(settingsModule, DLS_FLS_FEATURE, true);
|
||||
XPackPlugin.addFeatureEnabledSettings(settingsList, DLS_FLS_FEATURE, true);
|
||||
|
||||
// IP Filter settings
|
||||
IPFilter.registerSettings(settingsModule);
|
||||
IPFilter.addSettings(settingsList);
|
||||
|
||||
// audit settings
|
||||
AuditTrailModule.registerSettings(settingsModule);
|
||||
AuditTrailModule.addSettings(settingsList);
|
||||
|
||||
// authentication settings
|
||||
FileRolesStore.registerSettings(settingsModule);
|
||||
AnonymousUser.registerSettings(settingsModule);
|
||||
Realms.registerSettings(settingsModule);
|
||||
NativeUsersStore.registerSettings(settingsModule);
|
||||
NativeRolesStore.registerSettings(settingsModule);
|
||||
InternalAuthenticationService.registerSettings(settingsModule);
|
||||
InternalAuthorizationService.registerSettings(settingsModule);
|
||||
FileRolesStore.addSettings(settingsList);
|
||||
AnonymousUser.addSettings(settingsList);
|
||||
Realms.addSettings(settingsList);
|
||||
NativeUsersStore.addSettings(settingsList);
|
||||
NativeRolesStore.addSettings(settingsList);
|
||||
InternalAuthenticationService.addSettings(settingsList);
|
||||
InternalAuthorizationService.addSettings(settingsList);
|
||||
|
||||
// HTTP settings
|
||||
ShieldNettyHttpServerTransport.registerSettings(settingsModule);
|
||||
ShieldNettyHttpServerTransport.addSettings(settingsList);
|
||||
|
||||
// encryption settings
|
||||
InternalCryptoService.registerSettings(settingsModule);
|
||||
InternalCryptoService.addSettings(settingsList);
|
||||
|
||||
// hide settings
|
||||
settingsModule.registerSetting(Setting.listSetting(setting("hide_settings"), Collections.emptyList(), Function.identity(),
|
||||
settingsList.add(Setting.listSetting(setting("hide_settings"), Collections.emptyList(), Function.identity(),
|
||||
Property.NodeScope, Property.Filtered));
|
||||
return settingsList;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSettingsFilter() {
|
||||
ArrayList<String> settingsFilter = new ArrayList<>();
|
||||
String[] asArray = settings.getAsArray(setting("hide_settings"));
|
||||
for (String pattern : asArray) {
|
||||
settingsModule.registerSettingsFilter(pattern);
|
||||
settingsFilter.add(pattern);
|
||||
}
|
||||
|
||||
settingsModule.registerSettingsFilter(setting("authc.realms.*.bind_dn"));
|
||||
settingsModule.registerSettingsFilter(setting("authc.realms.*.bind_password"));
|
||||
settingsModule.registerSettingsFilter(setting("authc.realms.*." + SessionFactory.HOSTNAME_VERIFICATION_SETTING));
|
||||
settingsModule.registerSettingsFilter(setting("authc.realms.*.truststore.password"));
|
||||
settingsModule.registerSettingsFilter(setting("authc.realms.*.truststore.path"));
|
||||
settingsModule.registerSettingsFilter(setting("authc.realms.*.truststore.algorithm"));
|
||||
settingsFilter.add(setting("authc.realms.*.bind_dn"));
|
||||
settingsFilter.add(setting("authc.realms.*.bind_password"));
|
||||
settingsFilter.add(setting("authc.realms.*." + SessionFactory.HOSTNAME_VERIFICATION_SETTING));
|
||||
settingsFilter.add(setting("authc.realms.*.truststore.password"));
|
||||
settingsFilter.add(setting("authc.realms.*.truststore.path"));
|
||||
settingsFilter.add(setting("authc.realms.*.truststore.algorithm"));
|
||||
|
||||
// hide settings where we don't define them - they are part of a group...
|
||||
settingsModule.registerSettingsFilter("transport.profiles.*." + setting("*"));
|
||||
settingsFilter.add("transport.profiles.*." + setting("*"));
|
||||
return settingsFilter;
|
||||
}
|
||||
|
||||
public void onIndexModule(IndexModule module) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.elasticsearch.common.inject.multibindings.Multibinder;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.shield.action.filter.ShieldActionFilter;
|
||||
import org.elasticsearch.shield.action.interceptor.BulkRequestInterceptor;
|
||||
import org.elasticsearch.shield.action.interceptor.FieldStatsRequestInterceptor;
|
||||
import org.elasticsearch.shield.action.interceptor.RealtimeRequestInterceptor;
|
||||
import org.elasticsearch.shield.action.interceptor.RequestInterceptor;
|
||||
import org.elasticsearch.shield.action.interceptor.SearchRequestInterceptor;
|
||||
|
@ -34,5 +35,6 @@ public class ShieldActionModule extends AbstractShieldModule.Node {
|
|||
multibinder.addBinding().to(SearchRequestInterceptor.class);
|
||||
multibinder.addBinding().to(UpdateRequestInterceptor.class);
|
||||
multibinder.addBinding().to(BulkRequestInterceptor.class);
|
||||
multibinder.addBinding().to(FieldStatsRequestInterceptor.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,12 +47,14 @@ public abstract class FieldAndDocumentLevelSecurityRequestInterceptor<Request> e
|
|||
for (String index : indicesRequest.indices()) {
|
||||
IndicesAccessControl.IndexAccessControl indexAccessControl = indicesAccessControl.getIndexPermissions(index);
|
||||
if (indexAccessControl != null) {
|
||||
boolean fls = indexAccessControl.getFields() != null;
|
||||
boolean dls = indexAccessControl.getQueries() != null;
|
||||
if (fls || dls) {
|
||||
logger.debug("intercepted request for index [{}] with field level or document level security enabled, " +
|
||||
"disabling features", index);
|
||||
disableFeatures(request);
|
||||
boolean fieldLevelSecurityEnabled = indexAccessControl.getFields() != null;
|
||||
boolean documentLevelSecurityEnabled = indexAccessControl.getQueries() != null;
|
||||
if (fieldLevelSecurityEnabled || documentLevelSecurityEnabled) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("intercepted request for index [{}] with field level [{}] or document level [{}] security "
|
||||
+ "enabled, disabling features", index, fieldLevelSecurityEnabled, documentLevelSecurityEnabled);
|
||||
}
|
||||
disableFeatures(request, fieldLevelSecurityEnabled, documentLevelSecurityEnabled);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +64,6 @@ public abstract class FieldAndDocumentLevelSecurityRequestInterceptor<Request> e
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract void disableFeatures(Request request);
|
||||
protected abstract void disableFeatures(Request request, boolean fieldLevelSecurityEnabled, boolean documentLevelSecurityEnabled);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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.shield.action.interceptor;
|
||||
|
||||
import org.elasticsearch.action.fieldstats.FieldStatsRequest;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportRequest;
|
||||
|
||||
/**
|
||||
* Intercepts requests to shards to field level stats and strips fields that the user is not allowed to access from the response.
|
||||
*/
|
||||
public class FieldStatsRequestInterceptor extends FieldAndDocumentLevelSecurityRequestInterceptor<FieldStatsRequest> {
|
||||
@Inject
|
||||
public FieldStatsRequestInterceptor(Settings settings, ThreadPool threadPool) {
|
||||
super(settings, threadPool.getThreadContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(TransportRequest request) {
|
||||
return request instanceof FieldStatsRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disableFeatures(FieldStatsRequest request, boolean fieldLevelSecurityEnabled, boolean documentLevelSecurityEnabled) {
|
||||
if (fieldLevelSecurityEnabled) {
|
||||
request.setUseCache(false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,7 +23,8 @@ public class RealtimeRequestInterceptor extends FieldAndDocumentLevelSecurityReq
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void disableFeatures(RealtimeRequest realtimeRequest) {
|
||||
protected void disableFeatures(RealtimeRequest realtimeRequest, boolean fieldLevelSecurityEnabled,
|
||||
boolean documentLevelSecurityEnabled) {
|
||||
realtimeRequest.realtime(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public class SearchRequestInterceptor extends FieldAndDocumentLevelSecurityReque
|
|||
}
|
||||
|
||||
@Override
|
||||
public void disableFeatures(SearchRequest request) {
|
||||
public void disableFeatures(SearchRequest request, boolean fieldLevelSecurityEnabled, boolean documentLevelSecurityEnabled) {
|
||||
request.requestCache(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class UpdateRequestInterceptor extends FieldAndDocumentLevelSecurityReque
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void disableFeatures(UpdateRequest updateRequest) {
|
||||
protected void disableFeatures(UpdateRequest updateRequest, boolean fieldLevelSecurityEnabled, boolean documentLevelSecurityEnabled) {
|
||||
throw new ElasticsearchSecurityException("Can't execute an update request if field or document level security is enabled",
|
||||
RestStatus.BAD_REQUEST);
|
||||
}
|
||||
|
|
|
@ -102,10 +102,10 @@ public class AuditTrailModule extends AbstractShieldModule.Node {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(ENABLED_SETTING);
|
||||
settingsModule.registerSetting(OUTPUTS_SETTING);
|
||||
LoggingAuditTrail.registerSettings(settingsModule);
|
||||
IndexAuditTrail.registerSettings(settingsModule);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(ENABLED_SETTING);
|
||||
settings.add(OUTPUTS_SETTING);
|
||||
LoggingAuditTrail.registerSettings(settings);
|
||||
IndexAuditTrail.registerSettings(settings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -877,15 +877,15 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(INDEX_SETTINGS);
|
||||
settingsModule.registerSetting(EXCLUDE_EVENT_SETTINGS);
|
||||
settingsModule.registerSetting(INCLUDE_EVENT_SETTINGS);
|
||||
settingsModule.registerSetting(ROLLOVER_SETTING);
|
||||
settingsModule.registerSetting(BULK_SIZE_SETTING);
|
||||
settingsModule.registerSetting(FLUSH_TIMEOUT_SETTING);
|
||||
settingsModule.registerSetting(QUEUE_SIZE_SETTING);
|
||||
settingsModule.registerSetting(REMOTE_CLIENT_SETTINGS);
|
||||
public static void registerSettings(List<Setting<?>> settings) {
|
||||
settings.add(INDEX_SETTINGS);
|
||||
settings.add(EXCLUDE_EVENT_SETTINGS);
|
||||
settings.add(INCLUDE_EVENT_SETTINGS);
|
||||
settings.add(ROLLOVER_SETTING);
|
||||
settings.add(BULK_SIZE_SETTING);
|
||||
settings.add(FLUSH_TIMEOUT_SETTING);
|
||||
settings.add(QUEUE_SIZE_SETTING);
|
||||
settings.add(REMOTE_CLIENT_SETTINGS);
|
||||
}
|
||||
|
||||
private class QueueConsumer extends Thread {
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.transport.TransportMessage;
|
|||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.Strings.arrayToCommaDelimitedString;
|
||||
import static org.elasticsearch.shield.audit.AuditUtil.indices;
|
||||
|
@ -463,9 +464,9 @@ public class LoggingAuditTrail extends AbstractLifecycleComponent<LoggingAuditTr
|
|||
return builder.append(user.principal()).append("]").toString();
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(HOST_ADDRESS_SETTING);
|
||||
settingsModule.registerSetting(HOST_NAME_SETTING);
|
||||
settingsModule.registerSetting(NODE_NAME_SETTING);
|
||||
public static void registerSettings(List<Setting<?>> settings) {
|
||||
settings.add(HOST_ADDRESS_SETTING);
|
||||
settings.add(HOST_NAME_SETTING);
|
||||
settings.add(NODE_NAME_SETTING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.transport.TransportMessage;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.shield.Security.setting;
|
||||
import static org.elasticsearch.shield.support.Exceptions.authenticationError;
|
||||
|
@ -316,9 +317,9 @@ public class InternalAuthenticationService extends AbstractComponent implements
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(SIGN_USER_HEADER);
|
||||
settingsModule.registerSetting(RUN_AS_ENABLED);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(SIGN_USER_HEADER);
|
||||
settings.add(RUN_AS_ENABLED);
|
||||
}
|
||||
|
||||
// these methods are package private for testing. They are also needed so that a AuditableRequest can be created in tests
|
||||
|
|
|
@ -212,7 +212,7 @@ public class Realms extends AbstractLifecycleComponent<Realms> implements Iterab
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(REALMS_GROUPS_SETTINGS);
|
||||
public static void addSettings(List<Setting<?>> settingsModule) {
|
||||
settingsModule.add(REALMS_GROUPS_SETTINGS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -867,9 +867,9 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
|
|||
void onUsersChanged(List<String> username);
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(SCROLL_SIZE_SETTING);
|
||||
settingsModule.registerSetting(SCROLL_KEEP_ALIVE_SETTING);
|
||||
settingsModule.registerSetting(POLL_INTERVAL_SETTING);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(SCROLL_SIZE_SETTING);
|
||||
settings.add(SCROLL_KEEP_ALIVE_SETTING);
|
||||
settings.add(POLL_INTERVAL_SETTING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -357,7 +357,7 @@ public class InternalAuthorizationService extends AbstractComponent implements A
|
|||
return authorizationError("action [{}] is unauthorized for user [{}]", action, user.principal());
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(ANONYMOUS_AUTHORIZATION_EXCEPTION_SETTING);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(ANONYMOUS_AUTHORIZATION_EXCEPTION_SETTING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ public class FileRolesStore extends AbstractLifecycleComponent<RolesStore> imple
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(ROLES_FILE_SETTING);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(ROLES_FILE_SETTING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.common.inject.Provider;
|
|||
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.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
@ -604,9 +603,9 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(SCROLL_SIZE_SETTING);
|
||||
settingsModule.registerSetting(SCROLL_KEEP_ALIVE_SETTING);
|
||||
settingsModule.registerSetting(POLL_INTERVAL_SETTING);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(SCROLL_SIZE_SETTING);
|
||||
settings.add(SCROLL_KEEP_ALIVE_SETTING);
|
||||
settings.add(POLL_INTERVAL_SETTING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -676,10 +676,10 @@ public class InternalCryptoService extends AbstractLifecycleComponent<InternalCr
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(FILE_SETTING);
|
||||
settingsModule.registerSetting(ENCRYPTION_KEY_LENGTH_SETTING);
|
||||
settingsModule.registerSetting(ENCRYPTION_KEY_ALGO_SETTING);
|
||||
settingsModule.registerSetting(ENCRYPTION_ALGO_SETTING);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(FILE_SETTING);
|
||||
settings.add(ENCRYPTION_KEY_LENGTH_SETTING);
|
||||
settings.add(ENCRYPTION_KEY_ALGO_SETTING);
|
||||
settings.add(ENCRYPTION_ALGO_SETTING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,25 +147,25 @@ public abstract class SSLConfiguration {
|
|||
static final Setting<Boolean> INCLUDE_JDK_CERTS_SETTING = Setting.boolSetting(globalKey(Custom.INCLUDE_JDK_CERTS_SETTING), true,
|
||||
Property.NodeScope, Property.Filtered);
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(Global.CIPHERS_SETTING);
|
||||
settingsModule.registerSetting(Global.SUPPORTED_PROTOCOLS_SETTING);
|
||||
settingsModule.registerSetting(Global.KEYSTORE_PATH_SETTING);
|
||||
settingsModule.registerSetting(Global.KEYSTORE_PASSWORD_SETTING);
|
||||
settingsModule.registerSetting(Global.KEYSTORE_ALGORITHM_SETTING);
|
||||
settingsModule.registerSetting(Global.KEYSTORE_KEY_PASSWORD_SETTING);
|
||||
settingsModule.registerSetting(Global.KEY_PATH_SETTING);
|
||||
settingsModule.registerSetting(Global.KEY_PASSWORD_SETTING);
|
||||
settingsModule.registerSetting(Global.CERT_SETTING);
|
||||
settingsModule.registerSetting(Global.TRUSTSTORE_PATH_SETTING);
|
||||
settingsModule.registerSetting(Global.TRUSTSTORE_PASSWORD_SETTING);
|
||||
settingsModule.registerSetting(Global.TRUSTSTORE_ALGORITHM_SETTING);
|
||||
settingsModule.registerSetting(Global.PROTOCOL_SETTING);
|
||||
settingsModule.registerSetting(Global.SESSION_CACHE_SIZE_SETTING);
|
||||
settingsModule.registerSetting(Global.SESSION_CACHE_TIMEOUT_SETTING);
|
||||
settingsModule.registerSetting(Global.CA_PATHS_SETTING);
|
||||
settingsModule.registerSetting(Global.INCLUDE_JDK_CERTS_SETTING);
|
||||
settingsModule.registerSetting(Global.RELOAD_ENABLED_SETTING);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(Global.CIPHERS_SETTING);
|
||||
settings.add(Global.SUPPORTED_PROTOCOLS_SETTING);
|
||||
settings.add(Global.KEYSTORE_PATH_SETTING);
|
||||
settings.add(Global.KEYSTORE_PASSWORD_SETTING);
|
||||
settings.add(Global.KEYSTORE_ALGORITHM_SETTING);
|
||||
settings.add(Global.KEYSTORE_KEY_PASSWORD_SETTING);
|
||||
settings.add(Global.KEY_PATH_SETTING);
|
||||
settings.add(Global.KEY_PASSWORD_SETTING);
|
||||
settings.add(Global.CERT_SETTING);
|
||||
settings.add(Global.TRUSTSTORE_PATH_SETTING);
|
||||
settings.add(Global.TRUSTSTORE_PASSWORD_SETTING);
|
||||
settings.add(Global.TRUSTSTORE_ALGORITHM_SETTING);
|
||||
settings.add(Global.PROTOCOL_SETTING);
|
||||
settings.add(Global.SESSION_CACHE_SIZE_SETTING);
|
||||
settings.add(Global.SESSION_CACHE_TIMEOUT_SETTING);
|
||||
settings.add(Global.CA_PATHS_SETTING);
|
||||
settings.add(Global.INCLUDE_JDK_CERTS_SETTING);
|
||||
settings.add(Global.RELOAD_ENABLED_SETTING);
|
||||
}
|
||||
|
||||
private final KeyConfig keyConfig;
|
||||
|
|
|
@ -260,13 +260,13 @@ public class IPFilter {
|
|||
updateRules();
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(ALLOW_BOUND_ADDRESSES_SETTING);
|
||||
settingsModule.registerSetting(IP_FILTER_ENABLED_SETTING);
|
||||
settingsModule.registerSetting(IP_FILTER_ENABLED_HTTP_SETTING);
|
||||
settingsModule.registerSetting(HTTP_FILTER_ALLOW_SETTING);
|
||||
settingsModule.registerSetting(HTTP_FILTER_DENY_SETTING);
|
||||
settingsModule.registerSetting(TRANSPORT_FILTER_ALLOW_SETTING);
|
||||
settingsModule.registerSetting(TRANSPORT_FILTER_DENY_SETTING);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(ALLOW_BOUND_ADDRESSES_SETTING);
|
||||
settings.add(IP_FILTER_ENABLED_SETTING);
|
||||
settings.add(IP_FILTER_ENABLED_HTTP_SETTING);
|
||||
settings.add(HTTP_FILTER_ALLOW_SETTING);
|
||||
settings.add(HTTP_FILTER_DENY_SETTING);
|
||||
settings.add(TRANSPORT_FILTER_ALLOW_SETTING);
|
||||
settings.add(TRANSPORT_FILTER_DENY_SETTING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.jboss.netty.handler.ssl.SslHandler;
|
|||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_COMPRESSION;
|
||||
import static org.elasticsearch.shield.Security.setting;
|
||||
|
@ -128,10 +129,10 @@ public class ShieldNettyHttpServerTransport extends NettyHttpServerTransport {
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(SSL_SETTING);
|
||||
settingsModule.registerSetting(CLIENT_AUTH_SETTING);
|
||||
settingsModule.registerSetting(DEPRECATED_SSL_SETTING);
|
||||
public static void addSettings(List<Setting<?>> settings) {
|
||||
settings.add(SSL_SETTING);
|
||||
settings.add(CLIENT_AUTH_SETTING);
|
||||
settings.add(DEPRECATED_SSL_SETTING);
|
||||
}
|
||||
|
||||
public static void overrideSettings(Settings.Builder settingsBuilder, Settings settings) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.jboss.netty.handler.ssl.SslHandler;
|
|||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLParameters;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.shield.Security.featureEnabledSetting;
|
||||
import static org.elasticsearch.shield.Security.setting;
|
||||
|
@ -249,17 +250,17 @@ public class ShieldNettyTransport extends NettyTransport {
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(SSL_SETTING);
|
||||
settingsModule.registerSetting(HOSTNAME_VERIFICATION_SETTING);
|
||||
settingsModule.registerSetting(HOSTNAME_VERIFICATION_RESOLVE_NAME_SETTING);
|
||||
settingsModule.registerSetting(CLIENT_AUTH_SETTING);
|
||||
settingsModule.registerSetting(PROFILE_SSL_SETTING);
|
||||
settingsModule.registerSetting(PROFILE_CLIENT_AUTH_SETTING);
|
||||
public static void addSettings(List<Setting<?>> settingsModule) {
|
||||
settingsModule.add(SSL_SETTING);
|
||||
settingsModule.add(HOSTNAME_VERIFICATION_SETTING);
|
||||
settingsModule.add(HOSTNAME_VERIFICATION_RESOLVE_NAME_SETTING);
|
||||
settingsModule.add(CLIENT_AUTH_SETTING);
|
||||
settingsModule.add(PROFILE_SSL_SETTING);
|
||||
settingsModule.add(PROFILE_CLIENT_AUTH_SETTING);
|
||||
|
||||
// deprecated transport settings
|
||||
settingsModule.registerSetting(DEPRECATED_SSL_SETTING);
|
||||
settingsModule.registerSetting(DEPRECATED_PROFILE_SSL_SETTING);
|
||||
settingsModule.registerSetting(DEPRECATED_HOSTNAME_VERIFICATION_SETTING);
|
||||
settingsModule.add(DEPRECATED_SSL_SETTING);
|
||||
settingsModule.add(DEPRECATED_PROFILE_SSL_SETTING);
|
||||
settingsModule.add(DEPRECATED_HOSTNAME_VERIFICATION_SETTING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.shield.user.User.ReservedUser;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -80,8 +81,12 @@ public class AnonymousUser extends ReservedUser {
|
|||
return roles;
|
||||
}
|
||||
|
||||
public static void registerSettings(SettingsModule settingsModule) {
|
||||
settingsModule.registerSetting(USERNAME_SETTING);
|
||||
settingsModule.registerSetting(ROLES_SETTING);
|
||||
public static List<Setting<?>> getSettings() {
|
||||
return Arrays.asList();
|
||||
}
|
||||
|
||||
public static void addSettings(List<Setting<?>> settingsList) {
|
||||
settingsList.add(USERNAME_SETTING);
|
||||
settingsList.add(ROLES_SETTING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,15 +11,14 @@ import org.elasticsearch.common.inject.Injector;
|
|||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerModule;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.shield.audit.logfile.LoggingAuditTrail;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPoolModule;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.local.LocalTransport;
|
||||
|
||||
|
@ -36,8 +35,7 @@ public class AuditTrailModuleTests extends ESTestCase {
|
|||
.put("client.type", "node")
|
||||
.put(AuditTrailModule.ENABLED_SETTING.getKey(), false)
|
||||
.build();
|
||||
SettingsModule settingsModule = new SettingsModule(settings);
|
||||
settingsModule.registerSetting(AuditTrailModule.ENABLED_SETTING);
|
||||
SettingsModule settingsModule = new SettingsModule(settings, AuditTrailModule.ENABLED_SETTING);
|
||||
Injector injector = Guice.createInjector(settingsModule, new AuditTrailModule(settings));
|
||||
AuditTrail auditTrail = injector.getInstance(AuditTrail.class);
|
||||
assertThat(auditTrail, is(AuditTrail.NOOP));
|
||||
|
@ -58,8 +56,7 @@ public class AuditTrailModuleTests extends ESTestCase {
|
|||
.build();
|
||||
ThreadPool pool = new TestThreadPool("testLogFile");
|
||||
try {
|
||||
SettingsModule settingsModule = new SettingsModule(settings);
|
||||
settingsModule.registerSetting(AuditTrailModule.ENABLED_SETTING);
|
||||
SettingsModule settingsModule = new SettingsModule(settings, AuditTrailModule.ENABLED_SETTING);
|
||||
Injector injector = Guice.createInjector(
|
||||
settingsModule,
|
||||
new NetworkModule(new NetworkService(settings), settings, false, new NamedWriteableRegistry()) {
|
||||
|
@ -69,8 +66,11 @@ public class AuditTrailModuleTests extends ESTestCase {
|
|||
}
|
||||
},
|
||||
new AuditTrailModule(settings),
|
||||
new CircuitBreakerModule(settings),
|
||||
new ThreadPoolModule(pool),
|
||||
b -> {
|
||||
b.bind(CircuitBreakerService.class).toInstance(Node.createCircuitBreakerService(settingsModule.getSettings(),
|
||||
settingsModule.getClusterSettings()));
|
||||
b.bind(ThreadPool.class).toInstance(pool);
|
||||
},
|
||||
new Version.Module(Version.CURRENT)
|
||||
);
|
||||
AuditTrail auditTrail = injector.getInstance(AuditTrail.class);
|
||||
|
@ -90,9 +90,7 @@ public class AuditTrailModuleTests extends ESTestCase {
|
|||
.put(AuditTrailModule.OUTPUTS_SETTING.getKey() , "foo")
|
||||
.put("client.type", "node")
|
||||
.build();
|
||||
SettingsModule settingsModule = new SettingsModule(settings);
|
||||
settingsModule.registerSetting(AuditTrailModule.ENABLED_SETTING);
|
||||
settingsModule.registerSetting(AuditTrailModule.OUTPUTS_SETTING);
|
||||
SettingsModule settingsModule = new SettingsModule(settings, AuditTrailModule.ENABLED_SETTING, AuditTrailModule.OUTPUTS_SETTING);
|
||||
try {
|
||||
Guice.createInjector(settingsModule, new AuditTrailModule(settings));
|
||||
fail("Expect initialization to fail when an unknown audit trail output is configured");
|
||||
|
|
|
@ -116,16 +116,6 @@ public class TransportFilterTests extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public static class InternalPlugin extends Plugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "test-transport-filter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.<Module>singletonList(new TestTransportFilterModule());
|
||||
|
@ -289,14 +279,6 @@ public class TransportFilterTests extends ESIntegTestCase {
|
|||
// Sub class the Shield transport to always inject a mock for testing
|
||||
public static class InternalPluginServerTransportService extends ShieldServerTransportService {
|
||||
public static class TestPlugin extends Plugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-transport-service";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "a mock transport service for testing";
|
||||
}
|
||||
public void onModule(NetworkModule module) {
|
||||
module.registerTransportService("filter-mock", InternalPluginServerTransportService.class);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@ import org.elasticsearch.shield.ssl.SSLConfiguration;
|
|||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.hamcrest.Matcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
|
@ -85,13 +87,14 @@ public class SettingsFilterTests extends ESTestCase {
|
|||
.build();
|
||||
|
||||
XPackPlugin xPackPlugin = new XPackPlugin(settings);
|
||||
SettingsModule settingsModule = new SettingsModule(settings);
|
||||
List<Setting<?>> settingList = new ArrayList<>();
|
||||
settingList.add(Setting.simpleString("foo.bar", Setting.Property.NodeScope));
|
||||
settingList.add(Setting.simpleString("foo.baz", Setting.Property.NodeScope));
|
||||
settingList.add(Setting.simpleString("bar.baz", Setting.Property.NodeScope));
|
||||
settingList.add(Setting.simpleString("baz.foo", Setting.Property.NodeScope));
|
||||
settingList.addAll(xPackPlugin.getSettings());
|
||||
// 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);
|
||||
SettingsModule settingsModule = new SettingsModule(settings, settingList, xPackPlugin.getSettingsFilter());
|
||||
|
||||
Injector injector = Guice.createInjector(settingsModule);
|
||||
SettingsFilter settingsFilter = injector.getInstance(SettingsFilter.class);
|
||||
|
|
|
@ -151,7 +151,8 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase {
|
|||
// assertThat(nodeInfo.getPlugins().getInfos(), hasSize(2));
|
||||
Collection<String> pluginNames =
|
||||
nodeInfo.getPlugins().getPluginInfos().stream().map(p -> p.getName()).collect(Collectors.toList());
|
||||
assertThat("plugin [" + XPackPlugin.NAME + "] not found in [" + pluginNames + "]", pluginNames, hasItem(XPackPlugin.NAME));
|
||||
assertThat("plugin [" + xpackPluginClass().getName() + "] not found in [" + pluginNames + "]", pluginNames,
|
||||
hasItem(xpackPluginClass().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,16 +21,19 @@ import org.elasticsearch.env.Environment;
|
|||
import org.elasticsearch.index.IndexModule;
|
||||
import org.elasticsearch.license.plugin.Licensing;
|
||||
import org.elasticsearch.marvel.Monitoring;
|
||||
import org.elasticsearch.marvel.MonitoringSettings;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.plugins.ScriptPlugin;
|
||||
import org.elasticsearch.script.ScriptContext;
|
||||
import org.elasticsearch.script.ScriptModule;
|
||||
import org.elasticsearch.shield.Security;
|
||||
import org.elasticsearch.shield.authc.AuthenticationModule;
|
||||
import org.elasticsearch.threadpool.ExecutorBuilder;
|
||||
import org.elasticsearch.threadpool.ThreadPoolModule;
|
||||
import org.elasticsearch.xpack.action.TransportXPackInfoAction;
|
||||
import org.elasticsearch.xpack.action.TransportXPackUsageAction;
|
||||
import org.elasticsearch.xpack.action.XPackInfoAction;
|
||||
import org.elasticsearch.xpack.action.XPackUsageAction;
|
||||
import org.elasticsearch.xpack.common.ScriptServiceProxy;
|
||||
import org.elasticsearch.xpack.common.http.HttpClientModule;
|
||||
import org.elasticsearch.xpack.common.init.LazyInitializationModule;
|
||||
import org.elasticsearch.xpack.common.init.LazyInitializationService;
|
||||
|
@ -55,7 +58,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class XPackPlugin extends Plugin {
|
||||
public class XPackPlugin extends Plugin implements ScriptPlugin {
|
||||
|
||||
public static final String NAME = "x-pack";
|
||||
|
||||
|
@ -124,14 +127,6 @@ public class XPackPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public String name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override public String description() {
|
||||
return "Elastic X-Pack";
|
||||
}
|
||||
|
||||
// For tests only
|
||||
public Collection<Class<? extends XPackExtension>> getExtensions() {
|
||||
return Collections.emptyList();
|
||||
|
@ -182,26 +177,39 @@ public class XPackPlugin extends Plugin {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
public void onModule(ScriptModule module) {
|
||||
watcher.onModule(module);
|
||||
@Override
|
||||
public ScriptContext.Plugin getCustomScriptContexts() {
|
||||
return ScriptServiceProxy.INSTANCE;
|
||||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
@Override
|
||||
public List<Setting<?>> getSettings() {
|
||||
ArrayList<Setting<?>> settings = new ArrayList<>();
|
||||
settings.addAll(notification.getSettings());
|
||||
settings.addAll(security.getSettings());
|
||||
settings.addAll(MonitoringSettings.getSettings());
|
||||
settings.addAll(watcher.getSettings());
|
||||
settings.addAll(graph.getSettings());
|
||||
settings.addAll(licensing.getSettings());
|
||||
// we add the `xpack.version` setting to all internal indices
|
||||
module.registerSetting(Setting.simpleString("index.xpack.version", Setting.Property.IndexScope));
|
||||
settings.add(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));
|
||||
settings.add(Setting.simpleString("xpack.http.default_read_timeout", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.http.default_connection_timeout", Setting.Property.NodeScope));
|
||||
settings.add(Setting.groupSetting("xpack.http.ssl.", Setting.Property.NodeScope));
|
||||
settings.add(Setting.groupSetting("xpack.http.proxy.", Setting.Property.NodeScope));
|
||||
return settings;
|
||||
}
|
||||
|
||||
notification.onModule(module);
|
||||
security.onModule(module);
|
||||
monitoring.onModule(module);
|
||||
watcher.onModule(module);
|
||||
graph.onModule(module);
|
||||
licensing.onModule(module);
|
||||
@Override
|
||||
public List<String> getSettingsFilter() {
|
||||
List<String> filters = new ArrayList<>();
|
||||
filters.addAll(notification.getSettingsFilter());
|
||||
filters.addAll(security.getSettingsFilter());
|
||||
filters.addAll(MonitoringSettings.getSettingsFilter());
|
||||
filters.addAll(graph.getSettingsFilter());
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -305,9 +313,9 @@ public class XPackPlugin extends Plugin {
|
|||
*
|
||||
* {@code "<feature>.enabled": true | false}
|
||||
*/
|
||||
public static void registerFeatureEnabledSettings(SettingsModule settingsModule, String featureName, boolean defaultValue) {
|
||||
settingsModule.registerSetting(Setting.boolSetting(featureEnabledSetting(featureName), defaultValue, Setting.Property.NodeScope));
|
||||
settingsModule.registerSetting(Setting.boolSetting(legacyFeatureEnabledSetting(featureName),
|
||||
public static void addFeatureEnabledSettings(List<Setting<?>> settingsList, String featureName, boolean defaultValue) {
|
||||
settingsList.add(Setting.boolSetting(featureEnabledSetting(featureName), defaultValue, Setting.Property.NodeScope));
|
||||
settingsList.add(Setting.boolSetting(legacyFeatureEnabledSetting(featureName),
|
||||
defaultValue, Setting.Property.NodeScope));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,18 +36,22 @@ public class Notification {
|
|||
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);
|
||||
public List<Setting<?>> getSettings() {
|
||||
return Arrays.asList(InternalSlackService.SLACK_ACCOUNT_SETTING,
|
||||
InternalEmailService.EMAIL_ACCOUNT_SETTING,
|
||||
InternalHipChatService.HIPCHAT_ACCOUNT_SETTING,
|
||||
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 List<String> getSettingsFilter() {
|
||||
ArrayList<String> settingsFilter = new ArrayList<>();
|
||||
settingsFilter.add("xpack.notification.email.account.*.smtp.password");
|
||||
settingsFilter.add("xpack.notification.slack.account.*.url");
|
||||
settingsFilter.add("xpack.notification.pagerduty.account.*.url");
|
||||
settingsFilter.add("xpack.notification.pagerduty." + PagerDutyAccount.SERVICE_KEY_SETTING);
|
||||
settingsFilter.add("xpack.notification.pagerduty.account.*." + PagerDutyAccount.SERVICE_KEY_SETTING);
|
||||
settingsFilter.add("xpack.notification.hipchat.account.*.auth_token");
|
||||
return settingsFilter;
|
||||
}
|
||||
|
||||
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
|
||||
|
|
|
@ -19,12 +19,10 @@ import org.elasticsearch.common.network.NetworkModule;
|
|||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||
import org.elasticsearch.script.ScriptModule;
|
||||
import org.elasticsearch.threadpool.ExecutorBuilder;
|
||||
import org.elasticsearch.threadpool.FixedExecutorBuilder;
|
||||
import org.elasticsearch.threadpool.ThreadPoolModule;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.common.init.LazyInitializationModule;
|
||||
import org.elasticsearch.xpack.watcher.actions.WatcherActionModule;
|
||||
|
@ -140,33 +138,32 @@ public class Watcher {
|
|||
return Settings.EMPTY;
|
||||
}
|
||||
|
||||
public void onModule(ScriptModule module) {
|
||||
module.registerScriptContext(ScriptServiceProxy.INSTANCE);
|
||||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
public List<Setting<?>> getSettings() {
|
||||
List<Setting<?>> settings = new ArrayList<>();
|
||||
for (TemplateConfig templateConfig : WatcherIndexTemplateRegistry.TEMPLATE_CONFIGS) {
|
||||
module.registerSetting(templateConfig.getSetting());
|
||||
settings.add(templateConfig.getSetting());
|
||||
}
|
||||
module.registerSetting(INDEX_WATCHER_VERSION_SETTING);
|
||||
module.registerSetting(INDEX_WATCHER_TEMPLATE_VERSION_SETTING);
|
||||
module.registerSetting(Setting.intSetting("xpack.watcher.execution.scroll.size", 0, Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.intSetting("xpack.watcher.watch.scroll.size", 0, Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.boolSetting(XPackPlugin.featureEnabledSetting(Watcher.NAME), true, Setting.Property.NodeScope));
|
||||
module.registerSetting(ENCRYPT_SENSITIVE_DATA_SETTING);
|
||||
settings.add(INDEX_WATCHER_VERSION_SETTING);
|
||||
settings.add(INDEX_WATCHER_TEMPLATE_VERSION_SETTING);
|
||||
settings.add(Setting.intSetting("xpack.watcher.execution.scroll.size", 0, Setting.Property.NodeScope));
|
||||
settings.add(Setting.intSetting("xpack.watcher.watch.scroll.size", 0, Setting.Property.NodeScope));
|
||||
settings.add(Setting.boolSetting(XPackPlugin.featureEnabledSetting(Watcher.NAME), true, Setting.Property.NodeScope));
|
||||
settings.add(ENCRYPT_SENSITIVE_DATA_SETTING);
|
||||
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.internal.ops.search.default_timeout", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.internal.ops.bulk.default_timeout", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.internal.ops.index.default_timeout", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.execution.default_throttle_period", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.actions.index.default_timeout", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.index.rest.direct_access", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.trigger.schedule.engine", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.input.search.default_timeout", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.transform.search.default_timeout", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.trigger.schedule.ticker.tick_interval", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.execution.scroll.timeout", Setting.Property.NodeScope));
|
||||
module.registerSetting(Setting.simpleString("xpack.watcher.start_immediately", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.internal.ops.search.default_timeout", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.internal.ops.bulk.default_timeout", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.internal.ops.index.default_timeout", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.execution.default_throttle_period", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.actions.index.default_timeout", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.index.rest.direct_access", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.trigger.schedule.engine", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.input.search.default_timeout", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.transform.search.default_timeout", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.trigger.schedule.ticker.tick_interval", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.execution.scroll.timeout", Setting.Property.NodeScope));
|
||||
settings.add(Setting.simpleString("xpack.watcher.start_immediately", Setting.Property.NodeScope));
|
||||
return settings;
|
||||
}
|
||||
|
||||
public List<ExecutorBuilder<?>> getExecutorBuilders(final Settings settings) {
|
||||
|
@ -282,4 +279,5 @@ public class Watcher {
|
|||
"[.watcher-history-YYYY.MM.dd] are allowed to be created", value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
*/
|
||||
package org.elasticsearch.script;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.common.text.DefaultTextTemplateEngine;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -21,16 +20,10 @@ public class MockMustacheScriptEngine extends MockScriptEngine {
|
|||
public static final String NAME = "mustache";
|
||||
|
||||
public static class TestPlugin extends MockScriptEngine.TestPlugin {
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return NAME;
|
||||
public ScriptEngineService getScriptEngineService(Settings settings) {
|
||||
return new MockMustacheScriptEngine();
|
||||
}
|
||||
|
||||
public void onModule(ScriptModule module) {
|
||||
module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(MockMustacheScriptEngine.class, NAME, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,4 +44,9 @@ public class MockMustacheScriptEngine extends MockScriptEngine {
|
|||
|
||||
return super.compile(name, script, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInlineScriptEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
package org.elasticsearch.script;
|
||||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.plugins.ScriptPlugin;
|
||||
import org.elasticsearch.search.lookup.SearchLookup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -21,26 +22,11 @@ public class SleepScriptEngine implements ScriptEngineService {
|
|||
|
||||
public static final String NAME = "sleep";
|
||||
|
||||
public static class TestPlugin extends Plugin {
|
||||
|
||||
public TestPlugin() {
|
||||
}
|
||||
|
||||
public static class TestPlugin extends Plugin implements ScriptPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return NAME;
|
||||
public ScriptEngineService getScriptEngineService(Settings settings) {
|
||||
return new SleepScriptEngine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Mock script engine for integration tests";
|
||||
}
|
||||
|
||||
public void onModule(ScriptModule module) {
|
||||
module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class,
|
||||
SleepScriptEngine.NAME, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,4 +78,8 @@ public class SleepScriptEngine implements ScriptEngineService {
|
|||
.params(Collections.singletonMap("millis", millis)).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInlineScriptEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,19 +112,6 @@ public class ActionErrorIntegrationTests extends AbstractWatcherIntegrationTestC
|
|||
|
||||
public static class ErrorActionPlugin extends Plugin {
|
||||
|
||||
public ErrorActionPlugin() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "error-action";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public void onModule(WatcherActionModule module) {
|
||||
module.registerAction(ErrorAction.TYPE, ErrorAction.Factory.class);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
|
||||
|
@ -74,19 +76,12 @@ public class WatcherIndexTemplateRegistryTests extends AbstractWatcherIntegratio
|
|||
}
|
||||
|
||||
public static class SettingTestPlugin extends Plugin {
|
||||
public String name() {
|
||||
return "watcher-index-template-registry-settings-plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "installs a setting this test needs";
|
||||
}
|
||||
|
||||
public static final Setting<String> KEY_1 = new Setting<>("index.key1", "", Function.identity(), Setting.Property.IndexScope);
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
module.registerSetting(KEY_1);
|
||||
@Override
|
||||
public List<Setting<?>> getSettings() {
|
||||
return Collections.singletonList(KEY_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ public final class WatcherTestUtils {
|
|||
ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
|
||||
ClusterService clusterService = Mockito.mock(ClusterService.class);
|
||||
Mockito.when(clusterService.state()).thenReturn(ClusterState.builder(new ClusterName("_name")).build());
|
||||
return ScriptServiceProxy.of(new ScriptService(settings, new Environment(settings), Collections.emptySet(),
|
||||
return ScriptServiceProxy.of(new ScriptService(settings, new Environment(settings),
|
||||
new ResourceWatcherService(settings, tp), scriptEngineRegistry, scriptContextRegistry, scriptSettings),
|
||||
clusterService);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue