use of org.neo4j.test.extension.DisabledForRoot in project neo4j by neo4j.
the class ConfigTest method shouldLogIfConfigFileCouldNotBeRead.
@Test
@DisabledForRoot
void shouldLogIfConfigFileCouldNotBeRead() throws IOException {
AssertableLogProvider logProvider = new AssertableLogProvider(true);
Log log = logProvider.getLog(Config.class);
Path confFile = testDirectory.file("test.conf");
assertTrue(confFile.toFile().createNewFile());
assumeTrue(confFile.toFile().setReadable(false));
Config config = Config.emptyBuilder().fromFileNoThrow(confFile).build();
config.setLogger(log);
assertThat(logProvider).containsMessages("Unable to load config file [%s]");
}
use of org.neo4j.test.extension.DisabledForRoot in project neo4j by neo4j.
the class DumperTest method shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsNotWritable.
@Test
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsNotWritable() throws IOException {
Path directory = testDirectory.directory("a-directory");
Path archive = testDirectory.file("subdir").resolve("the-archive.dump");
Files.createDirectories(archive.getParent());
try (Closeable ignored = TestUtils.withPermissions(archive.getParent(), emptySet())) {
AccessDeniedException exception = assertThrows(AccessDeniedException.class, () -> new Dumper().dump(directory, directory, archive, GZIP, Predicates.alwaysFalse()));
assertEquals(archive.getParent().toString(), exception.getMessage());
}
}
use of org.neo4j.test.extension.DisabledForRoot in project neo4j by neo4j.
the class DumpCommandIT method shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock.
@Test
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock() throws Exception {
DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(databaseDirectory);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
Path file = databaseLayout.databaseLockFile();
try (Closeable ignored = withPermissions(file, emptySet())) {
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
assertEquals("You do not have permission to dump the database.", commandFailed.getMessage());
}
}
}
use of org.neo4j.test.extension.DisabledForRoot in project neo4j by neo4j.
the class LoaderTest method shouldGiveAClearErrorMessageIfTheTxLogsParentDirectoryIsNotWritable.
@Test
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldGiveAClearErrorMessageIfTheTxLogsParentDirectoryIsNotWritable() throws IOException {
Path archive = testDirectory.file("the-archive.dump");
Path txLogsDirectory = testDirectory.directory("subdir", "txLogs");
Config config = Config.newBuilder().set(neo4j_home, testDirectory.homePath()).set(transaction_logs_root_path, txLogsDirectory.toAbsolutePath()).set(default_database, "destination").build();
DatabaseLayout databaseLayout = DatabaseLayout.of(config);
Path txLogsRoot = databaseLayout.getTransactionLogsDirectory().getParent();
try (Closeable ignored = withPermissions(txLogsRoot, emptySet())) {
AccessDeniedException exception = assertThrows(AccessDeniedException.class, () -> new Loader().load(archive, databaseLayout));
assertEquals(txLogsRoot.toString(), exception.getMessage());
}
}
use of org.neo4j.test.extension.DisabledForRoot in project neo4j by neo4j.
the class DefaultFileSystemAbstractionTest method shouldFailGracefullyWhenPathCannotBeCreated.
@Test
// Windows doesn't seem to be able to set a directory read only without complex ACLs
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldFailGracefullyWhenPathCannotBeCreated() throws Exception {
Files.createDirectories(path);
assertTrue(fsa.fileExists(path));
Files.setPosixFilePermissions(path, EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.GROUP_READ, PosixFilePermission.OTHERS_READ));
path = path.resolve("some_file");
IOException exception = assertThrows(IOException.class, () -> fsa.mkdirs(path));
assertFalse(fsa.isDirectory(path));
String expectedMessage = format(UNABLE_TO_CREATE_DIRECTORY_FORMAT, path);
assertThat(exception.getMessage()).isEqualTo(expectedMessage);
Throwable cause = exception.getCause();
assertThat(cause).isInstanceOf(AccessDeniedException.class);
}
Aggregations