zip/0000755000176200001440000000000015212255442011056 5ustar liggesuserszip/tests/0000755000176200001440000000000015170432710012216 5ustar liggesuserszip/tests/testthat/0000755000176200001440000000000015212255442014060 5ustar liggesuserszip/tests/testthat/test-http.R0000644000176200001440000001071615212212275016141 0ustar liggesuserstest_that("zip_list works with range request server", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture() url <- range_server$url(zip_path(za$zip)) expect_snapshot(zip_list_snapshot(url, za$ex), transform = transform_offset) }) test_that("unzip works with range request server", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture() url <- range_server$url(zip_path(za$zip)) exdir <- test_temp_dir() unzip(url, exdir = exdir) expect_snapshot(extracted_tree(exdir, za$ex)) }) test_that("unzip extracts specific files with range request server", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture() url <- range_server$url(zip_path(za$zip)) exdir <- test_temp_dir() target <- paste0(basename(za$ex), "/file1") unzip(url, files = target, exdir = exdir) expect_snapshot(extracted_tree(exdir, za$ex)) }) test_that("zip_list falls back to full download when ranges unsupported", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture() url <- range_server$url(zip_path(za$zip, "no-range")) expect_snapshot(zip_list_snapshot(url, za$ex), transform = transform_offset) }) test_that("zip_list recovers when an oversized suffix range gives 416", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture() url <- range_server$url(zip_path(za$zip, "suffix-416")) expect_snapshot(zip_list_snapshot(url, za$ex), transform = transform_offset) }) test_that("unzip recovers when an oversized suffix range gives 416", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture() url <- range_server$url(zip_path(za$zip, "suffix-416")) exdir <- test_temp_dir() unzip(url, exdir = exdir) expect_snapshot(extracted_tree(exdir, za$ex)) }) test_that("unzip falls back to full download when ranges unsupported", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture() url <- range_server$url(zip_path(za$zip, "no-range")) exdir <- test_temp_dir() expect_snapshot(unzip(url, exdir = exdir)) expect_snapshot(extracted_tree(exdir, za$ex)) }) test_that("unzip falls back to full download per entry when ranges drop out", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture() url <- range_server$url(zip_path(za$zip, "mixed")) exdir <- test_temp_dir() expect_snapshot(unzip(url, exdir = exdir)) expect_snapshot(extracted_tree(exdir, za$ex)) }) test_that("unzip fetches data separately when entry range is truncated", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture() url <- range_server$url(zip_path(za$zip, "truncating")) exdir <- test_temp_dir() unzip(url, exdir = exdir) expect_snapshot(extracted_tree(exdir, za$ex)) }) test_that("zip_list reads a ZIP64 EOCD archive over range requests", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- make_a_zip64() url <- range_server$url(zip_path(za$zip)) expect_snapshot(zip_list_snapshot(url, za$ex), transform = transform_offset) }) test_that("reads a real ZIP64 EOCD-record archive over range requests", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") # zip64.zip's classic EOCD has the cd_offset 0xFFFFFFFF sentinel, so the # real offset must be read from the ZIP64 EOCD record via its locator. # ext_attr has the S_IFREG high bit set; permissions must decode without # overflowing integer range. zf <- test_path("fixtures/zip64.zip") url <- range_server$url(zip_path(zf)) expect_snapshot( zip_list_snapshot(url, sort = TRUE), transform = transform_offset ) exdir <- test_temp_dir() unzip(url, exdir = exdir) expect_snapshot(extracted_tree(exdir)) }) test_that("unzip reads a ZIP64 EOCD archive over range requests", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- make_a_zip64() url <- range_server$url(zip_path(za$zip)) exdir <- test_temp_dir() unzip(url, exdir = exdir) expect_snapshot(extracted_tree(exdir, za$ex)) }) test_that("unzip with junkpaths works with range request server", { skip_if_not_installed("curl") skip_if_not_installed("webfakes") za <- http_fixture(include_directories = FALSE) url <- range_server$url(zip_path(za$zip)) exdir <- test_temp_dir() unzip(url, junkpaths = TRUE, exdir = exdir) expect_snapshot(extracted_tree(exdir)) }) zip/tests/testthat/fixtures/0000755000176200001440000000000015212212275015726 5ustar liggesuserszip/tests/testthat/fixtures/aes128.zip0000644000176200001440000000130315212212275017452 0ustar liggesusersPK3c\' a.txtAE`bgAl;bZ>.|XپW[YPK3c\W big.txtAE$Rs?-Xy7ZW+wj ]@ Pv^~viPFUFIb+u/dev/null || echo ./.z64build) mkdir -p "$work/src/dir" printf 'file1\n' > "$work/src/file1" printf 'file11\n' > "$work/src/file11" printf 'file2\n' > "$work/src/dir/file2" printf 'file3\n' > "$work/src/dir/file3" ( cd "$work" && zip -fz -r -X zip64.zip src >/dev/null ) cp "$work/zip64.zip" zip64.zip rm -rf "$work" # --- zip64-extra.zip : per-entry ZIP64 extended info fields (Python) --- python3 - <<'PY' import zipfile with zipfile.ZipFile('zip64-extra.zip', 'w', zipfile.ZIP_DEFLATED) as z: for name, content in [ ('src/file1', 'file1\n'), ('src/file11', 'file11\n'), ('src/dir/file2', 'file2\n'), ('src/dir/file3', 'file3\n'), ]: with z.open(name, 'w', force_zip64=True) as f: f.write(content.encode()) PY zip/tests/testthat/fixtures/cp437.zip0000644000176200001440000000021415207545633017322 0ustar liggesusersPKm^ @ cataln.txtCP437 filename test PKm^ @ cataln.txtPK9=zip/tests/testthat/fixtures/stored-zero-compsize.zip0000644000176200001440000000037415207537100022563 0ustar liggesusersPKSGDDsubdir/PKSGDDB subdir/hello.txtHWH+UHT(,,ʮT,PHIUPKSGDDsubdir/PKSGDDB %subdir/hello.txtPKsszip/tests/testthat/fixtures/symlink.zip0000644000176200001440000000066515170432710020150 0ustar liggesusersPK nZa/UT /!h !hux PK lZe2~a/fooUT +!h+!hux foo PK nZ!esa/barUT /!h/!hux fooPK nZAa/UT/!hux PK lZe2~<a/fooUT+!hux PK nZ!esa/barUT/!hux PKzip/tests/testthat/fixtures/msdos.zip0000644000176200001440000000115415170432710017601 0ustar liggesusersPKXUUDESCRIPTUT  fc fcux Q]0~)FawEZ]UٖW8Ԫcm͞#bL"|3, 3iwFyt:np&3!dHoөl6PWLJ"@а euECnЕS7([ZbPں { ِmblaa t%6NGrq'Ц9Pd! {k A貴]v}G$Q ZԜL,3^SXoj/2p۶Kil 'Q}l@ZYa߆(_ɂ +:3pyϿNzoiW{/UF a<1I F|(W=RQ\\Y[9vNqj/][ i/f6RW d{ 7`<~~PKXUUDESCRIPTUT fcux PKNzip/tests/testthat/fixtures/abs.zip0000644000176200001440000000021315170432710017214 0ustar liggesusersPK]V/tmp/booboo PKP PK]VP /tmp/booPK6?zip/tests/testthat/fixtures/http-nodirs.zip0000644000176200001440000000105515212212275020726 0ustar liggesusersPK$h\ziptest/dir/file2file2 PKǤ PK$h\ziptest/dir/file3file3 PK PK$h\ ziptest/file1file1 PK) PK$h\ziptest/file11file11 PKE PK$h\Ǥ ziptest/dir/file2PK$h\ Jziptest/dir/file3PK$h\)  ziptest/file1PK$h\E ziptest/file11PK"zip/tests/testthat/fixtures/make-encrypted-fixtures.sh0000755000176200001440000000430515212212275023046 0ustar liggesusers#!/bin/sh # Regenerate the encrypted ZIP test fixtures in this directory. # # These archives are produced by *external* tools (7-Zip and Info-ZIP), not by # this package, so they exercise the inbound interop direction: the package's # reader must decrypt what other implementations encrypt. # # All fixtures use the password secret unless noted otherwise. Each archive # contains the same three entries: # # a.txt - small, stored (too small to benefit from deflate) # sub/b.txt - small, stored, in a subdirectory # big.txt - highly compressible, so it is deflated then encrypted # # aes256.zip - 7-Zip, WinZip AES-256 (AE-2) # aes192.zip - 7-Zip, WinZip AES-192 (AE-2) # aes128.zip - 7-Zip, WinZip AES-128 (AE-2) # zipcrypto.zip - Info-ZIP, legacy traditional PKWARE (ZipCrypto) cipher # # (The non-ASCII / UTF-8 password contract is exercised by a writer+reader # round-trip test rather than a fixture: the 7-Zip CLI rejects a non-ASCII # password argument with E_INVALIDARG.) # # Requires: 7zz (brew install sevenzip) and zip (Info-ZIP). set -e cd "$(dirname "$0")" need() { command -v "$1" >/dev/null 2>&1 || { echo "missing tool: $1" >&2; exit 1; }; } need 7zz need zip work=$(mktemp -d 2>/dev/null || echo ./.encbuild) trap 'rm -rf "$work"' EXIT mkdir -p "$work/sub" printf 'first fixture file\n' > "$work/a.txt" printf 'second file in subdir\n' > "$work/sub/b.txt" # big.txt: compressible so the entry is deflated (real method 8) before # encryption, exercising the decrypt-then-inflate path. i=0; : > "$work/big.txt" while [ "$i" -lt 400 ]; do printf 'The quick brown fox jumps over the lazy dog. 0123456789\n' >> "$work/big.txt" i=$((i + 1)) done mkaes() { # strength password outfile rm -f "$work/$3" ( cd "$work" && 7zz a -tzip -p"$2" -mem="AES$1" "$3" a.txt sub/b.txt big.txt >/dev/null ) cp "$work/$3" "$3" } mkaes 256 secret aes256.zip mkaes 192 secret aes192.zip mkaes 128 secret aes128.zip # Legacy traditional PKWARE encryption (ZipCrypto), via Info-ZIP. rm -f zipcrypto.zip ( cd "$work" && zip -q -P secret zipcrypto.zip a.txt sub/b.txt big.txt ) cp "$work/zipcrypto.zip" zipcrypto.zip echo "Wrote: aes256.zip aes192.zip aes128.zip zipcrypto.zip" zip/tests/testthat/fixtures/zipcrypto.zip0000644000176200001440000000131215212212275020512 0ustar liggesusersPK \$a.txtUT &j&jux "W[&9}`3ƫ#~TCPK$PK \y" sub/b.txtUT &j&jux %]v|@nJ s2hOkάPKy"PK \:ҙWbig.txtUT &j&jux <2˧۩#>%05B°UIflJ X^' ; )$9eB YĿ]V|FK,7rd6҈ܮ-Ic~(m%ȑ49 C8PK:ҙWPK \$a.txtUT&jux PK \y" nsub/b.txtUT&jux PK \:ҙWbig.txtUT&jux PKzip/tests/testthat/fixtures/zip64.zip0000644000176200001440000000156515212212275017435 0ustar liggesusersPK-cV\src/PK-cV\E src/file11file11 PK-cV\src/dir/PK-cV\ src/dir/file3file3 PK-cV\Ǥ src/dir/file2file2 PK-cV\) src/file1file1 PK cV\ Asrc/PK-cV\E  6src/file11PK cV\ Aysrc/dir/PK-cV\ src/dir/file3PK-cV\Ǥ src/dir/file2PK-cV\) =src/file1PK,-~PKPKzip/tests/testthat/fixtures/aes256.zip0000644000176200001440000000133315212212275017457 0ustar liggesusersPK3c\/ a.txtAEuKx̫ /8vP$*ҟYA~ä Lf PK3c\W big.txtAEJ̘8O;(,sVҝE