diff options
| author | Michael Williamson <mike@zwobble.org> | 2025-09-10 16:40:27 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2025-09-10 16:40:27 +0100 |
| commit | 444dc1b64c015197bf6b5219da9459bc0cf6f787 (patch) | |
| tree | e34a6f67f643d5fd160d1465444ddd9c9b872439 /src/test/java/org/zwobble/mammoth/tests/MammothTests.java | |
| parent | 7ef256b4b287af758d5bad0912de7140a4f69fbf (diff) | |
Support disabling external file access
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/MammothTests.java')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/MammothTests.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java index 85a20ce..a072185 100644 --- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java @@ -121,6 +121,29 @@ public class MammothTests { } @Test + public void warnIfDocumentHasImagesStoredOutsideOfDocumentWhenExternalFileAccessIsDisabled() throws IOException { + Path tempDirectory = Files.createTempDirectory("mammoth-"); + try { + Path documentPath = tempDirectory.resolve("external-picture.docx"); + Files.copy(TestData.file("external-picture.docx").toPath(), documentPath); + Files.copy(TestData.file("tiny-picture.png").toPath(), tempDirectory.resolve("tiny-picture.png")); + assertThat( + new DocumentConverter() + .disableExternalFileAccess() + .convertToHtml(documentPath.toFile()), + allOf( + hasProperty("value", equalTo("")), + hasProperty("warnings", contains( + equalTo("could not open external image 'tiny-picture.png': external file access is disabled") + )) + ) + ); + } finally { + tempDirectory.toFile().delete(); + } + } + + @Test public void warnIfImagesStoredOutsideOfDocumentAreNotFound() throws IOException { Path tempDirectory = Files.createTempDirectory("mammoth-"); try { |
