-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional test for Info-Zip generated ZipCrypto encrypted file. Rela…
…tes to Issue 471.
- Loading branch information
1 parent
e1cddb3
commit 1bfa3bb
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
|
||
// Tests for github issue 471: https://github.com/cthackers/adm-zip/issues/471 | ||
|
||
const assert = require("assert"); | ||
const path = require("path"); | ||
const Zip = require("../../adm-zip"); | ||
|
||
describe("decryption with info-zip spec password check", () => { | ||
|
||
|
||
// test decryption with both password types | ||
it("test decrypted data with password", () => { | ||
// the issue-471-infozip-encrypted.zip file has been generated with Info-Zip Zip 2.32, but the Info-Zip | ||
// standard is used by other zip generators as well. | ||
const infoZip = new Zip(path.join(__dirname, "../assets/issue-471-infozip-encrypted.zip")); | ||
const entries = infoZip.getEntries(); | ||
assert(entries.length === 1, "Good: Test archive contains exactly 1 file"); | ||
|
||
const testFile = entries.filter(function (entry) { | ||
return entry.entryName === "dummy.txt"; | ||
}); | ||
assert(testFile.length === 1, "Good: dummy.txt file exists as archive entry"); | ||
|
||
const readData = entries[0].getData('secret'); | ||
assert(readData.toString('utf8').startsWith('How much wood could a woodchuck chuck'), "Good: buffer matches expectations"); | ||
|
||
// assert that the following call throws an exception | ||
assert.throws(() => { | ||
const readDataBad = entries[0].getData('badpassword'); | ||
}, "Good: error thrown for bad password"); | ||
|
||
}); | ||
}); | ||
|