Skip to content

Commit

Permalink
new test for password protected zip
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael5601 committed May 27, 2024
1 parent f67b49b commit 155c50d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,23 @@ public void testOpenFakeZip() {
fail("Expected a CoreException, but got a different type of exception.");
}
}

@Test
public void testOpenPasswordProtectedZip() {
try {
ZipFileSystemTestSetup.copyZipFileIntoProject(ZipFileSystemTestSetup.firstProject,
ZipFileSystemTestSetup.PASSWORD_PROTECTED_ZIP_FILE_NAME);
IFile passwordProtectedZipFile = ZipFileSystemTestSetup.firstProject
.getFile(ZipFileSystemTestSetup.PASSWORD_PROTECTED_ZIP_FILE_NAME);
ensureExists(passwordProtectedZipFile);

ZipFileSystemTestUtil.openZipFile(passwordProtectedZipFile);
fail("Expected an IOException due to password protection.");
} catch (CoreException e) {
String expectedMessage = "Zip File could not be opened";
assertTrue("Expected different error message", e.getMessage().contains(expectedMessage));
} catch (Exception e) {
fail("Expected a CoreException, but got a different type of exception.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ZipFileSystemTestSetup {
static final String TEXT_FILE_NAME = "Text.txt";
static final String DEEP_NESTED_ZIP_FILE_NAME = "DeepNested.zip";
static final String FAKE_ZIP_FILE_NAME = "Fake.zip";
static final String PASSWORD_PROTECTED_ZIP_FILE_NAME = "PasswordProtected.zip";
static IProject firstProject;
static IProject secondProject;
static IProgressMonitor progressMonitor = new NullProgressMonitor();
Expand Down

0 comments on commit 155c50d

Please sign in to comment.