]> gitweb.michael.orlitzky.com - apply-default-acl.git/blobdiff - run-tests.sh
Add a 'test' makefile target.
[apply-default-acl.git] / run-tests.sh
index 7f6838f66d5e7d1036aa73098cd4b30ba7cb8c31..75414cab82878d2209d1d6214bdd99386673a0d2 100755 (executable)
@@ -9,12 +9,13 @@ TESTDIR=test
 acl_reset() {
     # Remove any ACLs on our test directory and remove its contents.
     setfacl --remove-all --recursive "$TESTDIR"
-    rm "${TESTDIR}"/*
+    rm -rf "${TESTDIR}"/*
 }
 
 compare() {
     if [[ "${ACTUAL}" == "${EXPECTED}" ]]; then
        echo "Success."
+       acl_reset
     else
        echo "Failure."
        echo "Expected result:"
@@ -32,19 +33,39 @@ mkdir "${TESTDIR}"
 
 # When using a minimal ACL, the default user, group, and other
 # permissions should all be propagated to the mode bits.
-
 TARGET="${TESTDIR}"/foo
-touch "${TARGET}"
-chmod 777 "${TARGET}"
-setfacl -d -m user::r-- "${TESTDIR}"
+setfacl -d -m user::r--  "${TESTDIR}"
 setfacl -d -m group::r-- "${TESTDIR}"
 setfacl -d -m other::r-- "${TESTDIR}"
+touch "${TARGET}"
+chmod 777 "${TARGET}"
+./aclq "${TARGET}"
+
+EXPECTED=$(cat <<EOF
+user::r--
+group::r--
+other::r--
 
+EOF
+)
+
+ACTUAL=`getfacl --omit-header "${TARGET}"`
+compare
+
+# Do the same thing as the last test, except with an extended ACL.
+setfacl -d -m user::r--     "${TESTDIR}"
+setfacl -d -m group::r--    "${TESTDIR}"
+setfacl -d -m other::r--    "${TESTDIR}"
+setfacl -d -m user:mail:rwx "${TESTDIR}"
+touch "${TARGET}"
+chmod 777 "${TARGET}"
 ./aclq "${TARGET}"
 
 EXPECTED=$(cat <<EOF
 user::r--
+user:mail:rwx
 group::r--
+mask::rwx
 other::r--
 
 EOF
@@ -52,3 +73,46 @@ EOF
 
 ACTUAL=`getfacl --omit-header "${TARGET}"`
 compare
+
+# A directory shared by a group, should still be group-writable
+# afterwards.
+setfacl -d -m group:mail:rwx "${TESTDIR}"
+touch "${TARGET}"
+chmod 644 "${TARGET}"
+./aclq "${TARGET}"
+
+EXPECTED=$(cat <<EOF
+user::rw-
+group::r--
+group:mail:rwx #effective:rw-
+mask::rw-
+other::r--
+EOF
+)
+
+ACTUAL=`getfacl --omit-header "${TARGET}"`
+compare
+
+# Same test as before except with a directory.
+setfacl -d -m group:mail:rwx "${TESTDIR}"
+mkdir "${TARGET}"
+chmod 755 "${TARGET}"
+./aclq "${TARGET}"
+
+EXPECTED=$(cat <<EOF
+user::rwx
+group::r-x
+group:mail:rwx
+mask::rwx
+other::r-x
+default:user::rwx
+default:group::r-x
+default:group:mail:rwx
+default:mask::rwx
+default:other::r-x
+
+EOF
+)
+
+ACTUAL=`getfacl --omit-header "${TARGET}"`
+compare