summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-09-15 06:05:01 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-09-15 06:05:01 (GMT)
commit53287645760f083e2fbaf93ea73ec0f1992ca67d (patch)
tree0ab775f71c57be56b6378c20f3ff60016dd6de91 /tests
parent748f1c39e564df9766e43843cc48167342d39dc2 (diff)
downloadtcl-53287645760f083e2fbaf93ea73ec0f1992ca67d.zip
tcl-53287645760f083e2fbaf93ea73ec0f1992ca67d.tar.gz
tcl-53287645760f083e2fbaf93ea73ec0f1992ca67d.tar.bz2
zipfs password tests
Diffstat (limited to 'tests')
-rw-r--r--tests/zipfiles/README2
-rw-r--r--tests/zipfs.test46
2 files changed, 40 insertions, 8 deletions
diff --git a/tests/zipfiles/README b/tests/zipfiles/README
index e6c366e..38ce998 100644
--- a/tests/zipfiles/README
+++ b/tests/zipfiles/README
@@ -1,7 +1,7 @@
The files in this directory are used for testing zipfs file systems.
They fall under the following licenses:
-test-overlay.zip, test-zip-in-zip.zip - Tcl's license
+test-overlay.zip, test-password.zip, test-zip-in-zip.zip - Tcl's license
All other files - test files from libzip (https://libzip.org) and are covered by
the license in LICENSE-libzip. \ No newline at end of file
diff --git a/tests/zipfs.test b/tests/zipfs.test
index 44228c7..4edb629 100644
--- a/tests/zipfs.test
+++ b/tests/zipfs.test
@@ -665,7 +665,7 @@ namespace eval test_ns_zipfs {
mount [zippath test.zip]
set newmount [file join [zipfs root] test testdir]
mount [zippath test-overlay.zip] $newmount
- } -constraints knownBug -cleanup {
+ } -constraints bug-4ae42446ab -cleanup {
cleanup
} -body {
# KNOWN BUG. The test2 file is also present in parent mount.
@@ -712,7 +712,7 @@ namespace eval test_ns_zipfs {
# Some tests have !zipfslib constraint because otherwise they dump the entire Tcl library which is mounted on root
testzipfslist no-mounts "" {} {} -constraints !zipfslib
testzipfslist no-pattern "" {test.zip testmountA} {testmountA testmountA/test testmountA/testdir testmountA/testdir/test2} -constraints !zipfslib
- testzipfslist no-pattern-mount-on-root "" {test.zip {}} {{} test testdir testdir/test2} -constraints knownBug
+ testzipfslist no-pattern-mount-on-root "" {test.zip {}} {{} test testdir testdir/test2} -constraints bug-d056ee6d30
testzipfslist no-pattern-multiple "" {test.zip testmountA test.zip testmountB/subdir} {
testmountA testmountA/test testmountA/testdir testmountA/testdir/test2
testmountB/subdir testmountB/subdir/test testmountB/subdir/testdir testmountB/subdir/testdir/test2
@@ -749,7 +749,7 @@ namespace eval test_ns_zipfs {
testzipfsexists file [file join $defaultMountPoint test] 1
testzipfsexists dir [file join $defaultMountPoint testdir] 1
testzipfsexists mountpoint $defaultMountPoint 1
- testzipfsexists root [zipfs root] 1 -constraints knownBug
+ testzipfsexists root [zipfs root] 1 -constraints bug-02acab5aea
#
# zipfs find
@@ -838,7 +838,7 @@ namespace eval test_ns_zipfs {
test.zip {} test.zip testmountB/subdir
} [lmap path {
test testdir testdir/test2
- } {file join [zipfs root] $path}] -constraints knownBug
+ } {file join [zipfs root] $path}] -constraints bug-6183f535c8
#
# zipfs info
@@ -928,7 +928,7 @@ namespace eval test_ns_zipfs {
set zippath [zippath $zippath]
test zipfs-uncompress-$id $id -setup {
unset -nocomplain fd
- mount $zippath
+ zipfs mount $zippath $defaultMountPoint
} -cleanup {
# In case mount succeeded when it should not
if {[info exists fd]} {
@@ -947,6 +947,38 @@ namespace eval test_ns_zipfs {
testuncompress xz testfile-xz.zip {unsupported compression method} -returnCodes error
testuncompress zstd testfile-zstd.zip {unsupported compression method} -returnCodes error
+ proc testpassword {id filename password result args} {
+ variable defaultMountPoint
+ set zippath [zippath test-password.zip]
+ test zipfs-password-read-$id $id -setup {
+ unset -nocomplain fd
+ if {$password ne ""} {
+ zipfs mount $zippath $defaultMountPoint $password
+ } else {
+ zipfs mount $zippath $defaultMountPoint
+ }
+ } -cleanup {
+ # In case mount succeeded when it should not
+ if {[info exists fd]} {
+ close $fd
+ }
+ cleanup
+ } -body {
+ set fd [open [file join $defaultMountPoint $filename]]
+ gets $fd
+ } -result $result {*}$args
+ }
+ testpassword plain plain.txt password plaintext
+ testpassword plain-nopassword plain.txt "" plaintext
+ testpassword plain-badpassword plain.txt xxx plaintext
+ testpassword cipher cipher.bin password ciphertext
+ testpassword cipher-nopassword cipher.bin {} "decryption failed" -returnCodes error
+ testpassword cipher-badpassword cipher.bin xxx "decryption failed" -returnCodes error -constraints bug-b3c7429255
+ testpassword cipher-deflate cipher-deflate.bin password [lseq 100]
+ testpassword cipher-deflate-nopassword cipher-deflate.bin {} "decryption failed" -returnCodes error
+ testpassword cipher-deflate-badpassword cipher-deflate.bin xxx "decryption failed" -returnCodes error bug-b3c7429255
+
+
#
# file stat
proc fixupstat {stat} {
@@ -992,14 +1024,14 @@ namespace eval test_ns_zipfs {
test zipfs-file-stat-root-subdir-mount "Read stat of root when mount is subdir" -setup {
mount [zippath test.zip]
- } -cleanup cleanup -constraints knownBug -body {
+ } -cleanup cleanup -constraints bug-02acab5aea -body {
lsort -stride 2 [file stat [zipfs root]]
} -result [fixupstat {atime 0 ctime 0 dev 0 gid 0 ino 0 mode 16749 mtime 0 nlink 0 size 0 type directory uid 0}]
#
# TODO - glob of zipfs file
- # TODO tests for compress and save
+ # TODO tests for compress and save, + with password
#
# TODO - file copy, file rename etc.