diff --git a/dev-tools/integration-tests.xml b/dev-tools/integration-tests.xml new file mode 100644 index 00000000000..1a35a802fcf --- /dev/null +++ b/dev-tools/integration-tests.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + Installing license plugin... + + + + + + Installing plugin ${project.artifactId}... + + + + Starting up external cluster... + + + + + + + + + + + + + + + + + External cluster started PID ${integ.pid} + + diff --git a/pom.xml b/pom.xml index 6ecb2e13347..1b2e5c2e1ef 100644 --- a/pom.xml +++ b/pom.xml @@ -47,10 +47,9 @@ - - true dev-tools/elasticsearch_license_header.txt dev-tools/license_header_definition.xml + dev-tools/integration-tests.xml 2.0.0-SNAPSHOT indices.get/10_basic/*allow_no_indices*,cat.count/10_basic/Test cat count output,cat.aliases/10_basic/Empty cluster,indices.segments/10_basic/no segments test,indices.clear_cache/10_basic/clear_cache test,indices.status/10_basic/Indices status test,cat.indices/10_basic/Test cat indices output,cat.recovery/10_basic/Test cat recovery output,cat.shards/10_basic/Test cat shards output,termvector/20_issue7121/*,index/10_with_id/Index with ID,indices.get_alias/20_emtpy/*,cat.segments/10_basic/Test cat segments output,indices.put_settings/10_basic/Test indices settings allow_no_indices,indices.put_settings/10_basic/Test indices settings ignore_unavailable,indices.refresh/10_basic/Indices refresh test no-match wildcard,indices.stats/10_index/Index - star*,indices.recovery/10_basic/Indices recovery test*,template/30_render_search_template/* @@ -96,6 +95,13 @@ 1.0 test + + org.elasticsearch + elasticsearch-license-plugin + ${license.plugin.version} + zip + test + com.github.spullara.mustache.java diff --git a/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java b/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java index ac5ba082515..d19ccc26d8a 100644 --- a/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java +++ b/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java @@ -241,7 +241,9 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail { if (state.compareAndSet(State.STARTED, State.STOPPING)) { try { queueConsumer.interrupt(); - bulkProcessor.flush(); + if (bulkProcessor != null) { + bulkProcessor.flush(); + } } finally { state.set(State.STOPPED); } @@ -254,7 +256,9 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail { } try { - bulkProcessor.close(); + if (bulkProcessor != null) { + bulkProcessor.close(); + } } finally { if (indexToRemoteCluster) { if (client != null) { diff --git a/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java b/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java index 9f5cd4b9268..810cd6972a2 100644 --- a/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java +++ b/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java @@ -23,6 +23,7 @@ import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.node.Node; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.search.SearchHit; +import org.elasticsearch.shield.ShieldPlugin; import org.elasticsearch.shield.User; import org.elasticsearch.shield.authc.AuthenticationService; import org.elasticsearch.shield.authc.AuthenticationToken; @@ -124,7 +125,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { if (remoteIndexing) { // start a small single-node cluster to test remote indexing against logger.info("--> remote indexing enabled"); - Settings s = Settings.builder().put("shield.enabled", "false").put("path.home", createTempDir()).build(); + Settings s = Settings.builder().put(ShieldPlugin.ENABLED_SETTING_NAME, false).put("path.home", createTempDir()).build(); remoteNode = nodeBuilder().clusterName(REMOTE_TEST_CLUSTER).data(true).settings(s).node(); remoteClient = remoteNode.client(); diff --git a/src/test/java/org/elasticsearch/shield/test/ShieldAssertions.java b/src/test/java/org/elasticsearch/shield/test/ShieldAssertions.java index 8c3ef8a747a..2eae3a18544 100644 --- a/src/test/java/org/elasticsearch/shield/test/ShieldAssertions.java +++ b/src/test/java/org/elasticsearch/shield/test/ShieldAssertions.java @@ -7,6 +7,7 @@ package org.elasticsearch.shield.test; import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.shield.ShieldPlugin; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -17,6 +18,6 @@ public class ShieldAssertions { assertThat(e.status(), is(RestStatus.UNAUTHORIZED)); assertThat(e.getHeaderKeys(), hasSize(1)); assertThat(e.getHeader("WWW-Authenticate"), notNullValue()); - assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"shield\"")); + assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"" + ShieldPlugin.NAME + "\"")); } } diff --git a/src/test/java/org/elasticsearch/test/ShieldIntegrationTest.java b/src/test/java/org/elasticsearch/test/ShieldIntegrationTest.java index e67f786eae2..f70340d056c 100644 --- a/src/test/java/org/elasticsearch/test/ShieldIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ShieldIntegrationTest.java @@ -167,6 +167,13 @@ public abstract class ShieldIntegrationTest extends ElasticsearchIntegrationTest .build(); } + @Override + protected Settings externalClusterClientSettings() { + return Settings.builder() + .put("shield.user", ShieldSettingsSource.DEFAULT_USER_NAME + ":" + ShieldSettingsSource.DEFAULT_PASSWORD) + .build(); + } + /** * Allows for us to get the system key that is being used for the cluster * @return the system key bytes diff --git a/src/test/java/org/elasticsearch/test/ShieldRestIT.java b/src/test/java/org/elasticsearch/test/ShieldRestIT.java new file mode 100644 index 00000000000..c0d7a58ac1e --- /dev/null +++ b/src/test/java/org/elasticsearch/test/ShieldRestIT.java @@ -0,0 +1,27 @@ +/* + * 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.test; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; + +import org.elasticsearch.test.rest.ElasticsearchRestTestCase; +import org.elasticsearch.test.rest.RestTestCandidate; +import org.elasticsearch.test.rest.parser.RestTestParseException; + +import java.io.IOException; + +/** Runs rest tests against external cluster */ +public class ShieldRestIT extends ShieldRestTestCase { + public ShieldRestIT(@Name("yaml") RestTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws IOException, RestTestParseException { + return ElasticsearchRestTestCase.createParameters(0, 1); + } +}