Merge branch 'master' into kibana-shield-users

Original commit: elastic/x-pack-elasticsearch@7009e3ecd9
This commit is contained in:
Lukas Olson 2016-01-22 15:59:03 -07:00
commit fca35a501d
42 changed files with 141 additions and 77 deletions

View File

@ -8,6 +8,7 @@ package org.elasticsearch.messy.tests;
import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.common.collect.HppcMaps;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;

View File

@ -176,6 +176,7 @@ public class SearchTransformTests extends ESIntegTestCase {
assertThat(resultData, equalTo(expectedData));
}
@SuppressWarnings("unchecked")
public void testExecuteFailure() throws Exception {
index("idx", "type", "1");
ensureGreen("idx");

View File

@ -44,7 +44,7 @@ public abstract class AbstractLicensesConsumerPluginIntegrationTestCase extends
return Settings.settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
// this setting is only used in tests
.put(".trial_license_duration_in_seconds", trialLicenseDurationInSeconds)
.put("_trial_license_duration_in_seconds", trialLicenseDurationInSeconds)
.build();
}

View File

@ -37,7 +37,7 @@ public class LicensesPluginIntegrationTests extends AbstractLicensesIntegrationT
return Settings.settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
// this setting is only used in tests
.put(".trial_license_duration_in_seconds", trialLicenseDurationInSeconds)
.put("_trial_license_duration_in_seconds", trialLicenseDurationInSeconds)
.build();
}

View File

@ -42,7 +42,7 @@ public class LicensesPluginsIntegrationTests extends AbstractLicensesIntegration
return Settings.settingsBuilder()
.put(super.nodeSettings(0))
// this setting is only used in tests
.put(".trial_license_duration_in_seconds", trialLicenseDuration)
.put("_trial_license_duration_in_seconds", trialLicenseDuration)
.build();
}

View File

@ -6,6 +6,7 @@
package org.elasticsearch.license.plugin;
import org.elasticsearch.client.ClusterAdminClient;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.license.core.License;
@ -61,10 +62,10 @@ public class LicensesServiceClusterTests extends AbstractLicensesIntegrationTest
.put("node.data", true)
.put("format", "json")
// this setting is only used in tests
.put(".trial_license_duration_in_seconds", 9)
.put("_trial_license_duration_in_seconds", 9)
// this setting is only used in tests
.put(".grace_duration_in_seconds", 9)
.put(Node.HTTP_ENABLED, true);
.put("_grace_duration_in_seconds", 9)
.put(NetworkModule.HTTP_ENABLED.getKey(), true);
}
@Override

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.license.plugin;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationConsumerPlugin;
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationPluginService;
@ -27,7 +28,7 @@ public class LicensesServiceNodeTests extends AbstractLicensesIntegrationTestCas
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}

View File

@ -33,11 +33,11 @@ public abstract class TestPluginServiceBase extends AbstractLifecycleComponent<T
super(settings);
this.eagerLicenseRegistration = eagerLicenseRegistration;
this.licensesClientService = licensesClientService;
int trialDurationInSec = settings.getAsInt(".trial_license_duration_in_seconds", -1);
int trialDurationInSec = settings.getAsInt("_trial_license_duration_in_seconds", -1);
if (trialDurationInSec != -1) {
licensesClientService.setTrialLicenseDuration(TimeValue.timeValueSeconds(trialDurationInSec));
}
int graceDurationInSec = settings.getAsInt(".grace_duration_in_seconds", 5);
int graceDurationInSec = settings.getAsInt("_grace_duration_in_seconds", 5);
licensesClientService.setGracePeriodDuration(TimeValue.timeValueSeconds(graceDurationInSec));
if (!eagerLicenseRegistration) {
this.clusterService = clusterService;

View File

@ -54,7 +54,7 @@ public class AbstractCollectorTestCase extends MarvelIntegTestCase {
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, false)
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(MarvelSettings.INTERVAL_SETTING.getKey(), "-1")
.build();
}

View File

@ -5,23 +5,27 @@
*/
package org.elasticsearch.marvel.agent.renderer.node;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.marvel.agent.collector.node.NodeStatsCollector;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.test.MarvelIntegTestCase;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.junit.After;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/960")
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0)
public class MultiNodesStatsTests extends MarvelIntegTestCase {
@ -41,30 +45,38 @@ public class MultiNodesStatsTests extends MarvelIntegTestCase {
}
public void testMultipleNodes() throws Exception {
logger.debug("--> starting a master only node");
internalCluster().startMasterOnlyNodeAsync();
int nodes = 0;
logger.debug("--> starting a data only node");
internalCluster().startDataOnlyNodeAsync();
int n = randomIntBetween(1, 2);
logger.debug("--> starting {} master only nodes", n);
InternalTestCluster.Async<List<String>> masterNodes = internalCluster().startMasterOnlyNodesAsync(n);
masterNodes.get();
nodes += n;
logger.debug("--> starting a client node");
internalCluster().startNodeClient(Settings.EMPTY);
n = randomIntBetween(2, 3);
logger.debug("--> starting {} data only nodes", n);
InternalTestCluster.Async<List<String>> dataNodes = internalCluster().startDataOnlyNodesAsync(n);
dataNodes.get();
nodes += n;
logger.debug("--> starting few other nodes");
int extraNodes = randomIntBetween(2, 5);
for (int i = 0; i < extraNodes; i++) {
if (randomBoolean()) {
internalCluster().startNodeAsync();
} else {
internalCluster().startNodeClient(Settings.EMPTY);
}
}
n = randomIntBetween(1, 2);
logger.debug("--> starting {} client only nodes", n);
InternalTestCluster.Async<List<String>> clientNodes = internalCluster().startNodesAsync(n, settingsBuilder().put("node.client", true).build());
clientNodes.get();
nodes += n;
final int nbNodes = 3 + extraNodes;
n = randomIntBetween(1, 2);
logger.debug("--> starting {} extra nodes", n);
InternalTestCluster.Async<List<String>> extraNodes = internalCluster().startNodesAsync(n);
extraNodes.get();
nodes += n;
final int nbNodes = nodes;
logger.debug("--> waiting for {} nodes to be available", nbNodes);
assertBusy(new Runnable() {
@Override
public void run() {
assertThat(cluster().size(), equalTo(nbNodes));
assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(nbNodes)).get());
}
});
@ -77,15 +89,22 @@ public class MultiNodesStatsTests extends MarvelIntegTestCase {
public void run() {
securedFlush();
for (String nodeName : internalCluster().getNodeNames()) {
SearchResponse response = client(nodeName).prepareSearch()
.setTypes(NodeStatsCollector.TYPE)
.setQuery(QueryBuilders.termQuery("node_stats.node_id", internalCluster().clusterService(nodeName).localNode().getId()))
.get();
assertThat(response.getHits().getTotalHits(), greaterThan(0L));
SearchResponse response = client().prepareSearch()
.setTypes(NodeStatsCollector.TYPE)
.setSize(0)
.addAggregation(AggregationBuilders.terms("nodes_ids").field("node_stats.node_id"))
.get();
for (Aggregation aggregation : response.getAggregations()) {
assertThat(aggregation, instanceOf(StringTerms.class));
assertThat(((StringTerms) aggregation).getBuckets().size(), equalTo(nbNodes));
for (String nodeName : internalCluster().getNodeNames()) {
StringTerms.Bucket bucket = (StringTerms.Bucket) ((StringTerms) aggregation).getBucketByKey(internalCluster().clusterService(nodeName).localNode().getId());
assertThat(bucket.getDocCount(), equalTo(1L));
}
}
}
});
}
}

View File

@ -6,6 +6,7 @@
package org.elasticsearch.marvel.agent.settings;
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequestBuilder;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
@ -38,7 +39,7 @@ public class MarvelSettingsTests extends MarvelIntegTestCase {
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, false)
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(marvelSettings())
.build();
}

View File

@ -52,12 +52,14 @@ public class CleanerServiceTests extends ESTestCase {
}
public void testRetentionUpdateAllowed() {
TimeValue randomRetention = TimeValue.parseTimeValue(randomTimeValue(), null, "");
MarvelLicensee licensee = mock(MarvelLicensee.class);
when(licensee.allowUpdateRetention()).thenReturn(true);
CleanerService service = new CleanerService(Settings.EMPTY, clusterSettings, threadPool, licensee);
service.setRetention(TimeValue.parseTimeValue("-1", null, ""));
assertThat(service.getRetention().getMillis(), equalTo(-1L));
TimeValue randomRetention = TimeValue.parseTimeValue(randomIntBetween(1, 1000) + "ms", null, "");
service.setRetention(randomRetention);
assertThat(service.getRetention(), equalTo(randomRetention));
@ -69,14 +71,27 @@ public class CleanerServiceTests extends ESTestCase {
}
public void testRetentionUpdateBlocked() {
TimeValue randomRetention = TimeValue.parseTimeValue(randomTimeValue(), null, "");
MarvelLicensee licensee = mock(MarvelLicensee.class);
when(licensee.allowUpdateRetention()).thenReturn(false);
when(licensee.allowUpdateRetention()).thenReturn(true);
CleanerService service = new CleanerService(Settings.EMPTY, clusterSettings, threadPool, licensee);
try {
service.setRetention(TimeValue.parseTimeValue("-5000ms", null, ""));
fail("exception should have been thrown: negative retention are not allowed");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("invalid history duration setting value"));
}
try {
service.setRetention(null);
fail("exception should have been thrown: null retention is not allowed");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("history duration setting cannot be null"));
}
TimeValue randomRetention = TimeValue.parseTimeValue(randomIntBetween(1, 1000) + "ms", null, "");
when(licensee.allowUpdateRetention()).thenReturn(false);
try {
service.setRetention(randomRetention);
fail("exception should have been thrown");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("license does not allow the history duration setting to be updated to value"));
assertNull(service.getRetention());

View File

@ -7,6 +7,7 @@ package org.elasticsearch.marvel.shield;
import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.marvel.agent.exporter.MarvelTemplateUtils;
@ -24,7 +25,7 @@ public class SecuredClientTests extends MarvelIntegTestCase {
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, false)
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(MarvelSettings.INTERVAL_SETTING.getKey(), "-1")
.build();
}

View File

@ -42,7 +42,7 @@ public class IPFilter {
public static final String HTTP_PROFILE_NAME = ".http";
public static final Setting<Boolean> IP_FILTER_ENABLED_HTTP_SETTING = Setting.boolSetting("shield.http.filter.enabled", true, true, Setting.Scope.CLUSTER);
public static final Setting<Boolean> IP_FILTER_ENABLED_SETTING = new Setting<>("shield.transport.filter.enabled", (s) -> IP_FILTER_ENABLED_HTTP_SETTING.getDefault(s), Booleans::parseBooleanExact, true, Setting.Scope.CLUSTER);
public static final Setting<Boolean> IP_FILTER_ENABLED_SETTING = new Setting<>("shield.transport.filter.enabled", (s) -> IP_FILTER_ENABLED_HTTP_SETTING.getDefaultRaw(s), Booleans::parseBooleanExact, true, Setting.Scope.CLUSTER);
public static final Setting<List<String>> TRANSPORT_FILTER_ALLOW_SETTING = Setting.listSetting("shield.transport.filter.allow", Collections.emptyList(), Function.identity(), true, Setting.Scope.CLUSTER);
public static final Setting<List<String>> TRANSPORT_FILTER_DENY_SETTING = Setting.listSetting("shield.transport.filter.deny", Collections.emptyList(), Function.identity(), true, Setting.Scope.CLUSTER);

View File

@ -8,6 +8,7 @@ package org.elasticsearch.integration;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.shield.ShieldPlugin;
@ -29,7 +30,7 @@ public class BulkUpdateTests extends ShieldIntegTestCase {
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put(ShieldPlugin.DLS_FLS_ENABLED_SETTING, randomBoolean())
.build();
}

View File

@ -9,6 +9,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.Node;
@ -188,7 +189,7 @@ public class ClearRealmsCacheTests extends ShieldIntegTestCase {
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}
@Override

View File

@ -9,6 +9,7 @@ import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.node.Node;
@ -101,7 +102,7 @@ public class ClearRolesCacheTests extends ShieldIntegTestCase {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put("shield.authc.native.reload.interval", TimeValue.timeValueSeconds(2L))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}

View File

@ -8,6 +8,7 @@ package org.elasticsearch.integration;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse;
import org.elasticsearch.cluster.SnapshotsInProgress;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
@ -61,7 +62,7 @@ public class ClusterPrivilegeTests extends AbstractPrivilegeTestCase {
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put("action.disable_shutdown", true)
.put("path.repo", repositoryLocation)
.build();

View File

@ -6,6 +6,7 @@
package org.elasticsearch.integration;
import org.apache.lucene.util.LuceneTestCase.BadApple;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.rest.client.http.HttpResponse;
@ -118,7 +119,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put("action.disable_shutdown", true)
.build();
}

View File

@ -100,7 +100,7 @@ public class LicensingTests extends ShieldIntegTestCase {
@Override
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}

View File

@ -7,6 +7,7 @@ package org.elasticsearch.integration;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
@ -48,7 +49,7 @@ public class SettingsFilterTests extends ShieldIntegTestCase {
protected Settings nodeSettings(int nodeOrdinal) {
int clientProfilePort = randomIntBetween(49000, 65400);
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put("shield.authc.realms.esusers.type", "esusers")

View File

@ -7,6 +7,7 @@ package org.elasticsearch.shield;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.integration.LicensingTests;
@ -67,7 +68,7 @@ public class ShieldPluginEnabledDisabledTests extends ShieldIntegTestCase {
return Settings.settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.put(ShieldPlugin.ENABLED_SETTING_NAME, enabled)
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}

View File

@ -53,6 +53,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import static org.elasticsearch.shield.audit.index.IndexNameResolver.Rollover.DAILY;
import static org.elasticsearch.shield.audit.index.IndexNameResolver.Rollover.HOURLY;
@ -172,7 +173,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
return builder.build();
}
};
cluster2 = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name, cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins());
cluster2 = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name, cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), Function.identity());
cluster2.beforeTest(getRandom(), 0.5);
remoteClient = cluster2.client();

View File

@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import static org.elasticsearch.test.InternalTestCluster.clusterName;
import static org.hamcrest.Matchers.is;
@ -106,7 +107,7 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase {
return builder.build();
}
};
remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name, cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins());
remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name, cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), Function.identity());
remoteCluster.beforeTest(getRandom(), 0.5);
}

View File

@ -10,6 +10,7 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
@ -34,7 +35,7 @@ public class AnonymousUserTests extends ShieldIntegTestCase {
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put("shield.authc.anonymous.roles", "anonymous")
.put(AnonymousService.SETTING_AUTHORIZATION_EXCEPTION_ENABLED, authorizationExceptionsEnabled)
.build();

View File

@ -10,6 +10,7 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.node.Node;
@ -40,7 +41,7 @@ public class RunAsIntegTests extends ShieldIntegTestCase {
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}

View File

@ -13,6 +13,7 @@ import org.apache.http.util.EntityUtils;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.transport.NoNodeAvailableException;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
@ -50,7 +51,7 @@ public class PkiAuthenticationTests extends ShieldIntegTestCase {
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put(ShieldNettyHttpServerTransport.HTTP_SSL_SETTING, true)
.put(ShieldNettyHttpServerTransport.HTTP_CLIENT_AUTH_SETTING, randomBoolean() ? SSLClientAuth.REQUIRED : SSLClientAuth.OPTIONAL)
.put("shield.authc.realms.esusers.type", "esusers")

View File

@ -8,6 +8,7 @@ package org.elasticsearch.shield.authc.pki;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.http.HttpServerTransport;
@ -52,7 +53,7 @@ public class PkiOptionalClientAuthTests extends ShieldIntegTestCase {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put(ShieldNettyHttpServerTransport.HTTP_SSL_SETTING, true)
.put(ShieldNettyHttpServerTransport.HTTP_CLIENT_AUTH_SETTING, SSLClientAuth.OPTIONAL)
.put("shield.authc.realms.esusers.type", "esusers")

View File

@ -9,6 +9,7 @@ package org.elasticsearch.shield.authc.pki;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.http.HttpServerTransport;
@ -61,7 +62,7 @@ public class PkiWithoutClientAuthenticationTests extends ShieldIntegTestCase {
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put(ShieldNettyTransport.TRANSPORT_CLIENT_AUTH_SETTING, false)
.put(ShieldNettyHttpServerTransport.HTTP_SSL_SETTING, true)
.put(ShieldNettyHttpServerTransport.HTTP_CLIENT_AUTH_SETTING, randomFrom(SSLClientAuth.NO.name(), false, "false", "FALSE", SSLClientAuth.NO.name().toLowerCase(Locale.ROOT)))

View File

@ -8,6 +8,7 @@ package org.elasticsearch.shield.authc.pki;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.Node;
@ -32,7 +33,7 @@ public class PkiWithoutSSLTests extends ShieldIntegTestCase {
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put("shield.authc.realms.pki1.type", "pki")
.put("shield.authc.realms.pki1.order", "0")
.build();

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.shield.rest.action;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.shield.authc.support.SecuredString;
@ -34,7 +35,7 @@ public class RestAuthenticateActionTests extends ShieldIntegTestCase {
protected Settings nodeSettings(int nodeOrdinal) {
Settings.Builder builder = Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true);
.put(NetworkModule.HTTP_ENABLED.getKey(), true);
if (anonymousEnabled) {
builder.put("shield.authc.anonymous.username", "anon")

View File

@ -7,6 +7,7 @@ package org.elasticsearch.shield.transport;
import org.elasticsearch.Version;
import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
@ -98,7 +99,7 @@ public class ServerTransportFilterIntegrationTests extends ShieldIntegTestCase {
.put("shield.transport.ssl", sslTransportEnabled())
.put("shield.audit.enabled", false)
.put("path.home", createTempDir())
.put(Node.HTTP_ENABLED, false)
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(InternalCryptoService.FILE_SETTING, systemKeyFile)
.put("node.client", true)
.build();
@ -130,7 +131,7 @@ public class ServerTransportFilterIntegrationTests extends ShieldIntegTestCase {
.put("discovery.zen.ping.unicast.hosts", "localhost:" + randomClientPort)
.put("shield.transport.ssl", sslTransportEnabled())
.put("shield.audit.enabled", false)
.put(Node.HTTP_ENABLED, false)
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(InternalCryptoService.FILE_SETTING, systemKeyFile)
.put("discovery.initial_state_timeout", "2s")
.put("path.home", createTempDir())

View File

@ -6,6 +6,7 @@
package org.elasticsearch.shield.transport.filter;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
@ -41,7 +42,7 @@ public class IpFilteringIntegrationTests extends ShieldIntegTestCase {
protected Settings nodeSettings(int nodeOrdinal) {
String randomClientPortRange = randomClientPort + "-" + (randomClientPort+100);
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put("transport.profiles.client.port", randomClientPortRange)
.put("transport.profiles.client.bind_host", "localhost") // make sure this is "localhost", no matter if ipv4 or ipv6, but be consistent
.put("transport.profiles.client.shield.filter.deny", "_all")

View File

@ -6,6 +6,7 @@
package org.elasticsearch.shield.transport.filter;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
@ -38,7 +39,7 @@ public class IpFilteringUpdateTests extends ShieldIntegTestCase {
String randomClientPortRange = randomClientPort + "-" + (randomClientPort+100);
return settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, httpEnabled)
.put(NetworkModule.HTTP_ENABLED.getKey(), httpEnabled)
.put("shield.transport.filter.deny", "127.0.0.200")
.put("transport.profiles.client.port", randomClientPortRange)
.build();

View File

@ -11,6 +11,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.http.HttpServerTransport;
@ -43,7 +44,7 @@ public class SslClientAuthTests extends ShieldIntegTestCase {
.put(ShieldNettyHttpServerTransport.HTTP_SSL_SETTING, true)
.put(ShieldNettyHttpServerTransport.HTTP_CLIENT_AUTH_SETTING, true)
.put("transport.profiles.default.shield.ssl.client.auth", false)
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}

View File

@ -17,6 +17,7 @@ import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.client.transport.NoNodeAvailableException;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
@ -46,7 +47,7 @@ public class SslIntegrationTests extends ShieldIntegTestCase {
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return settingsBuilder().put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put(ShieldNettyHttpServerTransport.HTTP_SSL_SETTING, true).build();
}

View File

@ -11,4 +11,3 @@
nodes.info: {}
- match: { nodes.$master.plugins.0.name: x-pack }
- match: { nodes.$master.plugins.0.jvm: true }

View File

@ -170,15 +170,15 @@ public class TextTemplate implements ToXContent {
return new Builder.Inline(template.bytes().toUtf8()).contentType(template.contentType());
}
public static Builder inline(String text) {
public static Builder<Builder.Inline> inline(String text) {
return new Builder.Inline(text);
}
public static Builder file(String file) {
public static Builder<Builder.File> file(String file) {
return new Builder.File(file);
}
public static Builder indexed(String id) {
public static Builder<Builder.Indexed> indexed(String id) {
return new Builder.Indexed(id);
}

View File

@ -10,6 +10,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.Node;
@ -42,7 +43,7 @@ public class WatcherPluginDisableTests extends ESIntegTestCase {
.put(super.nodeSettings(nodeOrdinal))
.put(WatcherPlugin.ENABLED_SETTING, false)
.put(ShieldPlugin.ENABLED_SETTING_NAME, false) // disable shield because of query cache check and authentication/authorization
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}

View File

@ -6,6 +6,7 @@
package org.elasticsearch.watcher.input.chain;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.node.Node;
@ -35,7 +36,7 @@ public class ChainIntegrationTests extends AbstractWatcherIntegrationTestCase {
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}

View File

@ -7,6 +7,7 @@ package org.elasticsearch.watcher.input.http;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.node.Node;
@ -42,7 +43,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.build();
}

View File

@ -7,6 +7,7 @@ package org.elasticsearch.watcher.test.integration;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
@ -43,7 +44,7 @@ public class WatcherSettingsFilterTests extends AbstractWatcherIntegrationTestCa
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Node.HTTP_ENABLED, true)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put("watcher.actions.email.service.account._email.smtp.host", "host.domain")
.put("watcher.actions.email.service.account._email.smtp.port", 587)
.put("watcher.actions.email.service.account._email.smtp.user", "_user")