+echo "##################################################"
+echo "### make .monkeysphere directory an absolute symlink and updating..."
+mv "$TESTHOME"/.monkeysphere{,.bak}
+ln -s "$TESTHOME"/.monkeysphere{.linktest,}
+monkeysphere-authentication update-users $(whoami)
+echo
+echo "##################################################"
+echo "### ssh connection test for success..."
+ssh_test
+echo
+echo "##################################################"
+echo "### create bad permissions on link dir and updating..."
+chmod o+w "$TESTHOME"/.monkeysphere.linktest
+monkeysphere-authentication update-users $(whoami)
+echo
+echo "##################################################"
+echo "### ssh connection test for failure..."
+ssh_good_perm_test 255
+chmod o-w "$TESTHOME"/.monkeysphere.linktest
+echo
+echo "##################################################"
+echo "### make .monkeysphere directory a relative symlink and updating..."
+ln -sfn .monkeysphere.linktest "$TESTHOME"/.monkeysphere
+monkeysphere-authentication update-users $(whoami)
+echo
+echo "##################################################"
+echo "### ssh connection test for success..."
+ssh_test
+echo
+echo "##################################################"
+echo "### create bad permissions on link dir updating..."
+chmod o+w "$TESTHOME"/.monkeysphere.linktest
+monkeysphere-authentication update-users $(whoami)
+echo
+echo "##################################################"
+echo "### ssh connection test for failure..."
+ssh_good_perm_test 255
+chmod o-w "$TESTHOME"/.monkeysphere.linktest
+rm "$TESTHOME"/.monkeysphere
+mv "$TESTHOME"/.monkeysphere{.bak,}
+
+# ensure we're back to normal:
+echo
+echo "##################################################"
+echo "### making sure we are back to normal..."
+monkeysphere-authentication update-users $(whoami)
+ssh_test
+
+
+echo
+echo "##################################################"
+echo "### ssh connection test directly to 'testhost2' without new name..."
+target_hostname=testhost2 ssh_test 255
+echo
+echo "##################################################"
+echo "### add hostname, certify by admin, import by user..."
+monkeysphere-host add-hostname testhost2
+< "$MONKEYSPHERE_SYSCONFIGDIR"/ssh_host_rsa_key.pub.gpg gpgadmin --import
+printf "y\ny\n" | gpgadmin --command-fd 0 --sign-key "$HOSTKEYID"
+
+echo
+echo "##################################################"
+echo "### ssh connection test with hostname 'testhost2' added..."
+gpgadmin --export "$HOSTKEYID" | gpg --import
+gpg --check-trustdb
+ssh_test
+
+echo
+echo "##################################################"
+echo "### ssh connection test directly to 'testhost2' ..."
+gpg --import <"$MONKEYSPHERE_SYSCONFIGDIR"/ssh_host_rsa_key.pub.gpg
+gpg --check-trustdb
+target_hostname=testhost2 ssh_test
+
+echo
+echo "##################################################"
+echo "### ssh connection test for failure with 'testhost2' revoked..."
+monkeysphere-host revoke-hostname testhost2
+gpg --import <"$MONKEYSPHERE_SYSCONFIGDIR"/ssh_host_rsa_key.pub.gpg
+gpg --check-trustdb
+target_hostname=testhost2 ssh_test 255
+
+# FIXME: addtest: remove admin as id-certifier and check ssh failure
+
+# FIXME: addtest: how do we test that set-expire makes sense after new
+# hostnames have been added?
+
+# FIXME: addtest: revoke the host key and check ssh failure
+
+# test to make sure things are OK after the previous tests:
+echo
+echo "##################################################"
+echo "### settings reset, updating..."
+monkeysphere-authentication update-users $(whoami)
+echo
+echo "##################################################"
+echo "### ssh connection test for success..."
+ssh_test
+
+echo
+echo "##################################################"
+echo "### revoking host key..."
+# generate the revocation certificate and feed it directly to the test
+# user's keyring (we're not publishing to the keyservers)
+monkeysphere-host revoke-key | gpg --import
+echo
+echo "##################################################"
+echo "### ssh connection test for failure..."
+ssh_test 255
+
+
+######################################################################
+
+trap - EXIT
+