use NULL value in load_path_suffix to NOT load any files
[oweals/gnunet.git] / src / abd / test_abd_bi_and2.sh
1 #!/usr/bin/env bash
2 trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
3
4 LOCATION=$(which gnunet-config)
5 if [ -z $LOCATION ]
6 then
7   LOCATION="gnunet-config"
8 fi
9 $LOCATION --version 1> /dev/null
10 if test $? != 0
11 then
12         echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13         exit 77
14 fi
15
16 rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
17
18
19
20
21 which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
22 gnunet-arm -s -c test_abd_lookup.conf
23
24 gnunet-identity -C a -c test_abd_lookup.conf
25 gnunet-identity -C b -c test_abd_lookup.conf
26 gnunet-identity -C c -c test_abd_lookup.conf
27 gnunet-identity -C d -c test_abd_lookup.conf
28 gnunet-identity -C e -c test_abd_lookup.conf
29 gnunet-identity -C f -c test_abd_lookup.conf
30 gnunet-identity -C g -c test_abd_lookup.conf
31 gnunet-identity -C h -c test_abd_lookup.conf
32 AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
33 BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
34 CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
35 DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
36 EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
37 FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
38 GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
39 HKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep h | awk '{print $3}')
40 gnunet-identity -d
41
42 #   (1) (A.a) <- B.b
43 #   (2) (B.b) <- C.c AND G.g
44 #   (3) C.c <- (D.D)
45 #   (4) D.d <- (E.e)
46 #   (5) E.e <- (F) priv
47 #   (6) G.g <- (F) priv
48
49 # BIDIRECTIONAL
50 gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
51 gnunet-namestore -D -z a
52 gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_abd_lookup.conf
53 gnunet-namestore -D -z b
54
55 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
56 gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
57 gnunet-namestore -D -z d
58 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
59 gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
60 gnunet-namestore -D -z e
61 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
62 gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
63 gnunet-namestore -D -z f
64 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=g --attribute="g" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
65 gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
66 gnunet-namestore -D -z h
67
68 # Starting to resolve
69 echo "+++ Starting to Resolve +++"
70
71 DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f -c test_abd_lookup.conf | paste -d, -s - -`
72 echo $DELS
73 echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' -c test_abd_lookup.conf
74 gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" -c test_abd_lookup.conf
75
76 RES=$?
77
78 # Cleanup properly
79 gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
80 gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
81 gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
82 gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
83 gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
84
85 gnunet-arm -e -c test_abd_lookup.conf
86
87 if [ "$RES" == 0 ]
88 then
89   exit 0
90 else
91   echo "FAIL: Failed to verify credential."
92   exit 1
93 fi
94