mirror of https://github.com/apache/nifi.git
NIFI-7760 Remove invalid permission check
Because even though permissions are only the 7 least significant bits of the file mode but the file mode can be wider and can contain further info (like the sticky bit). Extend unit test for converting file mode with sticky bit into 'rwx' style permission string. Remove old test cases This closes #4490. Signed-off-by: Peter Turcsanyi <turcsanyi@apache.org>
This commit is contained in:
parent
d0c0f9704c
commit
aaab9ee0cf
|
@ -220,10 +220,6 @@ public class FileInfo implements Comparable<FileInfo>, Serializable, ListableEnt
|
|||
}
|
||||
|
||||
public static String permissionToString(int fileModeOctal) {
|
||||
if (fileModeOctal > 0777 || fileModeOctal < 00) {
|
||||
throw new IllegalArgumentException("Invalid permission numerals");
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (char p : PERMISSION_MODIFIER_CHARS) {
|
||||
sb.append((fileModeOctal & 1) == 1 ? p : '-');
|
||||
|
|
|
@ -27,19 +27,13 @@ public class TestFileInfo {
|
|||
String rwxPerm = FileInfo.permissionToString(0567);
|
||||
assertEquals("r-xrw-rwx", rwxPerm);
|
||||
|
||||
// Test with sticky bit
|
||||
rwxPerm = FileInfo.permissionToString(01567);
|
||||
assertEquals("r-xrw-rwx", rwxPerm);
|
||||
|
||||
rwxPerm = FileInfo.permissionToString(03);
|
||||
assertEquals("-------wx", rwxPerm);
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testPermissionModeToStringInvalidFourDigits() {
|
||||
FileInfo.permissionToString(01000);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testPermissionModeToStringInvalidNegative() {
|
||||
FileInfo.permissionToString(-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue