summaryrefslogtreecommitdiff
path: root/tests/basic
blob: 4daaf298c50de050f4d83ece248198215cada59e (plain)
  1. #!/usr/bin/env bash
  2. # Tests to ensure that the monkeysphere is working
  3. # Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
  4. # Date: 2008-09-13 13:40:15-0400
  5. # these tests might be best run under fakeroot, particularly the
  6. # "server-side" tests. Using fakeroot, they should be able to be run
  7. # as a non-privileged user.
  8. # NOTE: these tests have *not* themselves been tested yet
  9. # (2008-09-13). Please exercise with caution!
  10. # these tests assume a commonly-trusted "Admin's key", a fake key
  11. # permanently stored in ./home/admin/.gnupg:
  12. gpgadmin() {
  13. GNUPGHOME="$TESTDIR"/home/admin/.gnupg gpg "$@"
  14. }
  15. # cleanup:
  16. cleanup() {
  17. # FIXME: stop the sshd process
  18. echo
  19. echo "-- removing temp dir..."
  20. rm -rf "$TEMPDIR"
  21. # FIXME: how should we clear out the temporary $VARLIB?
  22. # FIXME: clear out ssh client config file and known hosts.
  23. }
  24. ## setup trap
  25. #trap cleanup EXIT
  26. ## set up some variables to ensure that we're operating strictly in
  27. ## the tests, not system-wide:
  28. export TESTDIR=$(pwd)
  29. # make temp dir
  30. TEMPDIR="$TESTDIR"/tmp
  31. mkdir "$TEMPDIR"
  32. # Use the local copy of executables first, instead of system ones.
  33. # This should help us test without installing.
  34. export PATH="$TESTDIR"/../src:"$TESTDIR"/../src/keytrans:"$PATH"
  35. export MONKEYSPHERE_SYSDATADIR="$TEMPDIR"
  36. export MONKEYSPHERE_SYSCONFIGDIR="$TEMPDIR"
  37. export MONKEYSPHERE_SYSSHAREDIR="$TESTDIR"/../src
  38. export MONKEYSPHERE_MONKEYSPHERE_USER="$USER"
  39. export SOCKET="$TEMPDIR"/ssh-socket
  40. ### SERVER TESTS
  41. # create the temp gnupghome directories
  42. mkdir -p -m 750 "$MONKEYSPHERE_SYSDATADIR"/gnupg-host
  43. mkdir -p -m 700 "$MONKEYSPHERE_SYSDATADIR"/gnupg-authentication
  44. # create a new host key
  45. echo "-- generating server key..."
  46. echo | monkeysphere-server gen-key --length 1024 --expire 0
  47. HOSTKEYID=$( monkeysphere-server show-key | tail -n1 | cut -f3 -d\ )
  48. # certify it with the "Admin's Key".
  49. # (this would normally be done via keyservers)
  50. echo "-- certifying server key..."
  51. monkeysphere-server gpg-authentication-cmd "--armor --export $HOSTKEYID" | gpgadmin --import
  52. gpgadmin --sign-key "$HOSTKEYID"
  53. # FIXME: how can we test publish-key without flooding junk into the
  54. # keyservers?
  55. # indicate that the "Admin's" key is an identity certifier for the
  56. # host
  57. echo "-- adding admin as certifier..."
  58. monkeysphere-server add-identity-certifier "$TESTDIR"/home/admin/.gnupg/pubkey.gpg
  59. # write the sshd_config
  60. cat <<EOF > "$TEMPDIR"/sshd_config
  61. HostKey ${MONKEYSPHERE_SYSDATADIR}/ssh_host_rsa_key
  62. EOF
  63. # launch sshd with the new host key.
  64. echo "-- starting sshd..."
  65. mkfifo "$SOCKET"
  66. /usr/sbin/sshd -f "$TEMPDIR"/sshd_config -i <>"$SOCKET"
  67. ### TESTUSER TESTS
  68. # copy testuser home directory into temp dir
  69. cp -r "$TESTDIR"/home/testuser "$TEMPDIR"/
  70. # generate an auth subkey for the test user
  71. echo "-- generating key for testuser..."
  72. MONKEYSPHERE_GNUPGHOME="$TEMPDIR"/testuser/.gnupg \
  73. monkeysphere gen-subkey --expire 0
  74. # connect to sample sshd host key, using monkeysphere to verify the
  75. # identity before connection.
  76. ## FIXME: implement!
  77. # create a new client side key, certify it with the "CA", use it to
  78. # log in.
  79. ## FIXME: implement!