summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/plugins
diff options
context:
space:
mode:
authorRyan Ernst <ryan@iernst.net>2016-01-16 21:54:05 -0800
committerRyan Ernst <ryan@iernst.net>2016-01-16 22:45:37 -0800
commit3b78267c7154d69a40d18acdab971a205acb2f22 (patch)
treeb4c00ac9dfeb7f3ddb32092b6c93256f646b8b7c /core/src/test/java/org/elasticsearch/plugins
parentb4538a56761cc13e11bd359ea850346aeac2513d (diff)
Plugins: Remove site plugins
Site plugins used to be used for things like kibana and marvel, but there is no longer a need since kibana (and marvel as a kibana plugin) uses node.js. This change removes site plugins, as well as the flag for jvm plugins. Now all plugins are jvm plugins.
Diffstat (limited to 'core/src/test/java/org/elasticsearch/plugins')
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java74
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/SitePluginIT.java131
-rw-r--r--core/src/test/java/org/elasticsearch/plugins/SitePluginRelativePathConfigIT.java88
3 files changed, 10 insertions, 283 deletions
diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java b/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
index deaff46f27..37a0f4e358 100644
--- a/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
+++ b/core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
@@ -40,17 +40,13 @@ public class PluginInfoTests extends ESTestCase {
"version", "1.0",
"elasticsearch.version", Version.CURRENT.toString(),
"java.version", System.getProperty("java.specification.version"),
- "jvm", "true",
"classname", "FakePlugin");
PluginInfo info = PluginInfo.readFromProperties(pluginDir);
assertEquals("my_plugin", info.getName());
assertEquals("fake desc", info.getDescription());
assertEquals("1.0", info.getVersion());
assertEquals("FakePlugin", info.getClassname());
- assertTrue(info.isJvm());
assertTrue(info.isIsolated());
- assertFalse(info.isSite());
- assertNull(info.getUrl());
}
public void testReadFromPropertiesNameMissing() throws Exception {
@@ -94,27 +90,12 @@ public class PluginInfoTests extends ESTestCase {
}
}
- public void testReadFromPropertiesJvmAndSiteMissing() throws Exception {
- Path pluginDir = createTempDir().resolve("fake-plugin");
- PluginTestUtil.writeProperties(pluginDir,
- "description", "fake desc",
- "version", "1.0",
- "name", "my_plugin");
- try {
- PluginInfo.readFromProperties(pluginDir);
- fail("expected jvm or site exception");
- } catch (IllegalArgumentException e) {
- assertTrue(e.getMessage().contains("must be at least a jvm or site plugin"));
- }
- }
-
public void testReadFromPropertiesElasticsearchVersionMissing() throws Exception {
Path pluginDir = createTempDir().resolve("fake-plugin");
PluginTestUtil.writeProperties(pluginDir,
"description", "fake desc",
"name", "my_plugin",
- "version", "1.0",
- "jvm", "true");
+ "version", "1.0");
try {
PluginInfo.readFromProperties(pluginDir);
fail("expected missing elasticsearch version exception");
@@ -129,8 +110,7 @@ public class PluginInfoTests extends ESTestCase {
"description", "fake desc",
"name", "my_plugin",
"elasticsearch.version", Version.CURRENT.toString(),
- "version", "1.0",
- "jvm", "true");
+ "version", "1.0");
try {
PluginInfo.readFromProperties(pluginDir);
fail("expected missing java version exception");
@@ -148,8 +128,7 @@ public class PluginInfoTests extends ESTestCase {
"elasticsearch.version", Version.CURRENT.toString(),
"java.version", "1000000.0",
"classname", "FakePlugin",
- "version", "1.0",
- "jvm", "true");
+ "version", "1.0");
try {
PluginInfo.readFromProperties(pluginDir);
fail("expected incompatible java version exception");
@@ -167,8 +146,7 @@ public class PluginInfoTests extends ESTestCase {
"elasticsearch.version", Version.CURRENT.toString(),
"java.version", "1.7.0_80",
"classname", "FakePlugin",
- "version", "1.0",
- "jvm", "true");
+ "version", "1.0");
try {
PluginInfo.readFromProperties(pluginDir);
fail("expected bad java version format exception");
@@ -182,7 +160,6 @@ public class PluginInfoTests extends ESTestCase {
PluginTestUtil.writeProperties(pluginDir,
"description", "fake desc",
"version", "1.0",
- "jvm", "true",
"name", "my_plugin",
"elasticsearch.version", "bogus");
try {
@@ -199,7 +176,6 @@ public class PluginInfoTests extends ESTestCase {
"description", "fake desc",
"name", "my_plugin",
"version", "1.0",
- "jvm", "true",
"elasticsearch.version", Version.V_1_7_0.toString());
try {
PluginInfo.readFromProperties(pluginDir);
@@ -216,8 +192,7 @@ public class PluginInfoTests extends ESTestCase {
"name", "my_plugin",
"version", "1.0",
"elasticsearch.version", Version.CURRENT.toString(),
- "java.version", System.getProperty("java.specification.version"),
- "jvm", "true");
+ "java.version", System.getProperty("java.specification.version"));
try {
PluginInfo.readFromProperties(pluginDir);
fail("expected old elasticsearch version exception");
@@ -226,42 +201,13 @@ public class PluginInfoTests extends ESTestCase {
}
}
- public void testReadFromPropertiesSitePlugin() throws Exception {
- Path pluginDir = createTempDir().resolve("fake-plugin");
- Files.createDirectories(pluginDir.resolve("_site"));
- PluginTestUtil.writeProperties(pluginDir,
- "description", "fake desc",
- "name", "my_plugin",
- "version", "1.0",
- "site", "true");
- PluginInfo info = PluginInfo.readFromProperties(pluginDir);
- assertTrue(info.isSite());
- assertFalse(info.isJvm());
- assertEquals("NA", info.getClassname());
- }
-
- public void testReadFromPropertiesSitePluginWithoutSite() throws Exception {
- Path pluginDir = createTempDir().resolve("fake-plugin");
- PluginTestUtil.writeProperties(pluginDir,
- "description", "fake desc",
- "name", "my_plugin",
- "version", "1.0",
- "site", "true");
- try {
- PluginInfo.readFromProperties(pluginDir);
- fail("didn't get expected exception");
- } catch (IllegalArgumentException e) {
- assertTrue(e.getMessage().contains("site plugin but has no '_site"));
- }
- }
-
public void testPluginListSorted() {
PluginsAndModules pluginsInfo = new PluginsAndModules();
- pluginsInfo.addPlugin(new PluginInfo("c", "foo", true, "dummy", true, "dummyclass", true));
- pluginsInfo.addPlugin(new PluginInfo("b", "foo", true, "dummy", true, "dummyclass", true));
- pluginsInfo.addPlugin(new PluginInfo("e", "foo", true, "dummy", true, "dummyclass", true));
- pluginsInfo.addPlugin(new PluginInfo("a", "foo", true, "dummy", true, "dummyclass", true));
- pluginsInfo.addPlugin(new PluginInfo("d", "foo", true, "dummy", true, "dummyclass", true));
+ pluginsInfo.addPlugin(new PluginInfo("c", "foo", "dummy", "dummyclass", true));
+ pluginsInfo.addPlugin(new PluginInfo("b", "foo", "dummy", "dummyclass", true));
+ pluginsInfo.addPlugin(new PluginInfo("e", "foo", "dummy", "dummyclass", true));
+ pluginsInfo.addPlugin(new PluginInfo("a", "foo", "dummy", "dummyclass", true));
+ pluginsInfo.addPlugin(new PluginInfo("d", "foo", "dummy", "dummyclass", true));
final List<PluginInfo> infos = pluginsInfo.getPluginInfos();
List<String> names = infos.stream().map((input) -> input.getName()).collect(Collectors.toList());
diff --git a/core/src/test/java/org/elasticsearch/plugins/SitePluginIT.java b/core/src/test/java/org/elasticsearch/plugins/SitePluginIT.java
deleted file mode 100644
index e2df2518f1..0000000000
--- a/core/src/test/java/org/elasticsearch/plugins/SitePluginIT.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.elasticsearch.plugins;
-
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.http.HttpServerTransport;
-import org.elasticsearch.test.ESIntegTestCase;
-import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
-import org.elasticsearch.test.rest.client.http.HttpResponse;
-
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.rest.RestStatus.FORBIDDEN;
-import static org.elasticsearch.rest.RestStatus.MOVED_PERMANENTLY;
-import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
-import static org.elasticsearch.rest.RestStatus.OK;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasStatus;
-import static org.hamcrest.Matchers.containsString;
-
-/**
- * We want to test site plugins
- */
-@ClusterScope(scope = Scope.SUITE, numDataNodes = 1)
-public class SitePluginIT extends ESIntegTestCase {
- @Override
- protected Settings nodeSettings(int nodeOrdinal) {
- Path pluginDir = getDataPath("/org/elasticsearch/test_plugins");
- return settingsBuilder()
- .put(super.nodeSettings(nodeOrdinal))
- .put("path.plugins", pluginDir.toAbsolutePath())
- .put("force.http.enabled", true)
- .build();
- }
-
- @Override
- public HttpRequestBuilder httpClient() {
- RequestConfig.Builder builder = RequestConfig.custom().setRedirectsEnabled(false);
- CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(builder.build()).build();
- return new HttpRequestBuilder(httpClient).httpTransport(internalCluster().getDataNodeInstance(HttpServerTransport.class));
- }
-
- public void testRedirectSitePlugin() throws Exception {
- // We use an HTTP Client to test redirection
- HttpResponse response = httpClient().method("GET").path("/_plugin/dummy").execute();
- assertThat(response, hasStatus(MOVED_PERMANENTLY));
- assertThat(response.getBody(), containsString("/_plugin/dummy/"));
-
- // We test the real URL
- response = httpClient().method("GET").path("/_plugin/dummy/").execute();
- assertThat(response, hasStatus(OK));
- assertThat(response.getBody(), containsString("<title>Dummy Site Plugin</title>"));
- }
-
- /**
- * Test direct access to an existing file (index.html)
- */
- public void testAnyPage() throws Exception {
- HttpResponse response = httpClient().path("/_plugin/dummy/index.html").execute();
- assertThat(response, hasStatus(OK));
- assertThat(response.getBody(), containsString("<title>Dummy Site Plugin</title>"));
- }
-
- /**
- * Test normalizing of path
- */
- public void testThatPathsAreNormalized() throws Exception {
- // more info: https://www.owasp.org/index.php/Path_Traversal
- List<String> notFoundUris = new ArrayList<>();
- notFoundUris.add("/_plugin/dummy/../../../../../log4j.properties");
- notFoundUris.add("/_plugin/dummy/../../../../../%00log4j.properties");
- notFoundUris.add("/_plugin/dummy/..%c0%af..%c0%af..%c0%af..%c0%af..%c0%aflog4j.properties");
- notFoundUris.add("/_plugin/dummy/%2E%2E/%2E%2E/%2E%2E/%2E%2E/index.html");
- notFoundUris.add("/_plugin/dummy/%2e%2e/%2e%2e/%2e%2e/%2e%2e/index.html");
- notFoundUris.add("/_plugin/dummy/%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2findex.html");
- notFoundUris.add("/_plugin/dummy/%2E%2E/%2E%2E/%2E%2E/%2E%2E/index.html");
- notFoundUris.add("/_plugin/dummy/..%5C..%5C..%5C..%5C..%5Clog4j.properties");
-
- for (String uri : notFoundUris) {
- HttpResponse response = httpClient().path(uri).execute();
- String message = String.format(Locale.ROOT, "URI [%s] expected to be not found", uri);
- assertThat(message, response, hasStatus(NOT_FOUND));
- }
-
- // using relative path inside of the plugin should work
- HttpResponse response = httpClient().path("/_plugin/dummy/dir1/../dir1/../index.html").execute();
- assertThat(response, hasStatus(OK));
- assertThat(response.getBody(), containsString("<title>Dummy Site Plugin</title>"));
- }
-
- /**
- * Test case for #4845: https://github.com/elasticsearch/elasticsearch/issues/4845
- * Serving _site plugins do not pick up on index.html for sub directories
- */
- public void testWelcomePageInSubDirs() throws Exception {
- HttpResponse response = httpClient().path("/_plugin/subdir/dir/").execute();
- assertThat(response, hasStatus(OK));
- assertThat(response.getBody(), containsString("<title>Dummy Site Plugin (subdir)</title>"));
-
- response = httpClient().path("/_plugin/subdir/dir_without_index/").execute();
- assertThat(response, hasStatus(FORBIDDEN));
-
- response = httpClient().path("/_plugin/subdir/dir_without_index/page.html").execute();
- assertThat(response, hasStatus(OK));
- assertThat(response.getBody(), containsString("<title>Dummy Site Plugin (page)</title>"));
- }
-}
diff --git a/core/src/test/java/org/elasticsearch/plugins/SitePluginRelativePathConfigIT.java b/core/src/test/java/org/elasticsearch/plugins/SitePluginRelativePathConfigIT.java
deleted file mode 100644
index 1cde90d698..0000000000
--- a/core/src/test/java/org/elasticsearch/plugins/SitePluginRelativePathConfigIT.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.elasticsearch.plugins;
-
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.elasticsearch.common.io.PathUtils;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.http.HttpServerTransport;
-import org.elasticsearch.test.ESIntegTestCase;
-import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
-import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
-import org.elasticsearch.test.rest.client.http.HttpResponse;
-
-import java.nio.file.Path;
-
-import static org.apache.lucene.util.Constants.WINDOWS;
-import static org.elasticsearch.common.settings.Settings.settingsBuilder;
-import static org.elasticsearch.rest.RestStatus.OK;
-import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasStatus;
-
-@ClusterScope(scope = SUITE, numDataNodes = 1)
-public class SitePluginRelativePathConfigIT extends ESIntegTestCase {
- private final Path root = PathUtils.get(".").toAbsolutePath().getRoot();
-
- @Override
- protected Settings nodeSettings(int nodeOrdinal) {
- String cwdToRoot = getRelativePath(PathUtils.get(".").toAbsolutePath());
- Path pluginDir = PathUtils.get(cwdToRoot, relativizeToRootIfNecessary(getDataPath("/org/elasticsearch/test_plugins")).toString());
-
- Path tempDir = createTempDir();
- boolean useRelativeInMiddleOfPath = randomBoolean();
- if (useRelativeInMiddleOfPath) {
- pluginDir = PathUtils.get(tempDir.toString(), getRelativePath(tempDir), pluginDir.toString());
- }
-
- return settingsBuilder()
- .put(super.nodeSettings(nodeOrdinal))
- .put("path.plugins", pluginDir)
- .put("force.http.enabled", true)
- .build();
- }
-
- public void testThatRelativePathsDontAffectPlugins() throws Exception {
- HttpResponse response = httpClient().method("GET").path("/_plugin/dummy/").execute();
- assertThat(response, hasStatus(OK));
- }
-
- private Path relativizeToRootIfNecessary(Path path) {
- if (WINDOWS) {
- return root.relativize(path);
- }
- return path;
- }
-
- private String getRelativePath(Path path) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < path.getNameCount(); i++) {
- sb.append("..");
- sb.append(path.getFileSystem().getSeparator());
- }
-
- return sb.toString();
- }
-
- @Override
- public HttpRequestBuilder httpClient() {
- CloseableHttpClient httpClient = HttpClients.createDefault();
- return new HttpRequestBuilder(httpClient).httpTransport(internalCluster().getDataNodeInstance(HttpServerTransport.class));
- }
-}