summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Pujol <alexandre@pujol.io>2017-05-01 22:02:49 (GMT)
committer Alexandre Pujol <alexandre@pujol.io>2017-05-01 22:02:49 (GMT)
commit92a670efd88ab2100b1e842cd315f123e5e41877 (patch)
tree76ba29fdc00afdaf1069a9596f4285d95ef24cd9
parent045c55436f03bc5de31bc3fc38a5417bcc672dc7 (diff)
Add integrity tests
-rw-r--r--extras/test/50_integrity.sh20
-rw-r--r--extras/test/setup8
2 files changed, 28 insertions, 0 deletions
diff --git a/extras/test/50_integrity.sh b/extras/test/50_integrity.sh
new file mode 100644
index 0000000..f97cd17
--- /dev/null
+++ b/extras/test/50_integrity.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env zsh
+
+export test_description="Testing file integrity"
+
+source ./setup
+
+test_export "test" # Using already generated tomb
+test_expect_success 'Testing contents integrity' '
+ tt_open --tomb-pwd $DUMMYPASS &&
+ tomb_set_ownership "$MEDIA/$USER/$testname" &&
+ tt dig -s 10 "$MEDIA/$USER/$testname/datacheck.raw" &&
+ CRC1=$(sha256sum "$MEDIA/$USER/$testname/datacheck.raw") &&
+ tt_close --unsafe &&
+ tt_open --tomb-pwd $DUMMYPASS &&
+ CRC2=$(sha256sum "$MEDIA/$USER/$testname/datacheck.raw") &&
+ [[ "$CRC1" == "$CRC2" ]] &&
+ tt_close
+ '
+
+test_done
diff --git a/extras/test/setup b/extras/test/setup
index 32fa76d..782b572 100644
--- a/extras/test/setup
+++ b/extras/test/setup
@@ -103,3 +103,11 @@ tt_forge() { tt forge "$tomb_key" --ignore-swap --unsafe --use-urandom "${@}"; }
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() {
+ local dir="$1"
+ local uid=$(id -u $USERNAME)
+ local gid=$(id -g $USERNAME)
+ sudo chown -R "$uid:$gid" "$dir"
+ sudo chmod 0711 "$dir"
+}