3 # Tests to ensure that the monkeysphere is working
5 # Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
6 # Date: 2008-09-13 13:40:15-0400
8 # these tests might be best run under fakeroot, particularly the
9 # "server-side" tests. Using fakeroot, they should be able to be run
10 # as a non-privileged user.
12 # NOTE: these tests have *not* themselves been tested yet
13 # (2008-09-13). Please exercise with caution!
15 # these tests assume a commonly-trusted "Admin's key", a fake key
16 # permanently stored in ./home/admin/.gnupg:
18 GNUPGHOME="$TESTDIR"/home/admin/.gnupg gpg "$@"
24 # FIXME: stop the sshd process
27 echo "-- removing temp dir..."
30 # FIXME: how should we clear out the temporary $VARLIB?
32 # FIXME: clear out ssh client config file and known hosts.
38 ## set up some variables to ensure that we're operating strictly in
39 ## the tests, not system-wide:
44 TEMPDIR="$TESTDIR"/tmp
47 # Use the local copy of executables first, instead of system ones.
48 # This should help us test without installing.
49 export PATH="$TESTDIR"/../src:"$TESTDIR"/../src/keytrans:"$PATH"
51 export MONKEYSPHERE_SYSDATADIR="$TEMPDIR"
52 export MONKEYSPHERE_SYSCONFIGDIR="$TEMPDIR"
53 export MONKEYSPHERE_SYSSHAREDIR="$TESTDIR"/../src
54 export MONKEYSPHERE_MONKEYSPHERE_USER="$USER"
55 export SOCKET="$TEMPDIR"/ssh-socket
59 # create the temp gnupghome directories
60 mkdir -p -m 750 "$MONKEYSPHERE_SYSDATADIR"/gnupg-host
61 mkdir -p -m 700 "$MONKEYSPHERE_SYSDATADIR"/gnupg-authentication
63 # create a new host key
64 echo "-- generating server key..."
65 echo | monkeysphere-server gen-key --length 1024 --expire 0
67 HOSTKEYID=$( monkeysphere-server show-key | tail -n1 | cut -f3 -d\ )
69 # certify it with the "Admin's Key".
70 # (this would normally be done via keyservers)
71 echo "-- certifying server key..."
72 monkeysphere-server gpg-authentication-cmd "--armor --export $HOSTKEYID" | gpgadmin --import
73 gpgadmin --sign-key "$HOSTKEYID"
75 # FIXME: how can we test publish-key without flooding junk into the
78 # indicate that the "Admin's" key is an identity certifier for the
81 echo "-- adding admin as certifier..."
82 monkeysphere-server add-identity-certifier "$TESTDIR"/home/admin/.gnupg/pubkey.gpg
84 # initialize base sshd_config
85 cp etc/ssh/sshd_config "$TEMPDIR"/sshd_config
86 # write the sshd_config
87 cat <<EOF >> "$TEMPDIR"/sshd_config
88 HostKey ${MONKEYSPHERE_SYSDATADIR}/ssh_host_rsa_key
89 AuthorizedKeysFile ${MONKEYSPHERE_SYSDATADIR}/authorized_keys/%u
92 # launch sshd with the new host key.
93 echo "-- starting sshd..."
94 socat EXEC:'/usr/sbin/sshd -f '"$TEMPDIR"/sshd_config' -i -d -d -d -D -e' "UNIX-LISTEN:${TEMPDIR/socket}" &
99 # copy testuser home directory into temp dir
100 cp -r "$TESTDIR"/home/testuser "$TEMPDIR"/
102 # generate an auth subkey for the test user
103 echo "-- generating key for testuser..."
104 MONKEYSPHERE_GNUPGHOME="$TEMPDIR"/testuser/.gnupg \
105 monkeysphere gen-subkey --expire 0
107 # connect to sample sshd host key, using monkeysphere to verify the
108 # identity before connection.
112 # create a new client side key, certify it with the "CA", use it to