tell shield tests to explicitly load shield and license plugins

Original commit: elastic/x-pack-elasticsearch@4f70d6ee93
This commit is contained in:
jaymode 2015-07-22 10:01:44 -04:00
parent 8dea4500c5
commit 187be6c602
5 changed files with 25 additions and 17 deletions

View File

@ -11,7 +11,9 @@ import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.license.plugin.LicensePlugin;
import org.elasticsearch.node.Node;
import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.shield.authc.support.SecuredString;
import org.elasticsearch.shield.authc.support.UsernamePasswordToken;
import org.elasticsearch.shield.transport.SSLClientAuth;
@ -103,6 +105,7 @@ public class PkiOptionalClientAuthTests extends ShieldIntegrationTest {
.put("cluster.name", internalTestCluster().getClusterName())
.put("shield.transport.ssl", true)
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();

View File

@ -12,7 +12,9 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.discovery.MasterNotDiscoveredException;
import org.elasticsearch.license.plugin.LicensePlugin;
import org.elasticsearch.node.Node;
import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.shield.authc.esusers.ESUsersRealm;
import org.elasticsearch.shield.crypto.InternalCryptoService;
import org.elasticsearch.test.ShieldIntegrationTest;
@ -89,6 +91,7 @@ public class ServerTransportFilterIntegrationTests extends ShieldIntegrationTest
// test that starting up a node works
Settings nodeSettings = settingsBuilder()
.put(ShieldSettingsSource.getSSLSettingsForStore("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks", "testnode"))
.put("plugin.types", ShieldPlugin.class.getName() + "," + LicensePlugin.class.getName())
.put("node.mode", "network")
.put("node.name", "my-test-node")
.put("network.host", "localhost")

View File

@ -16,6 +16,7 @@ import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.env.Environment;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.Node;
import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.shield.ssl.ClientSSLService;
import org.elasticsearch.shield.transport.netty.ShieldNettyHttpServerTransport;
import org.elasticsearch.test.ShieldIntegrationTest;
@ -101,6 +102,7 @@ public class SslClientAuthTests extends ShieldIntegrationTest {
Settings settings = settingsBuilder()
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.put("shield.transport.ssl", true)
.put("shield.ssl.keystore.path", store)
.put("shield.ssl.keystore.password", "testclient-client-profile")

View File

@ -10,6 +10,7 @@ import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.test.ShieldIntegrationTest;
import org.elasticsearch.test.ShieldSettingsSource;
import org.elasticsearch.transport.Transport;
@ -211,6 +212,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("shield.user", DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
.put("cluster.name", internalTestCluster().getClusterName())
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", getProfilePort("no_ssl")));
@ -228,6 +230,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("shield.user", DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
.put("cluster.name", internalTestCluster().getClusterName())
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(internalTestCluster().getInstance(Transport.class).boundAddress().boundAddress());
@ -245,6 +248,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("shield.user", DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
.put("cluster.name", internalTestCluster().getClusterName())
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", getProfilePort("client")));
@ -262,6 +266,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("shield.user", DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
.put("cluster.name", internalTestCluster().getClusterName())
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", getProfilePort("no_client_auth")));
@ -283,6 +288,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("shield.ssl.truststore.path", getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/truststore-testnode-only.jks"))
.put("shield.ssl.truststore.password", "truststore-testnode-only")
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", getProfilePort("no_client_auth")));
@ -305,6 +311,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("shield.ssl.truststore.path", getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/truststore-testnode-only.jks"))
.put("shield.ssl.truststore.password", "truststore-testnode-only")
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", getProfilePort("client")));
@ -327,6 +334,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("shield.ssl.truststore.path", getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/truststore-testnode-only.jks"))
.put("shield.ssl.truststore.password", "truststore-testnode-only")
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(internalTestCluster().getInstance(Transport.class).boundAddress().boundAddress());
@ -348,6 +356,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("shield.ssl.truststore.path", getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/truststore-testnode-only.jks"))
.put("shield.ssl.truststore.password", "truststore-testnode-only")
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", getProfilePort("no_ssl")));
@ -367,6 +376,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("cluster.name", internalTestCluster().getClusterName())
.put("shield.transport.ssl", true)
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(internalTestCluster().getInstance(Transport.class).boundAddress().boundAddress());
@ -386,6 +396,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("cluster.name", internalTestCluster().getClusterName())
.put("shield.transport.ssl", true)
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", getProfilePort("client")));
@ -405,6 +416,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("cluster.name", internalTestCluster().getClusterName())
.put("shield.transport.ssl", true)
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", getProfilePort("no_client_auth")));
@ -424,6 +436,7 @@ public class SslMultiPortTests extends ShieldIntegrationTest {
.put("cluster.name", internalTestCluster().getClusterName())
.put("shield.transport.ssl", true)
.put("path.home", createTempDir())
.put("plugin.types", ShieldPlugin.class.getName())
.build();
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
transportClient.addTransportAddress(new InetSocketTransportAddress("localhost", getProfilePort("no_ssl")));

View File

@ -28,12 +28,6 @@ public class TribeShieldLoadedTests extends ElasticsearchTestCase {
public void testShieldLoadedOnBothTribeNodeAndClients() {
//all good if the plugin is loaded on both tribe node and tribe clients, no matter how it gets loaded (manually or from classpath)
Settings.Builder builder = defaultSettings();
if (randomBoolean()) {
builder.put("plugin.types", ShieldPlugin.class.getName() + "," + LicensePlugin.class.getName());
}
if (randomBoolean()) {
builder.put("tribe.t1.plugin.types", ShieldPlugin.class.getName() + "," + LicensePlugin.class.getName());
}
try (Node node = NodeBuilder.nodeBuilder().settings(builder.build()).build()) {
node.start();
@ -46,9 +40,6 @@ public class TribeShieldLoadedTests extends ElasticsearchTestCase {
public void testShieldLoadedOnTribeNodeOnly() {
//startup failure if any of the tribe clients doesn't have shield installed
Settings.Builder builder = defaultSettings();
if (randomBoolean()) {
builder.put("plugin.types", ShieldPlugin.class.getName() + "," + LicensePlugin.class.getName());
}
try {
NodeBuilder.nodeBuilder().settings(builder.build()).build();
@ -63,12 +54,6 @@ public class TribeShieldLoadedTests extends ElasticsearchTestCase {
public void testShieldMustBeLoadedOnAllTribes() {
//startup failure if any of the tribe clients doesn't have shield installed
Settings.Builder builder = addTribeSettings(defaultSettings(), "t2");
if (randomBoolean()) {
builder.put("plugin.types", ShieldPlugin.class.getName() + "," + LicensePlugin.class.getName());
}
//load shield explicitly on tribe t1
builder.put("tribe.t1.plugin.types", ShieldPlugin.class.getName() + "," + LicensePlugin.class.getName());
try {
NodeBuilder.nodeBuilder().settings(builder.build()).build();
@ -81,13 +66,15 @@ public class TribeShieldLoadedTests extends ElasticsearchTestCase {
private static Settings.Builder defaultSettings() {
return addTribeSettings(Settings.builder()
.put("node.name", "tribe_node")
.put("path.home", createTempDir()), "t1");
.put("path.home", createTempDir()), "t1")
.put("plugin.types", ShieldPlugin.class.getName() + "," + LicensePlugin.class.getName());
}
private static Settings.Builder addTribeSettings(Settings.Builder settingsBuilder, String tribe) {
String tribePrefix = "tribe." + tribe + ".";
return settingsBuilder.put(tribePrefix + "cluster.name", "non_existing_cluster")
.put(tribePrefix + "discovery.type", "local")
.put(tribePrefix + "discovery.initial_state_timeout", 0);
.put(tribePrefix + "discovery.initial_state_timeout", 0)
.put(tribePrefix + "plugin.types", ShieldPlugin.class.getName() + "," + LicensePlugin.class.getName());
}
}