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