all: .depend $(PROGS) testparse maxpath sixdegrees splitkeys onak.conf \
$(BACKENDS)
+test: onak $(BACKENDS)
+ @./runtests
+
install: $(PROGS) onak.conf $(BACKENDS)
install -d $(DESTDIR)/@bindir@
install -d $(DESTDIR)/@libdir@/onak/backends
--- /dev/null
+#!/bin/sh
+set -e
+
+fail=0
+total=0
+
+if [ ! -e onak ]; then
+ echo "** onak binary doesn't exist, cannot run test suite" >&2
+ exit 1
+fi
+
+if [ -e t/db/ ]; then
+ rm -rf t/db/
+fi
+
+for t in libkeydb_*.so; do
+ backend=${t##libkeydb_}
+ backend=${backend%%.so}
+ if [ "`echo t/$backend-*`" != "t/$backend-*" ]; then
+ echo "* testing $backend backend"
+ (sed -e "s;DIR;`pwd`;" t/test-in.conf ; \
+ echo db_backend $backend) > t/test.conf
+ for t in t/$backend-*.t t/all-*.t; do
+ total=`expr $total + 1`
+ mkdir t/db/
+ if ! $t $backend; then
+ echo "test $t failed" >&2
+ fail=`expr $fail + 1`
+ fi
+ rm -rf t/db/
+ done
+ rm t/test.conf
+ fi
+done
+
+if [ "$fail" -gt 0 ]; then
+ echo "** failed $fail/$total tests" >&2
+ exit 1
+else
+ echo "** all tests succeeded"
+fi
--- /dev/null
+#!/bin/sh
+# Check we can retrieve a key by keyid
+
+set -e
+
+cd t
+../onak -b -c test.conf add < ../keys/noodles.key
+if ! ../onak -c test.conf get 0x2DA8B985 2> /dev/null | \
+ grep -q -- '-----BEGIN PGP PUBLIC KEY BLOCK-----'; then
+ echo "* Did not correctly retrieve key by keyid."
+ exit 1
+fi
+
+exit 0
--- /dev/null
+#!/bin/sh
+# Check retrieving a non existent keyid fails
+
+set -e
+
+cd t
+../onak -b -c test.conf add < ../keys/noodles.key
+if ! ../onak -c test.conf get 0x12345678 2>&1 | \
+ grep -q 'Key not found'; then
+ echo "* Did not correctly error on non-existent key"
+ exit 1
+fi
+
+exit 0
--- /dev/null
+#!/bin/sh
+# Check we can index a key by some uid text
+
+set -e
+
+# Backends should really support this, but the file one is as simple as
+# possible, so doesn't. Skip the test for it.
+if [ "$1" = "file" ]; then
+ exit 0
+fi
+
+cd t
+../onak -b -c test.conf add < ../keys/noodles.key
+if ! ../onak -c test.conf index noodles 2> /dev/null | \
+ grep -q -- 'pub 4096R/2DA8B985 2008/06/03 Jonathan McDowell'; then
+ echo "* Did not correctly retrieve key by text"
+ exit 1
+fi
+
+exit 0
--- /dev/null
+#!/bin/sh
+# Check we can add a key successfully with the db4 backend.
+
+set -e
+
+cd t
+../onak -b -c test.conf add < ../keys/noodles.key
+if [ ! -e db/worddb -o ! -e db/id32db -o ! -e db/keydb.0.db ]; then
+ echo Did not correctly add key using db4 backend.
+ exit 1
+fi
+
+exit 0
--- /dev/null
+#!/bin/sh
+# Check we can add a key successfully with the file backend.
+
+set -e
+
+cd t
+../onak -b -c test.conf add < ../keys/noodles.key
+if [ ! -e db/0x2DA8B985 ]; then
+ echo Did not correctly add key using file backend.
+ exit 1
+fi
+
+exit 0
--- /dev/null
+#!/bin/sh
+# Check we can delete a key successfully with the file backend.
+
+set -e
+
+cd t
+../onak -b -c test.conf add < ../keys/noodles.key
+../onak -b -c test.conf delete 0x2DA8B985
+if [ -e db/0x2DA8B985 ]; then
+ echo "* Did not correctly delete key using file backend"
+ exit 1
+fi
+
+exit 0
--- /dev/null
+#!/bin/sh
+# Check we can add a key successfully with the fs backend.
+
+set -e
+
+cd t
+../onak -b -c test.conf add < ../keys/noodles.key
+if [ ! -e db/key/2D/A8/2DA8B985/94FA372B2DA8B985 ]; then
+ echo Did not correctly add key using fs backend.
+ exit 1
+fi
+
+exit 0
--- /dev/null
+#!/bin/sh
+# Check we can delete a key successfully with the fs backend.
+
+set -e
+
+cd t
+../onak -b -c test.conf add < ../keys/noodles.key
+../onak -b -c test.conf delete 0x2DA8B985
+if [ -e db/key/2D/A8/2DA8B985/94FA372B2DA8B985 ]; then
+ echo "* Did not correctly delete key using fs backend"
+ exit 1
+fi
+
+exit 0
--- /dev/null
+pks_bin_dir DIR
+backends_dir DIR
+db_dir DIR/t/db/
+logfile onak.log
+loglevel 7
+use_keyd false
+this_site pgp-public-keys@localhost
+max_reply_keys 128