simple test code
authornsz <nsz@port70.net>
Mon, 23 Jan 2012 21:07:56 +0000 (22:07 +0100)
committernsz <nsz@port70.net>
Mon, 23 Jan 2012 21:07:56 +0000 (22:07 +0100)
test/basic.sh [new file with mode: 0644]

diff --git a/test/basic.sh b/test/basic.sh
new file mode 100644 (file)
index 0000000..857e19e
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+set -e
+
+PORT="8080"
+SERVER="http://localhost:$PORT"
+CSTORE="cstore"
+SSTORE="sstore"
+CFLAG="-dir=$CSTORE -server=$SERVER"
+SFLAG="-dir=$SSTORE -addr=:$PORT"
+
+client() {
+       echo epoint-client $CFLAG "$@" 1>&2
+       epoint-client $CFLAG "$@"
+}
+
+# TODO: storage..
+# send [key|draft|cert] path
+send() {
+       curl --data-urlencode $1@$2 $SERVER/submit
+}
+
+# query q
+query() {
+       curl $SERVER/$1
+}
+
+rm -rf $CSTORE $SSTORE
+
+epoint-server $SFLAG &
+echo $! >server.pid
+sleep 1
+
+# get server key
+client c
+
+# make issuer key
+IFPR=$(echo isecret | client i unit | client v | awk '/^Id:/ {print $2}')
+
+# make holder key
+HFPR=$(echo hsecret | client h $IFPR | client v | awk '/^Id:/ {print $2}')
+
+# send keys
+echo isecret | client i '' | client s k
+echo hsecret | client h $IFPR | client s k
+
+# make draft: issuer->holder 10
+echo isecret | client d $HFPR 10 | client s d | client s c | client v | awk '/^Balance:/ {if ($2 != 10) exit 1}'
+# make draft: holder->issuer 3
+echo hsecret | client d $IFPR 3 | client s d | client s c | client v | awk '/^Balance:/ {if ($2 != -7) exit 1}'
+
+# check certs
+query certby/key.issuer/$IFPR.$IFPR | client v | awk '/^Balance:/ {if ($2 != -7) exit 1}'
+query certby/key.issuer/$HFPR.$IFPR | client v | awk '/^Balance:/ {if ($2 != 7) exit 1}'
+
+kill $(cat server.pid)
+rm -f server.pid
+echo server is killed 1>&2
+echo PASS