fix tests so gradle test passes

Original commit: elastic/x-pack-elasticsearch@30683bd771
This commit is contained in:
jaymode 2015-12-01 07:23:32 -05:00 committed by uboness
parent 13a8c98cb2
commit e1c1552eb2
10 changed files with 146 additions and 120 deletions

View File

@ -66,8 +66,11 @@ ext.expansions = [
]
processResources {
inputs.properties(expansions)
MavenFilteringHack.filter(it, expansions)
from(sourceSets.main.resources.srcDirs) {
exclude '**/public.key'
inputs.properties(expansions)
MavenFilteringHack.filter(it, expansions)
}
String licenseKeyName = System.getProperty('license.key', 'dev')
String licenseKeyPath = "license-plugin/keys/${licenseKeyName}/public.key"
if (file(licenseKeyPath).exists() == false) {

View File

@ -13,6 +13,7 @@ import org.elasticsearch.marvel.test.MarvelIntegTestCase;
import org.elasticsearch.plugins.PluginInfo;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.tribe.TribeService;
import org.elasticsearch.xpack.XPackPlugin;
import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
import static org.hamcrest.Matchers.equalTo;
@ -53,12 +54,12 @@ public class MarvelPluginTests extends MarvelIntegTestCase {
for (PluginInfo plugin : nodeInfo.getPlugins().getInfos()) {
assertNotNull(plugin);
if (MarvelPlugin.NAME.equals(plugin.getName())) {
if (XPackPlugin.NAME.equals(plugin.getName())) {
found = true;
break;
}
}
assertThat("marvel plugin not found", found, equalTo(true));
assertThat("x-pack plugin not found", found, equalTo(true));
}
}

View File

@ -91,15 +91,14 @@ public abstract class MarvelIntegTestCase extends ESIntegTestCase {
.put("shield.user", "test:changeme")
.build();
}
return super.transportClientSettings();
return Settings.builder().put(super.transportClientSettings())
.put("shield.enabled", false)
.build();
}
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
if (shieldEnabled) {
return Arrays.asList(XPackPlugin.class, XPackPlugin.class, XPackPlugin.class);
}
return Arrays.asList(XPackPlugin.class, XPackPlugin.class);
return Collections.singletonList(XPackPlugin.class);
}
@Override

View File

@ -24,6 +24,7 @@ import org.elasticsearch.test.rest.client.http.HttpResponse;
import org.elasticsearch.test.rest.json.JsonPath;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.XPackPlugin;
import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.BeforeClass;
@ -56,6 +57,10 @@ public class ShieldPluginEnabledDisabledTests extends ShieldIntegTestCase {
logger.info("cleanup: enabling licensing...");
LicensingTests.enableLicensing();
}
@Override
protected Class<? extends XPackPlugin> xpackPluginClass() {
return LicensingTests.InternalXPackPlugin.class;
}
@Override
protected Settings nodeSettings(int nodeOrdinal) {

View File

@ -23,7 +23,6 @@ import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.shield.User;
import org.elasticsearch.shield.authc.AuthenticationService;
import org.elasticsearch.shield.authc.AuthenticationToken;
@ -220,20 +219,20 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "transport", "anonymous_access_denied");
Map<String, Object> sourceMap = hit.sourceAsMap();
if (message instanceof RemoteHostMockMessage) {
assertEquals(remoteHostAddress(), hit.field("origin_address").getValue());
assertEquals(remoteHostAddress(), sourceMap.get("origin_address"));
} else {
assertEquals("local[local_host]", hit.field("origin_address").getValue());
assertEquals("local[local_host]", sourceMap.get("origin_address"));
}
assertEquals("_action", hit.field("action").getValue());
assertEquals("transport", hit.field("origin_type").getValue());
assertEquals("_action", sourceMap.get("action"));
assertEquals("transport", sourceMap.get("origin_type"));
if (message instanceof IndicesRequest) {
List<Object> indices = hit.field("indices").getValues();
List<Object> indices = (List<Object>) sourceMap.get("indices");
assertThat(indices, contains((Object[]) ((IndicesRequest) message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testAnonymousAccessDeniedTransportMuted() throws Exception {
@ -257,10 +256,11 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "rest", "anonymous_access_denied");
assertThat(NetworkAddress.formatAddress(InetAddress.getLoopbackAddress()), equalTo(hit.field("origin_address").getValue()));
assertThat("_uri", equalTo(hit.field("uri").getValue()));
assertThat(hit.field("origin_type").getValue(), is("rest"));
assertThat(hit.field("request_body").getValue(), notNullValue());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertThat(NetworkAddress.formatAddress(InetAddress.getLoopbackAddress()), equalTo(sourceMap.get("origin_address")));
assertThat("_uri", equalTo(sourceMap.get("uri")));
assertThat(sourceMap.get("origin_type"), is("rest"));
assertThat(sourceMap.get("request_body"), notNullValue());
}
public void testAnonymousAccessDeniedRestMuted() throws Exception {
@ -282,19 +282,19 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
awaitAuditDocumentCreation(resolveIndexName());
SearchHit hit = getIndexedAuditMessage();
Map<String, Object> sourceMap = hit.sourceAsMap();
assertAuditMessage(hit, "transport", "authentication_failed");
if (message instanceof RemoteHostMockMessage) {
assertEquals(remoteHostAddress(), hit.field("origin_address").getValue());
assertEquals(remoteHostAddress(), sourceMap.get("origin_address"));
} else {
assertEquals("local[local_host]", hit.field("origin_address").getValue());
assertEquals("local[local_host]", sourceMap.get("origin_address"));
}
assertEquals("_principal", hit.field("principal").getValue());
assertEquals("_action", hit.field("action").getValue());
assertEquals("transport", hit.field("origin_type").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
assertEquals("_principal", sourceMap.get("principal"));
assertEquals("_action", sourceMap.get("action"));
assertEquals("transport", sourceMap.get("origin_type"));
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testAuthenticationFailedTransportNoToken() throws Exception {
@ -306,21 +306,21 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "transport", "authentication_failed");
Map<String, Object> sourceMap = hit.sourceAsMap();
if (message instanceof RemoteHostMockMessage) {
assertEquals(remoteHostAddress(), hit.field("origin_address").getValue());
assertEquals(remoteHostAddress(), sourceMap.get("origin_address"));
} else {
assertEquals("local[local_host]", hit.field("origin_address").getValue());
assertEquals("local[local_host]", sourceMap.get("origin_address"));
}
assertThat(hit.field("principal"), nullValue());
assertEquals("_action", hit.field("action").getValue());
assertEquals("transport", hit.field("origin_type").getValue());
assertThat(sourceMap.get("principal"), nullValue());
assertEquals("_action", sourceMap.get("action"));
assertEquals("transport", sourceMap.get("origin_type"));
if (message instanceof IndicesRequest) {
List<Object> indices = hit.field("indices").getValues();
List<Object> indices = (List<Object>) sourceMap.get("indices");
assertThat(indices, contains((Object[]) ((IndicesRequest) message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testAuthenticationFailed_Transport_Muted() throws Exception {
@ -356,11 +356,12 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "rest", "authentication_failed");
assertThat(hit.field("principal").getValue(), is((Object) "_principal"));
assertThat("127.0.0.1", equalTo(hit.field("origin_address").getValue()));
assertThat("_uri", equalTo(hit.field("uri").getValue()));
assertThat(hit.field("origin_type").getValue(), is("rest"));
assertThat(hit.field("request_body").getValue(), notNullValue());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertThat(sourceMap.get("principal"), is((Object) "_principal"));
assertThat("127.0.0.1", equalTo(sourceMap.get("origin_address")));
assertThat("_uri", equalTo(sourceMap.get("uri")));
assertThat(sourceMap.get("origin_type"), is("rest"));
assertThat(sourceMap.get("request_body"), notNullValue());
}
public void testAuthenticationFailedRestNoToken() throws Exception {
@ -372,11 +373,12 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "rest", "authentication_failed");
assertThat(hit.field("principal"), nullValue());
assertThat("127.0.0.1", equalTo(hit.field("origin_address").getValue()));
assertThat("_uri", equalTo(hit.field("uri").getValue()));
assertThat(hit.field("origin_type").getValue(), is("rest"));
assertThat(hit.field("request_body").getValue(), notNullValue());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertThat(sourceMap.get("principal"), nullValue());
assertThat("127.0.0.1", equalTo(sourceMap.get("origin_address")));
assertThat("_uri", equalTo(sourceMap.get("uri")));
assertThat(sourceMap.get("origin_type"), is("rest"));
assertThat(sourceMap.get("request_body"), notNullValue());
}
public void testAuthenticationFailedRestMuted() throws Exception {
@ -412,22 +414,23 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "transport", "authentication_failed");
Map<String, Object> sourceMap = hit.sourceAsMap();
if (message instanceof RemoteHostMockMessage) {
assertEquals(remoteHostAddress(), hit.field("origin_address").getValue());
assertEquals(remoteHostAddress(), sourceMap.get("origin_address"));
} else {
assertEquals("local[local_host]", hit.field("origin_address").getValue());
assertEquals("local[local_host]", sourceMap.get("origin_address"));
}
assertEquals("transport", hit.field("origin_type").getValue());
assertEquals("_principal", hit.field("principal").getValue());
assertEquals("_action", hit.field("action").getValue());
assertEquals("_realm", hit.field("realm").getValue());
assertEquals("transport", sourceMap.get("origin_type"));
assertEquals("_principal", sourceMap.get("principal"));
assertEquals("_action", sourceMap.get("action"));
assertEquals("_realm", sourceMap.get("realm"));
if (message instanceof IndicesRequest) {
List<Object> indices = hit.field("indices").getValues();
List<Object> indices = (List<Object>) sourceMap.get("indices");
assertThat(indices, contains((Object[]) ((IndicesRequest)message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testAuthenticationFailedTransportRealmMuted() throws Exception {
@ -451,11 +454,12 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "rest", "authentication_failed");
assertThat("127.0.0.1", equalTo(hit.field("origin_address").getValue()));
assertThat("_uri", equalTo(hit.field("uri").getValue()));
assertEquals("_realm", hit.field("realm").getValue());
assertThat(hit.field("origin_type").getValue(), is("rest"));
assertThat(hit.field("request_body").getValue(), notNullValue());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertThat("127.0.0.1", equalTo(sourceMap.get("origin_address")));
assertThat("_uri", equalTo(sourceMap.get("uri")));
assertEquals("_realm", sourceMap.get("realm"));
assertThat(sourceMap.get("origin_type"), is("rest"));
assertThat(sourceMap.get("request_body"), notNullValue());
}
public void testAuthenticationFailedRestRealmMuted() throws Exception {
@ -485,19 +489,20 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "transport", "access_granted");
assertEquals("transport", hit.field("origin_type").getValue());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertEquals("transport", sourceMap.get("origin_type"));
if (runAs) {
assertThat(hit.field("principal").getValue(), is("running as"));
assertThat(hit.field("run_by_principal").getValue(), is("_username"));
assertThat(sourceMap.get("principal"), is("running as"));
assertThat(sourceMap.get("run_by_principal"), is("_username"));
} else {
assertEquals("_username", hit.field("principal").getValue());
assertEquals("_username", sourceMap.get("principal"));
}
assertEquals("_action", hit.field("action").getValue());
assertEquals("_action", sourceMap.get("action"));
if (message instanceof IndicesRequest) {
List<Object> indices = hit.field("indices").getValues();
List<Object> indices = (List<Object>) sourceMap.get("indices");
assertThat(indices, contains((Object[]) ((IndicesRequest)message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testAccessGrantedMuted() throws Exception {
@ -519,10 +524,11 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "transport", "access_granted");
assertEquals("transport", hit.field("origin_type").getValue());
assertEquals(User.SYSTEM.principal(), hit.field("principal").getValue());
assertEquals("internal:_action", hit.field("action").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertEquals("transport", sourceMap.get("origin_type"));
assertEquals(User.SYSTEM.principal(), sourceMap.get("principal"));
assertEquals("internal:_action", sourceMap.get("action"));
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testSystemAccessGrantedMuted() throws Exception {
@ -551,20 +557,21 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
awaitAuditDocumentCreation(resolveIndexName());
SearchHit hit = getIndexedAuditMessage();
Map<String, Object> sourceMap = hit.sourceAsMap();
assertAuditMessage(hit, "transport", "access_denied");
assertEquals("transport", hit.field("origin_type").getValue());
assertEquals("transport", sourceMap.get("origin_type"));
if (runAs) {
assertThat(hit.field("principal").getValue(), is("running as"));
assertThat(hit.field("run_by_principal").getValue(), is("_username"));
assertThat(sourceMap.get("principal"), is("running as"));
assertThat(sourceMap.get("run_by_principal"), is("_username"));
} else {
assertEquals("_username", hit.field("principal").getValue());
assertEquals("_username", sourceMap.get("principal"));
}
assertEquals("_action", hit.field("action").getValue());
assertEquals("_action", sourceMap.get("action"));
if (message instanceof IndicesRequest) {
List<Object> indices = hit.field("indices").getValues();
List<Object> indices = (List<Object>) sourceMap.get("indices");
assertThat(indices, contains((Object[]) ((IndicesRequest)message).indices()));
}
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testAccessDenied_Muted() throws Exception {
@ -586,12 +593,12 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
awaitAuditDocumentCreation(resolveIndexName());
SearchHit hit = getIndexedAuditMessage();
Map<String, Object> sourceMap = hit.sourceAsMap();
assertAuditMessage(hit, "transport", "tampered_request");
assertEquals("transport", hit.field("origin_type").getValue());
assertThat(hit.field("principal"), is(nullValue()));
assertEquals("_action", hit.field("action").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
assertEquals("transport", sourceMap.get("origin_type"));
assertThat(sourceMap.get("principal"), is(nullValue()));
assertEquals("_action", sourceMap.get("action"));
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testTamperedRequestWithUser() throws Exception {
@ -610,15 +617,16 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "transport", "tampered_request");
assertEquals("transport", hit.field("origin_type").getValue());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertEquals("transport", sourceMap.get("origin_type"));
if (runAs) {
assertThat(hit.field("principal").getValue(), is("running as"));
assertThat(hit.field("run_by_principal").getValue(), is("_username"));
assertThat(sourceMap.get("principal"), is("running as"));
assertThat(sourceMap.get("run_by_principal"), is("_username"));
} else {
assertEquals("_username", hit.field("principal").getValue());
assertEquals("_username", sourceMap.get("principal"));
}
assertEquals("_action", hit.field("action").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
assertEquals("_action", sourceMap.get("action"));
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testTamperedRequestMuted() throws Exception {
@ -647,8 +655,9 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "ip_filter", "connection_granted");
assertEquals("allow default:accept_all", hit.field("rule").getValue());
assertEquals("default", hit.field("transport_profile").getValue());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertEquals("allow default:accept_all", sourceMap.get("rule"));
assertEquals("default", sourceMap.get("transport_profile"));
}
public void testConnectionGrantedMuted() throws Exception {
@ -674,8 +683,9 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "ip_filter", "connection_denied");
assertEquals("deny _all", hit.field("rule").getValue());
assertEquals("default", hit.field("transport_profile").getValue());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertEquals("deny _all", sourceMap.get("rule"));
assertEquals("default", sourceMap.get("transport_profile"));
}
public void testConnectionDeniedMuted() throws Exception {
@ -700,11 +710,12 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "transport", "run_as_granted");
assertEquals("transport", hit.field("origin_type").getValue());
assertThat(hit.field("principal").getValue(), is("_username"));
assertThat(hit.field("run_as_principal").getValue(), is("running as"));
assertEquals("_action", hit.field("action").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertEquals("transport", sourceMap.get("origin_type"));
assertThat(sourceMap.get("principal"), is("_username"));
assertThat(sourceMap.get("run_as_principal"), is("running as"));
assertEquals("_action", sourceMap.get("action"));
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testRunAsGrantedMuted() throws Exception {
@ -728,11 +739,12 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchHit hit = getIndexedAuditMessage();
assertAuditMessage(hit, "transport", "run_as_denied");
assertEquals("transport", hit.field("origin_type").getValue());
assertThat(hit.field("principal").getValue(), is("_username"));
assertThat(hit.field("run_as_principal").getValue(), is("running as"));
assertEquals("_action", hit.field("action").getValue());
assertEquals(hit.field("request").getValue(), message.getClass().getSimpleName());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertEquals("transport", sourceMap.get("origin_type"));
assertThat(sourceMap.get("principal"), is("_username"));
assertThat(sourceMap.get("run_as_principal"), is("running as"));
assertEquals("_action", sourceMap.get("action"));
assertEquals(sourceMap.get("request"), message.getClass().getSimpleName());
}
public void testRunAsDeniedMuted() throws Exception {
@ -748,15 +760,16 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
}
private void assertAuditMessage(SearchHit hit, String layer, String type) {
assertThat(hit.field("@timestamp").getValue(), notNullValue());
DateTime dateTime = ISODateTimeFormat.dateTimeParser().withZoneUTC().parseDateTime(hit.field("@timestamp").getValue());
Map<String, Object> sourceMap = hit.sourceAsMap();
assertThat(sourceMap.get("@timestamp"), notNullValue());
DateTime dateTime = ISODateTimeFormat.dateTimeParser().withZoneUTC().parseDateTime((String) sourceMap.get("@timestamp"));
assertThat(dateTime.isBefore(DateTime.now(DateTimeZone.UTC)), is(true));
assertThat(DummyTransportAddress.INSTANCE.getHost(), equalTo(hit.field("node_host_name").getValue()));
assertThat(DummyTransportAddress.INSTANCE.getAddress(), equalTo(hit.field("node_host_address").getValue()));
assertThat(DummyTransportAddress.INSTANCE.getHost(), equalTo(sourceMap.get("node_host_name")));
assertThat(DummyTransportAddress.INSTANCE.getAddress(), equalTo(sourceMap.get("node_host_address")));
assertEquals(layer, hit.field("layer").getValue());
assertEquals(type, hit.field("event_type").getValue());
assertEquals(layer, sourceMap.get("layer"));
assertEquals(type, sourceMap.get("event_type"));
}
private static class LocalHostMockMessage extends TransportMessage<LocalHostMockMessage> {
@ -821,7 +834,6 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
SearchResponse response = getClient().prepareSearch(resolveIndexName())
.setTypes(IndexAuditTrail.DOC_TYPE)
.fields(fieldList())
.execute().actionGet();
assertEquals(1, response.getHits().getTotalHits());

View File

@ -9,6 +9,7 @@ import org.apache.lucene.util.IOUtils;
import org.elasticsearch.action.Action;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.license.plugin.LicensePlugin;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.shield.action.ShieldActionModule;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
@ -109,7 +110,7 @@ public class KnownActionsTests extends ShieldIntegTestCase {
loadActions(collectSubClasses(Action.class, ShieldActionModule.class), actions);
// also loading all actions from the licensing plugin
loadActions(collectSubClasses(Action.class, XPackPlugin.class), actions);
loadActions(collectSubClasses(Action.class, LicensePlugin.class), actions);
return unmodifiableSet(actions);
}

View File

@ -12,6 +12,7 @@ import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.http.HttpServerModule;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.license.plugin.LicensePlugin;
@ -20,6 +21,7 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.rest.RestModule;
import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.shield.authz.AuthorizationModule;
import org.elasticsearch.transport.TransportModule;
import org.elasticsearch.watcher.WatcherPlugin;
@ -110,11 +112,13 @@ public class XPackPlugin extends Plugin {
shieldPlugin.onModule(module);
}
// NOTE: The fact this signature takes a module is a hack, and effectively like the previous
// processModule in the plugin api. The problem is tight coupling between watcher and shield.
// We need to avoid trying to load the AuthorizationModule class unless we know shield integration
// is enabled. This is a temporary solution until inter-plugin-communication can be worked out.
public void onModule(Module module) {
public void onModule(HttpServerModule module) {
shieldPlugin.onModule(module);
}
public void onModule(AuthorizationModule module) {
shieldPlugin.onModule(module);
// FIXME clean these up
watcherPlugin.onModule(module);
marvelPlugin.onModule(module);
}

View File

@ -1,4 +1,7 @@
grant {
// needed because of problems in unbound LDAP library
permission java.util.PropertyPermission "*", "read,write";
// needed to set expert SSL options, etc
permission java.lang.RuntimePermission "setFactory";
};

View File

@ -1,4 +0,0 @@
grant {
// needed to set expert SSL options, etc
permission java.lang.RuntimePermission "setFactory";
};

View File

@ -12,6 +12,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.Plugin;
@ -41,13 +42,14 @@ public class WatcherPluginDisableTests extends ESIntegTestCase {
return Settings.settingsBuilder()
.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)
.build();
}
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(XPackPlugin.class, XPackPlugin.class);
return Collections.<Class<? extends Plugin>>singleton(XPackPlugin.class);
}
@Override