use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class InstallPluginCommandTests method testPlatformBinPermissions.
public void testPlatformBinPermissions() throws Exception {
assumeTrue("posix filesystem", isPosix);
Tuple<Path, Environment> env = createEnv(fs, temp);
Path pluginDir = createPluginDir(temp);
Path platformDir = pluginDir.resolve("platform");
Path platformNameDir = platformDir.resolve("linux-x86_64");
Path platformBinDir = platformNameDir.resolve("bin");
Files.createDirectories(platformBinDir);
Path programFile = Files.createFile(platformBinDir.resolve("someprogram"));
// a file created with Files.createFile() should not have execute permissions
Set<PosixFilePermission> sourcePerms = Files.getPosixFilePermissions(programFile);
assertFalse(sourcePerms.contains(PosixFilePermission.OWNER_EXECUTE));
assertFalse(sourcePerms.contains(PosixFilePermission.GROUP_EXECUTE));
assertFalse(sourcePerms.contains(PosixFilePermission.OTHERS_EXECUTE));
String pluginZip = createPlugin("fake", pluginDir);
installPlugin(pluginZip, env.v1());
assertPlugin("fake", pluginDir, env.v2());
// check that the installed program has execute permissions, even though the one added to the plugin didn't
Path installedPlatformBinDir = env.v2().pluginsFile().resolve("fake").resolve("platform").resolve("linux-x86_64").resolve("bin");
assertTrue(Files.isDirectory(installedPlatformBinDir));
Path installedProgramFile = installedPlatformBinDir.resolve("someprogram");
assertTrue(Files.isRegularFile(installedProgramFile));
Set<PosixFilePermission> installedPerms = Files.getPosixFilePermissions(installedProgramFile);
assertTrue(installedPerms.contains(PosixFilePermission.OWNER_EXECUTE));
assertTrue(installedPerms.contains(PosixFilePermission.GROUP_EXECUTE));
assertTrue(installedPerms.contains(PosixFilePermission.OTHERS_EXECUTE));
}
use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class InstallPluginCommandTests method testMissingDescriptor.
public void testMissingDescriptor() throws Exception {
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.v1()));
assertTrue(e.getMessage(), e.getMessage().contains("plugin-descriptor.properties"));
assertInstallCleaned(env.v2());
}
use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class InstallPluginCommandTests method testJarHell.
public void testJarHell() throws Exception {
// jar hell test needs a real filesystem
assumeTrue("real filesystem", isReal);
Tuple<Path, Environment> environment = createEnv(fs, temp);
Path pluginDirectory = createPluginDir(temp);
writeJar(pluginDirectory.resolve("other.jar"), "FakePlugin");
// adds plugin.jar with FakePlugin
String pluginZip = createPlugin("fake", pluginDirectory);
IllegalStateException e = expectThrows(IllegalStateException.class, () -> installPlugin(pluginZip, environment.v1(), true));
assertTrue(e.getMessage(), e.getMessage().contains("jar hell"));
assertInstallCleaned(environment.v2());
}
use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class InstallPluginCommandTests method testBinContainsDir.
public void testBinContainsDir() throws Exception {
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);
UserException e = expectThrows(UserException.class, () -> installPlugin(pluginZip, env.v1()));
assertTrue(e.getMessage(), e.getMessage().contains("Directories not allowed in bin dir for plugin"));
assertInstallCleaned(env.v2());
}
use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class InstallPluginCommandTests method testUnknownPlugin.
public void testUnknownPlugin() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp);
UserException e = expectThrows(UserException.class, () -> installPlugin("foo", env.v1()));
assertTrue(e.getMessage(), e.getMessage().contains("Unknown plugin foo"));
}
Aggregations