ff897d211073e4a72452e2dfe9f0ed319828e655
[monkeysphere.git] / tests / basic
1 #!/usr/bin/env bash
2
3 # Tests to ensure that the monkeysphere is working
4
5 # Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
6 # Date: 2008-09-13 13:40:15-0400
7
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.
11
12 # NOTE: these tests have *not* themselves been tested yet
13 # (2008-09-13).  Please exercise with caution!
14
15 # these tests assume a commonly-trusted "Admin's key", a fake key
16 # permanently stored in ./admin:
17
18 gpgadmin() {
19     GNUPGHOME=./admin gpg "$@"
20 }
21
22
23 # cleanup:
24
25 cleanup() {
26     # FIXME: stop the sshd process
27
28     rm -f "$SOCKET"
29
30     # FIXME: how should we clear out the temporary $VARLIB?
31
32     # FIXME: clear out ssh client config file and known hosts.
33 }
34
35 ## set up some variables to ensure that we're operating strictly in
36 ## the tests, not system-wide:
37
38 TESTDIR=$(pwd)
39 export MONKEYSPHERE_SYSDATADIR="$TESTDIR"/var
40 export MONKEYSPHERE_SYSCONFIGDIR="$TESTDIR"/etc
41 export SOCKET="$TESTDIR"/ssh-socket
42
43 ### SERVER TESTS
44
45 # Use the local copy of executables first, instead of system ones.
46 # This should help us test without installing.
47 export PATH="$TESTDIR"/../src:"$TESTDIR"/../src/keytrans:"$PATH"
48 export MONKEYSPHERE_SHARE="$TESTDIR"/../src
49
50 # create a new host key
51
52 echo | monkeysphere-server gen-key --expire 2d
53
54 HOSTKEYID=$( monkeysphere-server show-key | tail -n1 | cut -f3 -d\  )
55
56 # certify it with the "Admin's Key".
57 # (this would normally be done via keyservers)
58 monkeysphere-server gpg-authentication-cmd "--armor --export $HOSTKEYID" | gpgadmin --import
59
60 gpgadmin --sign-key "$HOSTKEYID"
61
62 # FIXME: how can we test publish-key without flooding junk into the
63 # keyservers?
64
65 # indicate that the "Admin's" key is an identity certifier for the
66 # host
67
68 monkeysphere-server add-identity-certifier ./home/admin/.gnupg/pubkey.gpg
69
70 # write the sshd_config
71 cat <<EOF > "$TESTDIR"/etc/ssh/sshd_config
72 HostKey ${TESTDIR}/etc/ssh/ssh_host_rsa_key
73 EOF
74
75 # launch sshd with the new host key.
76
77 mkfifo "$SOCKET"
78
79 /usr/sbin/sshd -f "$TESTDIR"/etc/ssh/sshd_config -i <>"$SOCKET"
80
81
82
83 ### TESTUSER TESTS
84
85 # connect to sample sshd host key, using monkeysphere to verify the
86 # identity before connection.
87
88 ## FIXME: implement!
89
90 # create a new client side key, certify it with the "CA", use it to
91 # log in.
92
93 ## FIXME: implement!
94