summaryrefslogtreecommitdiff
path: root/tests/basic
blob: ff897d211073e4a72452e2dfe9f0ed319828e655 (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 ./admin:
  12. gpgadmin() {
  13. GNUPGHOME=./admin gpg "$@"
  14. }
  15. # cleanup:
  16. cleanup() {
  17. # FIXME: stop the sshd process
  18. rm -f "$SOCKET"
  19. # FIXME: how should we clear out the temporary $VARLIB?
  20. # FIXME: clear out ssh client config file and known hosts.
  21. }
  22. ## set up some variables to ensure that we're operating strictly in
  23. ## the tests, not system-wide:
  24. TESTDIR=$(pwd)
  25. export MONKEYSPHERE_SYSDATADIR="$TESTDIR"/var
  26. export MONKEYSPHERE_SYSCONFIGDIR="$TESTDIR"/etc
  27. export SOCKET="$TESTDIR"/ssh-socket
  28. ### SERVER TESTS
  29. # Use the local copy of executables first, instead of system ones.
  30. # This should help us test without installing.
  31. export PATH="$TESTDIR"/../src:"$TESTDIR"/../src/keytrans:"$PATH"
  32. export MONKEYSPHERE_SHARE="$TESTDIR"/../src
  33. # create a new host key
  34. echo | monkeysphere-server gen-key --expire 2d
  35. HOSTKEYID=$( monkeysphere-server show-key | tail -n1 | cut -f3 -d\ )
  36. # certify it with the "Admin's Key".
  37. # (this would normally be done via keyservers)
  38. monkeysphere-server gpg-authentication-cmd "--armor --export $HOSTKEYID" | gpgadmin --import
  39. gpgadmin --sign-key "$HOSTKEYID"
  40. # FIXME: how can we test publish-key without flooding junk into the
  41. # keyservers?
  42. # indicate that the "Admin's" key is an identity certifier for the
  43. # host
  44. monkeysphere-server add-identity-certifier ./home/admin/.gnupg/pubkey.gpg
  45. # write the sshd_config
  46. cat <<EOF > "$TESTDIR"/etc/ssh/sshd_config
  47. HostKey ${TESTDIR}/etc/ssh/ssh_host_rsa_key
  48. EOF
  49. # launch sshd with the new host key.
  50. mkfifo "$SOCKET"
  51. /usr/sbin/sshd -f "$TESTDIR"/etc/ssh/sshd_config -i <>"$SOCKET"
  52. ### TESTUSER TESTS
  53. # connect to sample sshd host key, using monkeysphere to verify the
  54. # identity before connection.
  55. ## FIXME: implement!
  56. # create a new client side key, certify it with the "CA", use it to
  57. # log in.
  58. ## FIXME: implement!