From cd5169745dbc2431f167e01482ef452bd41f9a4f Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 11 Aug 2015 18:03:07 +0200 Subject: [PATCH] Tests: Smoke tests with SSL enabled. We should smoke test our plugins with ssl enabled to make sure that plugins still work together and eg. Marvel still manages to export stats. Close elastic/elasticsearch#402 Original commit: elastic/x-pack-elasticsearch@3bb7c2b96c7819cc19f0e382b0bc7632a4beca33 --- qa/pom.xml | 1 + .../integration-tests.xml | 90 ++++++ qa/smoke-test-plugins-ssl/pom.xml | 287 ++++++++++++++++++ .../test/smoke_test_plugins_ssl/10_basic.yaml | 16 + .../smoketest/SmokeTestPluginsSslIT.java | 87 ++++++ qa/smoke-test-plugins-ssl/ssl-setup.xml | 170 +++++++++++ qa/smoke-test-plugins/integration-tests.xml | 2 +- 7 files changed, 652 insertions(+), 1 deletion(-) create mode 100644 qa/smoke-test-plugins-ssl/integration-tests.xml create mode 100644 qa/smoke-test-plugins-ssl/pom.xml create mode 100644 qa/smoke-test-plugins-ssl/rest-api-spec/test/smoke_test_plugins_ssl/10_basic.yaml create mode 100644 qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestPluginsSslIT.java create mode 100644 qa/smoke-test-plugins-ssl/ssl-setup.xml diff --git a/qa/pom.xml b/qa/pom.xml index c7e7b12a514..0620a11bbaa 100644 --- a/qa/pom.xml +++ b/qa/pom.xml @@ -319,5 +319,6 @@ smoke-test-plugins + smoke-test-plugins-ssl diff --git a/qa/smoke-test-plugins-ssl/integration-tests.xml b/qa/smoke-test-plugins-ssl/integration-tests.xml new file mode 100644 index 00000000000..a23691500ec --- /dev/null +++ b/qa/smoke-test-plugins-ssl/integration-tests.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + Waiting for elasticsearch to become available on port @{port}... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Setting up Shield auth + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Checking we can connect with basic auth on port ${integ.http.port}... + + + + + + diff --git a/qa/smoke-test-plugins-ssl/pom.xml b/qa/smoke-test-plugins-ssl/pom.xml new file mode 100644 index 00000000000..554abd11818 --- /dev/null +++ b/qa/smoke-test-plugins-ssl/pom.xml @@ -0,0 +1,287 @@ + + + + 4.0.0 + + + org.elasticsearch.qa + x-plugins-qa + 2.0.0-beta1-SNAPSHOT + + + + + smoke-test-x-plugins-ssl + QA: Smoke Test X-Plugins + Loads up all of our commercial and open-source plugins with ssl enabled + + + true + ${project.basedir}/integration-tests.xml + smoke_test_plugins_ssl + false + elasticsearch-license,elasticsearch-marvel,elasticsearch-shield,elasticsearch-watcher + ${project.basedir}/ssl-setup.xml + ${project.build.outputDirectory}/test-node.jks + + + + + org.elasticsearch.plugin + elasticsearch-shield + 2.0.0-beta1-SNAPSHOT + test + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + integ-setup-dependencies + pre-integration-test + + copy + + + ${skip.integ.tests} + true + ${integ.deps}/plugins + + + + + org.elasticsearch.distribution.zip + elasticsearch + ${elasticsearch.version} + zip + true + ${integ.deps} + + + + + org.elasticsearch.plugin + elasticsearch-license + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-watcher + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-shield + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-marvel + ${elasticsearch.version} + zip + true + + + + + org.elasticsearch.plugin + elasticsearch-analysis-kuromoji + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-analysis-smartcn + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-analysis-stempel + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-analysis-phonetic + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-analysis-icu + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-cloud-gce + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-cloud-azure + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-cloud-aws + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-delete-by-query + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-lang-python + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-lang-javascript + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-mapper-size + ${elasticsearch.version} + zip + true + + + + org.elasticsearch.plugin + elasticsearch-site-example + ${elasticsearch.version} + zip + true + + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + certificate-setup + generate-test-resources + + run + + + + + + + ${skip.integ.tests} + + + + + integ-setup + pre-integration-test + + run + + + + + + + + + ${skip.integ.tests} + + + + + integ-teardown + post-integration-test + + run + + + + + + ${skip.integ.tests} + + + + + + ant-contrib + ant-contrib + 1.0b3 + + + ant + ant + + + + + org.apache.ant + ant-nodeps + 1.8.1 + + + + + + + diff --git a/qa/smoke-test-plugins-ssl/rest-api-spec/test/smoke_test_plugins_ssl/10_basic.yaml b/qa/smoke-test-plugins-ssl/rest-api-spec/test/smoke_test_plugins_ssl/10_basic.yaml new file mode 100644 index 00000000000..dd1ada2ec73 --- /dev/null +++ b/qa/smoke-test-plugins-ssl/rest-api-spec/test/smoke_test_plugins_ssl/10_basic.yaml @@ -0,0 +1,16 @@ +# Integration tests for smoke testing plugins +# +"Plugins are actually installed": + - do: + cluster.state: {} + + # Get master node id + - set: { master_node: master } + + - do: + nodes.info: {} + + - match: { nodes.$master.plugins.11.name: license } + - match: { nodes.$master.plugins.13.name: marvel } + - match: { nodes.$master.plugins.14.name: shield } + - match: { nodes.$master.plugins.16.name: watcher } diff --git a/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestPluginsSslIT.java b/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestPluginsSslIT.java new file mode 100644 index 00000000000..79707388cff --- /dev/null +++ b/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestPluginsSslIT.java @@ -0,0 +1,87 @@ +/* + * 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.smoketest; + +import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.client.support.Headers; +import org.elasticsearch.common.io.PathUtils; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.shield.ShieldPlugin; +import org.elasticsearch.shield.authc.support.SecuredString; +import org.elasticsearch.test.rest.ESRestTestCase; +import org.elasticsearch.test.rest.RestTestCandidate; +import org.elasticsearch.test.rest.client.RestClient; +import org.elasticsearch.test.rest.parser.RestTestParseException; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; + +public class SmokeTestPluginsSslIT extends ESRestTestCase { + + private static final String USER = "test_user"; + private static final String PASS = "changeme"; + private static final String KEYSTORE_PASS = "keypass"; + + public SmokeTestPluginsSslIT(@Name("yaml") RestTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws IOException, RestTestParseException { + return ESRestTestCase.createParameters(0, 1); + } + + static Path keyStore; + + @BeforeClass + public static void getKeyStore() { + try { + keyStore = PathUtils.get(SmokeTestPluginsSslIT.class.getResource("/test-node.jks").toURI()); + } catch (URISyntaxException e) { + throw new ElasticsearchException("exception while reading the store", e); + } + if (!Files.exists(keyStore)) { + throw new IllegalStateException("Keystore file [" + keyStore + "] does not exist."); + } + } + + @AfterClass + public static void clearKeyStore() { + keyStore = null; + } + + @Override + protected Settings restClientSettings() { + String token = basicAuthHeaderValue(USER, new SecuredString(PASS.toCharArray())); + return Settings.builder() + .put(Headers.PREFIX + ".Authorization", token) + .put(RestClient.PROTOCOL, "https") + .put(RestClient.TRUSTSTORE_PATH, keyStore) + .put(RestClient.TRUSTSTORE_PASSWORD, KEYSTORE_PASS) + .build(); + } + + @Override + protected Settings externalClusterClientSettings() { + return Settings.builder() + .put("shield.user", USER + ":" + PASS) + .put("shield.transport.ssl", true) + .put("shield.ssl.keystore.path", keyStore) + .put("shield.ssl.keystore.password", KEYSTORE_PASS) + .put("plugin.types", ShieldPlugin.class.getName()) + .build(); + } + +} diff --git a/qa/smoke-test-plugins-ssl/ssl-setup.xml b/qa/smoke-test-plugins-ssl/ssl-setup.xml new file mode 100644 index 00000000000..b30fbb8023a --- /dev/null +++ b/qa/smoke-test-plugins-ssl/ssl-setup.xml @@ -0,0 +1,170 @@ + + + + + + + + + + 01 + + [ ca ] +default_ca = CA_default +[ CA_default ] +copy_extensions = copy +dir = ${integ.scratch}/ca +serial = $dir/serial +database = $dir/index.txt +new_certs_dir = $dir/certs +certificate = $dir/certs/cacert.pem +private_key = $dir/private/cakey.pem +default_days = 712 +default_md = sha256 +preserve = no +email_in_dn = no +x509_extensions = v3_ca +name_opt = ca_default +cert_opt = ca_default +policy = policy_anything +[ policy_anything ] +countryName = optional +stateOrProvinceName = optional +localityName = optional +organizationName = optional +organizationalUnitName = optional +commonName = supplied +emailAddress = optional +[ req ] +default_bits = 2048 # Size of keys +default_keyfile = key.pem # name of generated keys +default_md = sha256 # message digest algorithm +string_mask = nombstr # permitted characters +distinguished_name = req_distinguished_name +req_extensions = v3_req +[ req_distinguished_name ] +# Variable name Prompt string +#------------------------- ---------------------------------- +0.organizationName = Organization Name (company) +organizationalUnitName = Organizational Unit Name (department, division) +emailAddress = Email Address +emailAddress_max = 40 +localityName = Locality Name (city, district) +stateOrProvinceName = State or Province Name (full name) +countryName = Country Name (2 letter code) +countryName_min = 2 +countryName_max = 2 +commonName = Common Name (hostname, IP, or your name) +commonName_max = 64 +# Default values for the above, for consistency and less typing. +# Variable name Value +#------------------------ ------------------------------ +0.organizationName_default = Elasticsearch Test Org +localityName_default = Amsterdam +stateOrProvinceName_default = Amsterdam +countryName_default = NL +emailAddress_default = cacerttest@YOUR.COMPANY.TLD +[ v3_ca ] +basicConstraints = CA:TRUE +subjectKeyIdentifier = hash +authorityKeyIdentifier = keyid:always,issuer:always +[ v3_req ] +basicConstraints = CA:FALSE +subjectKeyIdentifier = hash + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qa/smoke-test-plugins/integration-tests.xml b/qa/smoke-test-plugins/integration-tests.xml index 2adfd1f59b2..c0c7bf175f6 100644 --- a/qa/smoke-test-plugins/integration-tests.xml +++ b/qa/smoke-test-plugins/integration-tests.xml @@ -1,5 +1,5 @@ -