|
@@ -27,6 +27,7 @@ import org.apache.lucene.util.SuppressForbidden;
|
|
|
import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.cli.MockTerminal;
|
|
|
import org.elasticsearch.cli.UserError;
|
|
|
+import org.elasticsearch.common.collect.Tuple;
|
|
|
import org.elasticsearch.common.io.PathUtils;
|
|
|
import org.elasticsearch.common.io.PathUtilsForTesting;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
@@ -54,8 +55,10 @@ import java.nio.file.attribute.PosixFileAttributeView;
|
|
|
import java.nio.file.attribute.PosixFileAttributes;
|
|
|
import java.nio.file.attribute.PosixFilePermission;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.function.Supplier;
|
|
@@ -129,7 +132,7 @@ public class InstallPluginCommandTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
/** Creates a test environment with bin, config and plugins directories. */
|
|
|
- static Environment createEnv(FileSystem fs, Function<String, Path> temp) throws IOException {
|
|
|
+ static Tuple<Path, Environment> createEnv(FileSystem fs, Function<String, Path> temp) throws IOException {
|
|
|
Path home = temp.apply("install-plugin-command-tests");
|
|
|
Files.createDirectories(home.resolve("bin"));
|
|
|
Files.createFile(home.resolve("bin").resolve("elasticsearch"));
|
|
@@ -140,7 +143,7 @@ public class InstallPluginCommandTests extends ESTestCase {
|
|
|
Settings settings = Settings.builder()
|
|
|
.put("path.home", home)
|
|
|
.build();
|
|
|
- return new Environment(settings);
|
|
|
+ return Tuple.tuple(home, new Environment(settings));
|
|
|
}
|
|
|
|
|
|
static Path createPluginDir(Function<String, Path> temp) throws IOException {
|
|
@@ -185,20 +188,22 @@ public class InstallPluginCommandTests extends ESTestCase {
|
|
|
return writeZip(structure, "elasticsearch");
|
|
|
}
|
|
|
|
|
|
- static MockTerminal installPlugin(String pluginUrl, Environment env) throws Exception {
|
|
|
- return installPlugin(pluginUrl, env, false);
|
|
|
+ static MockTerminal installPlugin(String pluginUrl, Path home) throws Exception {
|
|
|
+ return installPlugin(pluginUrl, home, false);
|
|
|
}
|
|
|
|
|
|
- static MockTerminal installPlugin(String pluginUrl, Environment env, boolean jarHellCheck) throws Exception {
|
|
|
+ static MockTerminal installPlugin(String pluginUrl, Path home, boolean jarHellCheck) throws Exception {
|
|
|
+ Map<String, String> settings = new HashMap<>();
|
|
|
+ settings.put("path.home", home.toString());
|
|
|
MockTerminal terminal = new MockTerminal();
|
|
|
- new InstallPluginCommand(env) {
|
|
|
+ new InstallPluginCommand() {
|
|
|
@Override
|
|
|
void jarHellCheck(Path candidate, Path pluginsDir) throws Exception {
|
|
|
if (jarHellCheck) {
|
|
|
super.jarHellCheck(candidate, pluginsDir);
|
|
|
}
|
|
|
}
|
|
|
- }.execute(terminal, pluginUrl, true);
|
|
|
+ }.execute(terminal, pluginUrl, true, settings);
|
|
|
return terminal;
|
|
|
}
|
|
|
|
|
@@ -275,192 +280,176 @@ public class InstallPluginCommandTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testSomethingWorks() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- assertPlugin("fake", pluginDir, env);
|
|
|
+ installPlugin(pluginZip, env.v1());
|
|
|
+ assertPlugin("fake", pluginDir, env.v2());
|
|
|
}
|
|
|
|
|
|
public void testSpaceInUrl() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
Path pluginZipWithSpaces = createTempFile("foo bar", ".zip");
|
|
|
try (InputStream in = new URL(pluginZip).openStream()) {
|
|
|
Files.copy(in, pluginZipWithSpaces, StandardCopyOption.REPLACE_EXISTING);
|
|
|
}
|
|
|
- installPlugin(pluginZipWithSpaces.toUri().toURL().toString(), env);
|
|
|
- assertPlugin("fake", pluginDir, env);
|
|
|
+ installPlugin(pluginZipWithSpaces.toUri().toURL().toString(), env.v1());
|
|
|
+ assertPlugin("fake", pluginDir, env.v2());
|
|
|
}
|
|
|
|
|
|
public void testMalformedUrlNotMaven() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
// has two colons, so it appears similar to maven coordinates
|
|
|
- MalformedURLException e = expectThrows(MalformedURLException.class, () -> {
|
|
|
- installPlugin("://host:1234", env);
|
|
|
- });
|
|
|
+ MalformedURLException e = expectThrows(MalformedURLException.class, () -> installPlugin("://host:1234", env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("no protocol"));
|
|
|
}
|
|
|
|
|
|
public void testPluginsDirMissing() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
- Files.delete(env.pluginsFile());
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
+ Files.delete(env.v2().pluginsFile());
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- assertPlugin("fake", pluginDir, env);
|
|
|
+ installPlugin(pluginZip, env.v1());
|
|
|
+ assertPlugin("fake", pluginDir, env.v2());
|
|
|
}
|
|
|
|
|
|
public void testPluginsDirReadOnly() throws Exception {
|
|
|
assumeTrue("posix and filesystem", isPosix && isReal);
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
- try (PosixPermissionsResetter pluginsAttrs = new PosixPermissionsResetter(env.pluginsFile())) {
|
|
|
+ try (PosixPermissionsResetter pluginsAttrs = new PosixPermissionsResetter(env.v2().pluginsFile())) {
|
|
|
pluginsAttrs.setPermissions(new HashSet<>());
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- IOException e = expectThrows(IOException.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
- assertTrue(e.getMessage(), e.getMessage().contains(env.pluginsFile().toString()));
|
|
|
+ IOException e = expectThrows(IOException.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
+ assertTrue(e.getMessage(), e.getMessage().contains(env.v2().pluginsFile().toString()));
|
|
|
}
|
|
|
- assertInstallCleaned(env);
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testBuiltinModule() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
String pluginZip = createPlugin("lang-groovy", pluginDir);
|
|
|
- UserError e = expectThrows(UserError.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
+ UserError e = expectThrows(UserError.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("is a system module"));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testJarHell() throws Exception {
|
|
|
// jar hell test needs a real filesystem
|
|
|
assumeTrue("real filesystem", isReal);
|
|
|
- Environment environment = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> environment = createEnv(fs, temp);
|
|
|
Path pluginDirectory = createPluginDir(temp);
|
|
|
writeJar(pluginDirectory.resolve("other.jar"), "FakePlugin");
|
|
|
String pluginZip = createPlugin("fake", pluginDirectory); // adds plugin.jar with FakePlugin
|
|
|
- IllegalStateException e = expectThrows(IllegalStateException.class, () -> {
|
|
|
- installPlugin(pluginZip, environment, true);
|
|
|
- });
|
|
|
+ IllegalStateException e = expectThrows(IllegalStateException.class, () -> installPlugin(pluginZip, environment.v1(), true));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("jar hell"));
|
|
|
- assertInstallCleaned(environment);
|
|
|
+ assertInstallCleaned(environment.v2());
|
|
|
}
|
|
|
|
|
|
public void testIsolatedPlugins() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
// these both share the same FakePlugin class
|
|
|
Path pluginDir1 = createPluginDir(temp);
|
|
|
String pluginZip1 = createPlugin("fake1", pluginDir1);
|
|
|
- installPlugin(pluginZip1, env);
|
|
|
+ installPlugin(pluginZip1, env.v1());
|
|
|
Path pluginDir2 = createPluginDir(temp);
|
|
|
String pluginZip2 = createPlugin("fake2", pluginDir2);
|
|
|
- installPlugin(pluginZip2, env);
|
|
|
- assertPlugin("fake1", pluginDir1, env);
|
|
|
- assertPlugin("fake2", pluginDir2, env);
|
|
|
+ installPlugin(pluginZip2, env.v1());
|
|
|
+ assertPlugin("fake1", pluginDir1, env.v2());
|
|
|
+ assertPlugin("fake2", pluginDir2, env.v2());
|
|
|
}
|
|
|
|
|
|
public void testExistingPlugin() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- UserError e = expectThrows(UserError.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
+ installPlugin(pluginZip, env.v1());
|
|
|
+ UserError e = expectThrows(UserError.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("already exists"));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testBin() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Path binDir = pluginDir.resolve("bin");
|
|
|
Files.createDirectory(binDir);
|
|
|
Files.createFile(binDir.resolve("somescript"));
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- assertPlugin("fake", pluginDir, env);
|
|
|
+ installPlugin(pluginZip, env.v1());
|
|
|
+ assertPlugin("fake", pluginDir, env.v2());
|
|
|
}
|
|
|
|
|
|
public void testBinNotDir() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Path binDir = pluginDir.resolve("bin");
|
|
|
Files.createFile(binDir);
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- UserError e = expectThrows(UserError.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
+ UserError e = expectThrows(UserError.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("not a directory"));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testBinContainsDir() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Path dirInBinDir = pluginDir.resolve("bin").resolve("foo");
|
|
|
Files.createDirectories(dirInBinDir);
|
|
|
Files.createFile(dirInBinDir.resolve("somescript"));
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- UserError e = expectThrows(UserError.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
+ UserError e = expectThrows(UserError.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("Directories not allowed in bin dir for plugin"));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testBinConflict() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Path binDir = pluginDir.resolve("bin");
|
|
|
Files.createDirectory(binDir);
|
|
|
Files.createFile(binDir.resolve("somescript"));
|
|
|
String pluginZip = createPlugin("elasticsearch", pluginDir);
|
|
|
- FileAlreadyExistsException e = expectThrows(FileAlreadyExistsException.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
- assertTrue(e.getMessage(), e.getMessage().contains(env.binFile().resolve("elasticsearch").toString()));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ FileAlreadyExistsException e = expectThrows(FileAlreadyExistsException.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
+ assertTrue(e.getMessage(), e.getMessage().contains(env.v2().binFile().resolve("elasticsearch").toString()));
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testBinPermissions() throws Exception {
|
|
|
assumeTrue("posix filesystem", isPosix);
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Path binDir = pluginDir.resolve("bin");
|
|
|
Files.createDirectory(binDir);
|
|
|
Files.createFile(binDir.resolve("somescript"));
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- try (PosixPermissionsResetter binAttrs = new PosixPermissionsResetter(env.binFile())) {
|
|
|
+ try (PosixPermissionsResetter binAttrs = new PosixPermissionsResetter(env.v2().binFile())) {
|
|
|
Set<PosixFilePermission> perms = binAttrs.getCopyPermissions();
|
|
|
// make sure at least one execute perm is missing, so we know we forced it during installation
|
|
|
perms.remove(PosixFilePermission.GROUP_EXECUTE);
|
|
|
binAttrs.setPermissions(perms);
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- assertPlugin("fake", pluginDir, env);
|
|
|
+ installPlugin(pluginZip, env.v1());
|
|
|
+ assertPlugin("fake", pluginDir, env.v2());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void testConfig() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Path configDir = pluginDir.resolve("config");
|
|
|
Files.createDirectory(configDir);
|
|
|
Files.createFile(configDir.resolve("custom.yaml"));
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- assertPlugin("fake", pluginDir, env);
|
|
|
+ installPlugin(pluginZip, env.v1());
|
|
|
+ assertPlugin("fake", pluginDir, env.v2());
|
|
|
}
|
|
|
|
|
|
public void testExistingConfig() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
- Path envConfigDir = env.configFile().resolve("fake");
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
+ Path envConfigDir = env.v2().configFile().resolve("fake");
|
|
|
Files.createDirectories(envConfigDir);
|
|
|
Files.write(envConfigDir.resolve("custom.yaml"), "existing config".getBytes(StandardCharsets.UTF_8));
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
@@ -469,8 +458,8 @@ public class InstallPluginCommandTests extends ESTestCase {
|
|
|
Files.write(configDir.resolve("custom.yaml"), "new config".getBytes(StandardCharsets.UTF_8));
|
|
|
Files.createFile(configDir.resolve("other.yaml"));
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- assertPlugin("fake", pluginDir, env);
|
|
|
+ installPlugin(pluginZip, env.v1());
|
|
|
+ assertPlugin("fake", pluginDir, env.v2());
|
|
|
List<String> configLines = Files.readAllLines(envConfigDir.resolve("custom.yaml"), StandardCharsets.UTF_8);
|
|
|
assertEquals(1, configLines.size());
|
|
|
assertEquals("existing config", configLines.get(0));
|
|
@@ -478,80 +467,68 @@ public class InstallPluginCommandTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testConfigNotDir() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Path configDir = pluginDir.resolve("config");
|
|
|
Files.createFile(configDir);
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- UserError e = expectThrows(UserError.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
+ UserError e = expectThrows(UserError.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("not a directory"));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testConfigContainsDir() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Path dirInConfigDir = pluginDir.resolve("config").resolve("foo");
|
|
|
Files.createDirectories(dirInConfigDir);
|
|
|
Files.createFile(dirInConfigDir.resolve("myconfig.yml"));
|
|
|
String pluginZip = createPlugin("fake", pluginDir);
|
|
|
- UserError e = expectThrows(UserError.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
+ UserError e = expectThrows(UserError.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("Directories not allowed in config dir for plugin"));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testConfigConflict() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Path configDir = pluginDir.resolve("config");
|
|
|
Files.createDirectory(configDir);
|
|
|
Files.createFile(configDir.resolve("myconfig.yml"));
|
|
|
String pluginZip = createPlugin("elasticsearch.yml", pluginDir);
|
|
|
- FileAlreadyExistsException e = expectThrows(FileAlreadyExistsException.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
- assertTrue(e.getMessage(), e.getMessage().contains(env.configFile().resolve("elasticsearch.yml").toString()));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ FileAlreadyExistsException e = expectThrows(FileAlreadyExistsException.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
+ assertTrue(e.getMessage(), e.getMessage().contains(env.v2().configFile().resolve("elasticsearch.yml").toString()));
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testMissingDescriptor() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Files.createFile(pluginDir.resolve("fake.yml"));
|
|
|
String pluginZip = writeZip(pluginDir, "elasticsearch");
|
|
|
- NoSuchFileException e = expectThrows(NoSuchFileException.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
+ NoSuchFileException e = expectThrows(NoSuchFileException.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("plugin-descriptor.properties"));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testMissingDirectory() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path pluginDir = createPluginDir(temp);
|
|
|
Files.createFile(pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES));
|
|
|
String pluginZip = writeZip(pluginDir, null);
|
|
|
- UserError e = expectThrows(UserError.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
+ UserError e = expectThrows(UserError.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("`elasticsearch` directory is missing in the plugin zip"));
|
|
|
- assertInstallCleaned(env);
|
|
|
+ assertInstallCleaned(env.v2());
|
|
|
}
|
|
|
|
|
|
public void testZipRelativeOutsideEntryName() throws Exception {
|
|
|
- Environment env = createEnv(fs, temp);
|
|
|
+ Tuple<Path, Environment> env = createEnv(fs, temp);
|
|
|
Path zip = createTempDir().resolve("broken.zip");
|
|
|
try (ZipOutputStream stream = new ZipOutputStream(Files.newOutputStream(zip))) {
|
|
|
stream.putNextEntry(new ZipEntry("elasticsearch/../blah"));
|
|
|
}
|
|
|
String pluginZip = zip.toUri().toURL().toString();
|
|
|
- IOException e = expectThrows(IOException.class, () -> {
|
|
|
- installPlugin(pluginZip, env);
|
|
|
- });
|
|
|
+ IOException e = expectThrows(IOException.class, () -> installPlugin(pluginZip, env.v1()));
|
|
|
assertTrue(e.getMessage(), e.getMessage().contains("resolving outside of plugin directory"));
|
|
|
}
|
|
|
|