aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2021-03-19 09:21:42 +0100
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2021-03-22 13:37:43 +0100
commit25763727265dd20b0301db0164c3e5549700cab4 (patch)
tree35b80e227db0306bca2f2ff9c6af03aa255ee9f5 /src/test
parent92c83fe593132a522cb26a872d94612373e46315 (diff)
Fix path from user input vulnerability
Issue-ID: SDC-3185 Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com> Change-Id: I9c121d2ba24487e45d08d2937cbc7bddc07e163e
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/sdc/helmvalidator/helm/validation/FileManagerTest.java21
1 files changed, 1 insertions, 20 deletions
diff --git a/src/test/java/org/onap/sdc/helmvalidator/helm/validation/FileManagerTest.java b/src/test/java/org/onap/sdc/helmvalidator/helm/validation/FileManagerTest.java
index 89eab80..8057303 100644
--- a/src/test/java/org/onap/sdc/helmvalidator/helm/validation/FileManagerTest.java
+++ b/src/test/java/org/onap/sdc/helmvalidator/helm/validation/FileManagerTest.java
@@ -47,7 +47,6 @@ class FileManagerTest {
private static final String TEST_RESOURCES_TMP = "src/test/resources/tmp";
private static final File TEST_RESOURCES_DIR = new File(TEST_RESOURCES_TMP);
private static final ByteArrayInputStream TEST_INPUT_STREAM = new ByteArrayInputStream("test".getBytes());
- private static final String SAMPLE_FILE_NAME = "sample_file";
private FileManager fileManager;
@@ -71,7 +70,7 @@ class FileManagerTest {
@BeforeEach
void setUp() {
- fileManager = new FileManager(TEST_RESOURCES_TMP);
+ fileManager = new FileManager(TEST_RESOURCES_DIR.getAbsolutePath());
}
@Test
@@ -95,25 +94,7 @@ class FileManagerTest {
assertThat(Files.exists(Paths.get(filePath))).isFalse();
}
- @Test
- void shouldThrowExceptionWhenFileContainsSlash() {
- when(multipartFile.getOriginalFilename()).thenReturn(SAMPLE_FILE_NAME + "/");
- Exception exception = assertThrows(SaveFileException.class,
- () -> fileManager.saveFile(multipartFile));
- assertThat(exception).hasMessageContaining("Not allowed file name");
- }
-
- @Test
- void shouldThrowExceptionWhenFileNameIsNull() {
- when(multipartFile.getOriginalFilename()).thenReturn(null);
-
- Exception exception = assertThrows(SaveFileException.class,
- () -> fileManager.saveFile(multipartFile));
- assertThat(exception).hasMessageContaining("Not allowed file name");
- }
-
private void mockMultipartFile() throws IOException {
- when(multipartFile.getOriginalFilename()).thenReturn(SAMPLE_FILE_NAME);
when(multipartFile.getInputStream()).thenReturn(TEST_INPUT_STREAM);
}
}