7
7
import org .junit .jupiter .api .Assertions ;
8
8
import org .junit .jupiter .api .Test ;
9
9
10
- class FileUtilitiesTest {
10
+ class FileSecurityUtilsTest {
11
11
12
12
@ Test
13
13
void isFileInDir_outside_successfullyWithResult () throws IOException {
14
14
Path sourcePath = Paths .get ("src" ).toAbsolutePath ();
15
15
Path cwd = Paths .get ("" ).toAbsolutePath ();
16
16
17
- boolean isOutside = FileUtilities .isFileOutsideDir (cwd .toString (), sourcePath .toString ());
17
+ boolean isOutside = FileSecurityUtils .isFileOutsideDir (cwd .toString (), sourcePath .toString ());
18
18
Assertions .assertTrue (isOutside );
19
19
}
20
20
@@ -23,35 +23,35 @@ void isFileInDir_inside_successfullyWithResult() throws IOException {
23
23
Path sourcePath = Paths .get ("src" ).toAbsolutePath ();
24
24
Path cwd = Paths .get ("" ).toAbsolutePath ();
25
25
26
- boolean isOutside = FileUtilities .isFileOutsideDir (sourcePath .toString (), cwd .toString ());
26
+ boolean isOutside = FileSecurityUtils .isFileOutsideDir (sourcePath .toString (), cwd .toString ());
27
27
Assertions .assertFalse (isOutside );
28
28
}
29
29
30
30
@ Test
31
31
void isFileInDir_null_successfully () {
32
32
Assertions .assertThrows (
33
- NullPointerException .class , () -> FileUtilities .isFileOutsideDir (null , null ));
33
+ NullPointerException .class , () -> FileSecurityUtils .isFileOutsideDir (null , null ));
34
34
35
35
Assertions .assertThrows (
36
36
NullPointerException .class ,
37
- () -> FileUtilities .isFileOutsideDir ("file-path-place-holder" , null ));
37
+ () -> FileSecurityUtils .isFileOutsideDir ("file-path-place-holder" , null ));
38
38
39
39
Assertions .assertThrows (
40
40
NullPointerException .class ,
41
- () -> FileUtilities .isFileOutsideDir (null , "base-dir-place-holder" ));
41
+ () -> FileSecurityUtils .isFileOutsideDir (null , "base-dir-place-holder" ));
42
42
}
43
43
44
44
@ Test
45
- void normalize_validInput_successfullyWithResult () throws IOException {
45
+ void normalize_validInput_successfullyWithResult () {
46
46
String validInput = "./In/../Valid/Un/../Normalized/./Path" ;
47
47
String expectedResult = "Valid" + File .separator + "Normalized" + File .separator + "Path" ;
48
48
49
- String actualResult = FileUtilities .normalize (validInput );
49
+ String actualResult = FileSecurityUtils .normalize (validInput );
50
50
Assertions .assertEquals (expectedResult , actualResult );
51
51
}
52
52
53
53
@ Test
54
54
void normalize_null_successfully () {
55
- Assertions .assertNull (FileUtilities .normalize (null ));
55
+ Assertions .assertNull (FileSecurityUtils .normalize (null ));
56
56
}
57
57
}
0 commit comments