fixed a license disabled behaviour

When the license is disabled (expired) we need to also block the nodes stats API

Fixes elastic/elasticsearch#671

Original commit: elastic/x-pack-elasticsearch@277c470889
This commit is contained in:
uboness 2015-01-28 14:57:25 +01:00
parent 82fc8fb9bf
commit dd5332500c
2 changed files with 17 additions and 1 deletions

View File

@ -40,7 +40,11 @@ public abstract class Privilege<P extends Privilege<P>> {
static final String SUB_ACTION_SUFFIX_PATTERN = "*";
public static final System SYSTEM = new System();
public static final General HEALTH_AND_STATS = new General("health_and_stats", "cluster:monitor/health*", "cluster:monitor/stats*", "indices:monitor/stats*");
public static final General HEALTH_AND_STATS = new General("health_and_stats",
"cluster:monitor/health*",
"cluster:monitor/stats*",
"indices:monitor/stats*",
"cluster:monitor/nodes/stats*");
protected final Name name;

View File

@ -6,6 +6,7 @@
package org.elasticsearch.integration;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsIndices;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
@ -154,6 +155,14 @@ public class LicensingTests extends ShieldIntegrationTest {
assertThat(lee.feature(), equalTo(LicenseService.FEATURE_NAME));
}
try {
client.admin().cluster().prepareNodesStats().get();
fail("expected an license expired exception when executing cluster health action");
} catch (LicenseExpiredException lee) {
// expected
assertThat(lee.feature(), equalTo(LicenseService.FEATURE_NAME));
}
enableLicensing();
IndicesStatsResponse indicesStatsResponse = client.admin().indices().prepareStats().get();
@ -167,6 +176,9 @@ public class LicensingTests extends ShieldIntegrationTest {
ClusterHealthResponse clusterIndexHealth = client.admin().cluster().prepareHealth().get();
assertThat(clusterIndexHealth, notNullValue());
NodesStatsResponse nodeStats = client.admin().cluster().prepareNodesStats().get();
assertThat(nodeStats, notNullValue());
}
public static void disableLicensing() {