[pass] [PATCH 3/3] Added test for mounting and unmounting ramdisks on Mac

Caleb Marble cm at marblenix.com
Mon Jun 2 02:47:17 CEST 2014


---
 tests/t0600-darwin-test-diskutil.sh |   48 +++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100755 tests/t0600-darwin-test-diskutil.sh

diff --git a/tests/t0600-darwin-test-diskutil.sh b/tests/t0600-darwin-test-diskutil.sh
new file mode 100755
index 0000000..9c82e19
--- /dev/null
+++ b/tests/t0600-darwin-test-diskutil.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+
+test_description='Test Mounting and Unmounting'
+cd "$(dirname "$0")"
+. ./setup.sh
+
+if [[ "$(uname)" != "Darwin" ]]; then
+  echo "Not on Mac, do not test."
+  test_done
+fi
+
+INITIAL_PASSWORD="Two Things Are Infinite: the Universe, and the Need for Tests"
+
+mounted_disks() {
+  diskutil list -plist | grep --only '>disk.*<' | awk -F'[><]' '{print $2}' | sort -u
+}
+
+test_expect_success 'Setup initial key and git' '
+	"$PASS" init $KEY1 && "$PASS" git init
+'
+
+initial_disk_env=($(mounted_disks))
+
+# These two tests are copied from test-0100 and test-0200
+# The point is to create a situation where mounting a /dev/diskX is required.
+test_expect_success 'Test "insert" command' '
+  "$PASS" init $KEY1 &&
+  echo "Hello world" | "$PASS" insert -e cred1 &&
+  [[ $("$PASS" show cred1) == "Hello world" ]]
+'
+
+test_expect_success 'Test "edit" command' '
+  "$PASS" init $KEY1 &&
+  "$PASS" generate cred1 90 &&
+  export FAKE_EDITOR_PASSWORD="big fat fake password" &&
+  export EDITOR="$TEST_HOME/fake-editor-change-password.sh" &&
+  "$PASS" edit cred1 &&
+  [[ $("$PASS" show cred1) == "$FAKE_EDITOR_PASSWORD" ]]
+'
+
+end_disk_env=($(mounted_disks))
+
+# Simply test if the number of mounted disks is the same as when we began.
+test_expect_success 'Ensure diskutil does not retain our mounted ramdisk' '
+  [[ ${#initial_disk_env[@]} == ${#end_disk_env[@]} ]]
+'
+
+test_done
-- 
1.7.10.4



More information about the Password-Store mailing list