|
32 | 32 | import static ee.openeid.siga.service.signature.test.RequestUtil.SIGNED_HASHCODE; |
33 | 33 | import static ee.openeid.siga.service.signature.test.RequestUtil.SIGNED_HASHCODE_SEVERAL_DATAFILES; |
34 | 34 | import static ee.openeid.siga.service.signature.test.RequestUtil.SIGNED_HASHCODE_SEVERAL_DATAFILES_RANDOM_ORDER; |
| 35 | +import static ee.openeid.siga.service.signature.test.RequestUtil.UNKNOWN_MIMETYPES_DEFINED_IN_MANIFEST; |
35 | 36 | import static org.junit.jupiter.api.Assertions.assertEquals; |
36 | 37 | import static org.junit.jupiter.api.Assertions.assertFalse; |
37 | 38 | import static org.junit.jupiter.api.Assertions.assertNull; |
@@ -231,6 +232,25 @@ void manifestHasDifferentFileNameOrder() throws URISyntaxException, IOException |
231 | 232 | assertEquals("test2.txt", hashcodeContainer.getDataFiles().get(2).getFileName()); |
232 | 233 | } |
233 | 234 |
|
| 235 | + @Test |
| 236 | + void shouldUseExistingMimetypeFromManifestForUnknownMimetype() throws URISyntaxException, IOException { |
| 237 | + HashcodeContainer hashcodeContainer = new HashcodeContainer(); |
| 238 | + byte[] container = TestUtil.getFile(UNKNOWN_MIMETYPES_DEFINED_IN_MANIFEST); |
| 239 | + hashcodeContainer.open(container); |
| 240 | + HashcodeContainer newContainer; |
| 241 | + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { |
| 242 | + hashcodeContainer.save(outputStream); |
| 243 | + newContainer = new HashcodeContainer(); |
| 244 | + newContainer.open(outputStream.toByteArray()); |
| 245 | + } |
| 246 | + |
| 247 | + assertEquals(2, newContainer.getDataFiles().size()); |
| 248 | + assertEquals("text_file.txt", newContainer.getDataFiles().get(0).getFileName()); |
| 249 | + assertEquals("text/plain", newContainer.getDataFiles().get(0).getMimeType()); |
| 250 | + assertEquals("word_file.docx", newContainer.getDataFiles().get(1).getFileName()); |
| 251 | + assertEquals("application/vnd.openxmlformats-officedocument.wordprocessingml.document", newContainer.getDataFiles().get(1).getMimeType()); |
| 252 | + } |
| 253 | + |
234 | 254 | @Test |
235 | 255 | void couldNotAddDataFileWhenSignatureExists() throws URISyntaxException, IOException { |
236 | 256 | HashcodeContainer hashcodeContainer = new HashcodeContainer(); |
|
0 commit comments