aboutsummaryrefslogtreecommitdiff
path: root/src/credential/test_credential_verify.sh
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-05 22:18:50 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-05 22:18:50 +0100
commita97e16efa84b72dd51dcb181d4ebdbcc58a111f9 (patch)
tree6f034a61e50765685c715cfac86ad394530fb829 /src/credential/test_credential_verify.sh
parent01fcfd11a5e4c170e0b31c60157fb9748c0d3277 (diff)
downloadgnunet-a97e16efa84b72dd51dcb181d4ebdbcc58a111f9.tar.gz
gnunet-a97e16efa84b72dd51dcb181d4ebdbcc58a111f9.zip
- add better test for verification
Diffstat (limited to 'src/credential/test_credential_verify.sh')
-rwxr-xr-xsrc/credential/test_credential_verify.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/credential/test_credential_verify.sh b/src/credential/test_credential_verify.sh
new file mode 100755
index 000000000..6e5ba4647
--- /dev/null
+++ b/src/credential/test_credential_verify.sh
@@ -0,0 +1,62 @@
1#!/bin/bash
2trap "gnunet-arm -e -c test_credential_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18# (1) Authority.test -> Intermediate.org.user
19# (2) Intermediate.org -> Issuer
20# (3) Issuer.user -> Subject
21
22
23which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
24gnunet-arm -s -c test_credential_lookup.conf
25gnunet-identity -C testissuer -c test_credential_lookup.conf
26gnunet-identity -C testsubject -c test_credential_lookup.conf
27gnunet-identity -C testintermediate -c test_credential_lookup.conf
28gnunet-identity -C testauthority -c test_credential_lookup.conf
29
30TEST_ATTR="user"
31INTERMEDIATE_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testintermediate | awk '{print $3}')
32SUBJECT_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testsubject | awk '{print $3}')
33ISSUER_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testissuer | awk '{print $3}')
34CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY --attribute=$TEST_ATTR -c test_credential_lookup.conf`
35
36TEST_CREDENTIAL="t1"
37gnunet-namestore -p -z testsubject -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf
38
39INTERMEDIATE_ATTR="org"
40gnunet-namestore -p -z testintermediate -a -n $INTERMEDIATE_ATTR -t ATTR -V "$ISSUER_KEY" -e 5m -c test_credential_lookup.conf
41
42AUTHORITY_ATTR="test"
43gnunet-namestore -p -z testauthority -a -n $AUTHORITY_ATTR -t ATTR -V "$INTERMEDIATE_KEY $INTERMEDIATE_ATTR.$TEST_ATTR" -e 5m -c test_credential_lookup.conf
44
45#TODO2 Add -z swich like in gnunet-gns
46#RES_CRED=`$DO_TIMEOUT gnunet-credential --verify --issuer=$ISSUER_KEY --attribute="$TEST_ATTR" --subject=$SUBJECT_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf`
47valgrind gnunet-credential --verify --issuer=$AUTHORITY_KEY --attribute=$AUTHORITY_ATTR --subject=$SUBJECT_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf
48
49#TODO cleanup properly
50gnunet-namestore -z testsubject -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf
51gnunet-arm -e -c test_credential_lookup.conf
52
53#TODO3 proper test
54exit 0
55
56if [ "$RES_CRED" == "Ok!" ]
57then
58 exit 0
59else
60 echo "FAIL: Failed to verify credential $RES_IP."
61 exit 1
62fi