global reindent, now with uncrustify hook enabled
[oweals/gnunet.git] / src / credential / test_credential_issue.sh
index a78bde6ede0a2d896e28cade88ad8fc789b1b4aa..f06de5d42bb8c701e15ade1c889ed2001f3f45d3 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 trap "gnunet-arm -e -c test_credential_lookup.conf" SIGINT
 
 LOCATION=$(which gnunet-config)
@@ -20,7 +20,7 @@ rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f`
 #  (3) PKEY3.user -> PKEY4
 
 
-which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
+which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
 
 TEST_ATTR="test"
 gnunet-arm -s -c test_credential_lookup.conf
@@ -28,16 +28,17 @@ gnunet-identity -C testissuer -c test_credential_lookup.conf
 gnunet-identity -C testsubject -c test_credential_lookup.conf
 SUBJECT_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testsubject | awk '{print $3}')
 ISSUER_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testissuer | awk '{print $3}')
-EXPECTED="$SUBJECT_KEY $ISSUER_KEY $TEST_ATTR"
 #TODO1 Get credential and store it with subject (3)
-CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY --attribute=$TEST_ATTR -c test_credential_lookup.conf`
+CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY --attribute=$TEST_ATTR --ttl=5m -c test_credential_lookup.conf`
+STATUS=$?
 
-gnunet-arm -e -c test_credential_lookup.conf
-
-if [ "$EXPECTED" == "$CRED" ]
+if test $? != 0
 then
-  exit 0
-else
-  echo "FAIL: Failed to issue credential, got $CRED."
+  echo "Error issuing..."
   exit 1
 fi
+#Try import
+$DO_TIMEOUT gnunet-namestore -a -z testsubject -n c1 -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf
+RES=$?
+gnunet-arm -e -c test_credential_lookup.conf
+exit $RES