-
- @Test
- public void testDirectoryValidateReadableFile() {
- apiCmdArgs.setConfigurationFilePath("src/test/resources/");
- assertThatThrownBy(
- apiCmdArgs::validate
- )
- .isInstanceOf(PolicyApiException.class)
- .hasMessageContaining("file \"src/test/resources/\" is not a normal file");
- }
-
- @Test
- public void testReadPermissionValidateReadableFile() throws IOException {
- String filepath = "src/test/resources/unreadablefile.json";
- Set<PosixFilePermission> notReadable = PosixFilePermissions.fromString("-wx-wx-wx");
- FileAttribute<?> permissions = PosixFilePermissions.asFileAttribute(notReadable);
- Path pathObj = Paths.get(filepath);
- Files.createFile(pathObj, permissions);
- apiCmdArgs.setConfigurationFilePath(filepath);
- assertThatThrownBy(
- apiCmdArgs::validate
- )
- .isInstanceOf(PolicyApiException.class)
- .hasMessageContaining(
- "file \"src/test/resources/unreadablefile.json\" is ureadable");
- Files.deleteIfExists(pathObj);
- }