Skip to content

Commit

Permalink
[P4ADEV-1830] fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mscarsel committed Jan 14, 2025
1 parent ebf1477 commit a3f9666
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,28 @@ void givenValidFileWhenSaveToSharedFolderThenOK() {
filesMockedStatic.verifyNoMoreInteractions();
}
}

@Test
void givenInvalidPathWhenSaveToSharedFolderThenInvalidFileException() {
MockMultipartFile file = new MockMultipartFile(
"ingestionFlowFile",
"test.txt",
MediaType.TEXT_PLAIN_VALUE,
"this is a test file".getBytes()
);

try (MockedStatic<AESUtils> aesUtilsMockedStatic = Mockito.mockStatic(
AESUtils.class);
MockedStatic<Files> filesMockedStatic = Mockito.mockStatic(
Files.class)) {
try {
fileStorerService.saveToSharedFolder(file, "/relative/../../test");
Assertions.fail("Expected InvalidFileException");
} catch (InvalidFileException e) {
Mockito.verifyNoInteractions(foldersPathsConfig);
aesUtilsMockedStatic.verifyNoInteractions();
filesMockedStatic.verifyNoInteractions();
}
}
}
}

0 comments on commit a3f9666

Please sign in to comment.