+# generate an auth subkey for the test user that expires in 2 days
+echo "##################################################"
+echo "### generating key for testuser..."
+monkeysphere gen-subkey --expire 2
+
+# add server key to testuser keychain
+echo "##################################################"
+echo "### export server key to testuser..."
+gpgadmin --armor --export "$HOSTKEYID" | gpg --import
+
+# teach the "server" about the testuser's key
+echo "##################################################"
+echo "### export testuser key to server..."
+gpg --export testuser | monkeysphere-authentication gpg-cmd --import
+
+# update authorized_keys for user
+echo "##################################################"
+echo "### update server authorized_keys file for this testuser..."
+monkeysphere-authentication update-users $(whoami)
+
+
+### TESTS
+
+# connect to test sshd, using monkeysphere-ssh-proxycommand to verify
+# the identity before connection. This should work in both directions!
+echo "##################################################"
+echo "### ssh connection test for success..."
+ssh_test
+
+# remove the testuser's authorized_user_ids file, update, and make
+# sure that the ssh authentication FAILS
+echo "##################################################"
+echo "### removing testuser authorized_user_ids and updating..."
+mv "$TESTHOME"/.monkeysphere/authorized_user_ids{,.bak}
+monkeysphere-authentication update-users $(whoami)
+echo "##################################################"
+echo "### ssh connection test for server authentication denial..."
+ssh_test 255
+mv "$TESTHOME"/.monkeysphere/authorized_user_ids{.bak,}
+
+# put improper permissions on authorized_user_ids file, update, and
+# make sure ssh authentication FAILS
+echo "##################################################"
+echo "### setting group writability on authorized_user_ids and updating..."
+chmod g+w "$TESTHOME"/.monkeysphere/authorized_user_ids
+monkeysphere-authentication update-users $(whoami)
+echo "##################################################"
+echo "### ssh connection test for server authentication denial..."
+ssh_test 255
+chmod g-w "$TESTHOME"/.monkeysphere/authorized_user_ids
+echo "##################################################"
+echo "### setting other writability on authorized_user_ids and updating..."
+chmod o+w "$TESTHOME"/.monkeysphere/authorized_user_ids
+monkeysphere-authentication update-users $(whoami)
+echo "##################################################"
+echo "### ssh connection test for server authentication denial..."
+ssh_test 255
+chmod o-w "$TESTHOME"/.monkeysphere/authorized_user_ids
+
+# FIXME: addtest: remove admin as id-certifier and check ssh failure
+
+# FIXME: addtest: revoke hostname on host key and check ssh failure
+
+# FIXME: addtest: revoke the host key and check ssh failure
+
+trap - EXIT
+
+echo "##################################################"
+echo " Monkeysphere basic tests completed successfully!"
+echo "##################################################"
+
+cleanup