3 # Tests to ensure that the monkeysphere is working
6 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
7 # Jameson Rollins <jrollins@fifthhorseman.net>
8 # Micah Anderson <micah@riseup.net>
10 # Copyright: 2008-2009
11 # License: GPL v3 or later
13 # these tests should all be able to run as a non-privileged user.
15 # all subcommands in this script should complete without failure:
17 # piped commands should return the code of the first non-zero return
20 # make sure the TESTDIR is an absolute path, not a relative one.
21 export TESTDIR=$(cd $(dirname "$0") && pwd)
23 source "$TESTDIR"/common
26 trap failed_cleanup EXIT
28 ######################################################################
31 ## set up some variables to ensure that we're operating strictly in
32 ## the tests, not system-wide:
34 mkdir -p "$TESTDIR"/tmp
35 TEMPDIR=$(mktemp -d "${TMPDIR:-$TESTDIR/tmp}/monkeyspheretest.XXXXXXX")
38 ln -s "$TESTDIR"/../src/share/keytrans "$TEMPDIR"/bin/openpgp2ssh
39 ln -s "$TESTDIR"/../src/share/keytrans "$TEMPDIR"/bin/pem2openpgp
41 # Use the local copy of executables first, instead of system ones.
42 # This should help us test without installing.
43 export PATH="$TEMPDIR"/bin:"$PATH"
45 ######################################################################
48 echo "##################################################"
49 echo "### generating openpgp key..."
50 export GNUPGHOME="$TEMPDIR"
54 # create the key with the same preferences that monkeysphere uses.
55 cat > "$TEMPDIR"/gpg.conf <<EOF
56 default-preference-list SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1 ZLIB BZIP2 ZIP AES256 AES192 AES CAST5 3DES
57 cert-digest-algo SHA256
61 gpg --batch --$(get_gpg_prng_arg) --gen-key <<EOF
72 echo "##################################################"
73 echo "### retrieving key timestamp..."
74 timestamp=$(gpg --list-key --with-colons --fixed-list-mode | \
75 grep ^pub: | cut -d: -f6)
77 echo "##################################################"
78 echo "### exporting key to ssh file..."
79 gpg --export-secret-key | openpgp2ssh > \
82 gpg --export-secret-key > "$TEMPDIR"/secret.key
84 PEM2OPENPGP_USAGE_FLAGS=sign,certify \
85 PEM2OPENPGP_TIMESTAMP="$timestamp" pem2openpgp testtest \
86 < "$TEMPDIR"/test.pem > "$TEMPDIR"/converted.secret.key
88 echo "##################################################"
89 echo "### reconvert key, and compare to key in gpg keyring..."
91 <(gpg --list-packets < "$TEMPDIR"/secret.key) \
92 <(gpg --list-packets < "$TEMPDIR"/converted.secret.key)
95 <(hd "$TEMPDIR"/secret.key) \
96 <(hd "$TEMPDIR"/converted.secret.key)
100 echo "##################################################"
101 echo " Monkeysphere keytrans test completed successfully!"
102 echo "##################################################"