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 export TESTDIR=$(dirname "$0")
22 source "$TESTDIR"/common
25 trap failed_cleanup EXIT
27 ######################################################################
30 ## set up some variables to ensure that we're operating strictly in
31 ## the tests, not system-wide:
34 TEMPDIR="$TESTDIR"/tmp
35 if [ -e "$TEMPDIR" ] ; then
36 echo "tempdir '$TEMPDIR' already exists."
41 # Use the local copy of executables first, instead of system ones.
42 # This should help us test without installing.
43 export PATH="$TESTDIR"/../src/keytrans:"$PATH"
45 ######################################################################
48 echo "##################################################"
49 echo "### generating openpgp key..."
50 export GNUPGHOME="$TEMPDIR"
53 gpg --batch --$(get_gpg_prng_arg) --gen-key <<EOF
64 echo "##################################################"
65 echo "### retrieving key timestamp..."
66 timestamp=$(gpg --list-key --with-colons --fixed-list-mode | \
67 grep ^pub: | cut -d: -f6)
69 echo "##################################################"
70 echo "### exporting key to ssh file..."
71 gpg --export-secret-key | openpgp2ssh > \
74 echo "##################################################"
75 echo "### reconvert key, and compare to key in gpg keyring..."
77 <(gpg --export-secret-key | hd) \
78 <(PEM2OPENPGP_USAGE_FLAGS=sign,certify \
79 PEM2OPENPGP_TIMESTAMP="$timestamp" pem2openpgp testtest < \
80 "$TEMPDIR"/test.pem | hd )