|
@@ -12,6 +12,7 @@ package org.elasticsearch.entitlement.qa.test;
|
|
import org.elasticsearch.core.SuppressForbidden;
|
|
import org.elasticsearch.core.SuppressForbidden;
|
|
import org.elasticsearch.entitlement.qa.entitled.EntitledActions;
|
|
import org.elasticsearch.entitlement.qa.entitled.EntitledActions;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -45,6 +46,91 @@ class FileCheckActions {
|
|
return testRootDir.resolve("read_write_file");
|
|
return testRootDir.resolve("read_write_file");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileCreateNewFile() throws IOException {
|
|
|
|
+ readWriteDir().resolve("new_file").toFile().createNewFile();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileCreateTempFile() throws IOException {
|
|
|
|
+ File.createTempFile("prefix", "suffix", readWriteDir().toFile());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileDelete() throws IOException {
|
|
|
|
+ Path toDelete = readWriteDir().resolve("to_delete");
|
|
|
|
+ EntitledActions.createFile(toDelete);
|
|
|
|
+ toDelete.toFile().delete();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileDeleteOnExit() throws IOException {
|
|
|
|
+ Path toDelete = readWriteDir().resolve("to_delete_on_exit");
|
|
|
|
+ EntitledActions.createFile(toDelete);
|
|
|
|
+ toDelete.toFile().deleteOnExit();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileMkdir() throws IOException {
|
|
|
|
+ Path mkdir = readWriteDir().resolve("mkdir");
|
|
|
|
+ mkdir.toFile().mkdir();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileMkdirs() throws IOException {
|
|
|
|
+ Path mkdir = readWriteDir().resolve("mkdirs");
|
|
|
|
+ mkdir.toFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileRenameTo() throws IOException {
|
|
|
|
+ Path toRename = readWriteDir().resolve("to_rename");
|
|
|
|
+ EntitledActions.createFile(toRename);
|
|
|
|
+ toRename.toFile().renameTo(readWriteDir().resolve("renamed").toFile());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileSetExecutable() throws IOException {
|
|
|
|
+ readWriteFile().toFile().setExecutable(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileSetExecutableOwner() throws IOException {
|
|
|
|
+ readWriteFile().toFile().setExecutable(false, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileSetLastModified() throws IOException {
|
|
|
|
+ readWriteFile().toFile().setLastModified(System.currentTimeMillis());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileSetReadable() throws IOException {
|
|
|
|
+ readWriteFile().toFile().setReadable(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileSetReadableOwner() throws IOException {
|
|
|
|
+ readWriteFile().toFile().setReadable(true, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileSetReadOnly() throws IOException {
|
|
|
|
+ Path readOnly = readWriteDir().resolve("read_only");
|
|
|
|
+ EntitledActions.createFile(readOnly);
|
|
|
|
+ readOnly.toFile().setReadOnly();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileSetWritable() throws IOException {
|
|
|
|
+ readWriteFile().toFile().setWritable(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @EntitlementTest(expectedAccess = PLUGINS)
|
|
|
|
+ static void fileSetWritableOwner() throws IOException {
|
|
|
|
+ readWriteFile().toFile().setWritable(true, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
@EntitlementTest(expectedAccess = PLUGINS)
|
|
@EntitlementTest(expectedAccess = PLUGINS)
|
|
static void createScannerFile() throws FileNotFoundException {
|
|
static void createScannerFile() throws FileNotFoundException {
|
|
new Scanner(readFile().toFile());
|
|
new Scanner(readFile().toFile());
|