summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Pujol <alexandre@pujol.io>2017-05-03 18:51:36 (GMT)
committer Alexandre Pujol <alexandre@pujol.io>2017-05-03 18:51:36 (GMT)
commit593747d61915327f69336ea72a6a1c5060962ad5 (patch)
treea0128c6c21888e4520915cecc2d8e5b42ae56917
parent4688820b68a2f098e72b1cfe26eebb7391a6b91c (diff)
Add bind hooks tests and minors test setup changes
-rw-r--r--extras/test/50_integrity.sh2
-rw-r--r--extras/test/75_hooks.sh25
-rw-r--r--extras/test/setup5
3 files changed, 29 insertions, 3 deletions
diff --git a/extras/test/50_integrity.sh b/extras/test/50_integrity.sh
index 753db6a..4e926d1 100644
--- a/extras/test/50_integrity.sh
+++ b/extras/test/50_integrity.sh
@@ -7,7 +7,7 @@ source ./setup
test_export "test" # Using already generated tomb
test_expect_success 'Testing contents integrity' '
tt_open --tomb-pwd $DUMMYPASS &&
- tomb_set_ownership "$MEDIA/$testname" &&
+ tt_set_ownership "$MEDIA/$testname" &&
tt dig -s 10 "$MEDIA/$testname/datacheck.raw" &&
CRC1=$(sha256sum "$MEDIA/$testname/datacheck.raw") &&
tt_close --unsafe &&
diff --git a/extras/test/75_hooks.sh b/extras/test/75_hooks.sh
new file mode 100644
index 0000000..d263934
--- /dev/null
+++ b/extras/test/75_hooks.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env zsh
+
+export test_description="Testing tomb bind hooks"
+
+source ./setup
+
+test_export "test" # Using already generated tomb
+test_expect_success 'Testing bind hooks' '
+ tt_open --tomb-pwd $DUMMYPASS &&
+ tt_set_ownership "$MEDIA/$testname" &&
+ RND="$RANDOM" &&
+ bindtest="dyne-tomb-bind-test-$RND" &&
+ echo "$RND" > "$MEDIA/$testname/$bindtest" &&
+ rm -f "$MEDIA/$testname/bind-hooks" &&
+ echo "$bindtest $bindtest" > "$MEDIA/$testname/bind-hooks" &&
+ tt_close &&
+ touch "/home/$USER/$bindtest" &&
+ tt_open --tomb-pwd $DUMMYPASS &&
+ RND2=$(cat "/home/$USER/$bindtest") &&
+ [[ "$RND" = "$RND2" ]] &&
+ tt list $testname &&
+ tt_close
+ '
+
+test_done
diff --git a/extras/test/setup b/extras/test/setup
index 06e5447..bdc3ecb 100644
--- a/extras/test/setup
+++ b/extras/test/setup
@@ -44,7 +44,7 @@ if [[ ! -e "${T}" ]]; then
fi
MEDIA="/media"
-[[ -d /media ]] || MEDIA="/run/media/$USER/"
+[[ -d "/media" ]] || MEDIA="/run/media/$USER"
# Check for auxiliary programs
command -v steghide > /dev/null && test_set_prereq STEGHIDE
@@ -71,6 +71,7 @@ export DUMMYPASSNEW=changetest
test_cleanup() {
"${T}" slam all &> /dev/null
+ rm -f "/home/$USER/dyne-tomb-bind-test-"*
sudo rm -rf "$TMP"
mkdir -p "$TMP"
}
@@ -106,7 +107,7 @@ tt_lock() { tt lock "$tomb" -k "$tomb_key" --ignore-swap --unsafe "${@}"; }
tt_open() { tt open "$tomb" -k "$tomb_key" --ignore-swap --unsafe "${@}"; }
tt_close() { tt close "$testname" "${@}"; }
-tomb_set_ownership() {
+tt_set_ownership() {
local dir="$1"
local uid=$(id -u $USERNAME)
local gid=$(id -g $USERNAME)