Skip to content

Commit

Permalink
test: safe working dir chmod
Browse files Browse the repository at this point in the history
  • Loading branch information
mle86 committed Jan 17, 2020
1 parent 839e75f commit 6756218
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/09-test-dirmode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
. $(dirname "$0")/init.sh

# This test script checks if walk applies correct modes to the unpacked working directory.

walk_input='n\ny\n' # don't recreate archive, but delete temp dir

assertUnpackedDirmode () {
local inputArchiveMode="$1"
local expectedDirectoryMode="$2"

cp -- "$HERE/archives/test.tgz" "mode-$inputArchiveMode.tgz"
add_cleanup "mode-$inputArchiveMode.tgz"
chmod -- "$inputArchiveMode" "mode-$inputArchiveMode.tgz"

prepare_subshell <<-EOT
assertFileMode . "${expectedDirectoryMode#"0"}" \
"Unpacked working directory had incorrect mode! (Archive mode: $inputArchiveMode)"
EOT

printf "$walk_input" | "$WALK" "mode-$inputArchiveMode.tgz" >/dev/null # !
}


cd_tmpdir

assertUnpackedDirmode 0400 0700
assertUnpackedDirmode 0600 0700
assertUnpackedDirmode 0700 0700 # An executable .tgz doesn't make a lot of sense, but it shouldn't break the process either!
assertUnpackedDirmode 0640 0750
assertUnpackedDirmode 0644 0755
assertUnpackedDirmode 0755 0755
assertUnpackedDirmode 0666 0777


success
Binary file added test/archives/test.tgz
Binary file not shown.

0 comments on commit 6756218

Please sign in to comment.