use NULL value in load_path_suffix to NOT load any files
[oweals/gnunet.git] / src / abd / test_abd_own.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 which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
21 gnunet-arm -s -c test_abd_lookup.conf
22
23 gnunet-identity -C a -c test_abd_lookup.conf
24 gnunet-identity -C d -c test_abd_lookup.conf
25 gnunet-identity -C e -c test_abd_lookup.conf
26 gnunet-identity -C f -c test_abd_lookup.conf
27 gnunet-identity -C g -c test_abd_lookup.conf
28 AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
29 DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
30 EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
31 FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
32 GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
33
34 ############################################################################################
35 #   (1) EPub.discount <- EOrg.preferred
36 #   (2) EOrg.preferred <- StateU.student
37 #   (3) StateU.student <- RegistrarB.student
38 #   (4) RegistrarB.student <- Alice
39
40 gnunet-identity -C epub -c test_abd_lookup.conf
41 gnunet-identity -C eorg -c test_abd_lookup.conf
42 gnunet-identity -C stateu -c test_abd_lookup.conf
43 gnunet-identity -C registrarb -c test_abd_lookup.conf
44 gnunet-identity -C alice -c test_abd_lookup.conf
45
46 EPUB_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep epub | awk '{print $3}')
47 EORG_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep eorg | awk '{print $3}')
48 STATEU_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep stateu | awk '{print $3}')
49 REGISTRARB_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep registrarb | awk '{print $3}')
50 ALICE_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep alice | awk '{print $3}')
51
52
53 DISC_ATTR="discount"
54 PREF_ATTR="preferred"
55 STATE_STUD_ATTR="student"
56 REG_STUD_ATTR="student"
57 END_ATTR="end"
58
59 gnunet-identity -d
60
61 # FORWARD, subject side stored (different constallations)
62 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=a --attribute="a" --subject="$AKEY b.c" --ttl="2019-12-12 10:00:00"`
63 gnunet-abd --createSubjectSide --ego=a --import="$SIGNED"
64 gnunet-namestore -D -z a
65
66 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=a --attribute="b" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
67 gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
68 gnunet-namestore -D -z d
69
70 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY" --ttl="2019-12-12 10:00:00"`
71 gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
72 gnunet-namestore -D -z e
73
74 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="c" --subject="$FKEY c" --ttl="2019-12-12 10:00:00"`
75 gnunet-abd --createSubjectSide --ego=f --import="$SIGNED"
76 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="k" --subject="$FKEY c.k" --ttl="2019-12-12 10:00:00"`
77 gnunet-abd --createSubjectSide --ego=f --import="$SIGNED"
78 gnunet-namestore -D -z f
79
80 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=f --attribute="c" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
81 gnunet-abd --createSubjectSide --ego=g --import="$SIGNED" --private
82 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=a --attribute="c" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
83 gnunet-abd --createSubjectSide --ego=g --import="$SIGNED" --private
84 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="h.o" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
85 gnunet-abd --createSubjectSide --ego=g --import="$SIGNED"
86 gnunet-namestore -D -z g
87
88
89 # BACKWARD, issuer side stored
90 # (1) EPub assigns the attribute "discount" to all entities that have been assigned "preferred" by EOrg
91 gnunet-abd --createIssuerSide --ego=epub --attribute=$DISC_ATTR --subject="$EORG_KEY $PREF_ATTR" --ttl=5m -c test_abd_lookup.conf
92
93 # (2) EOrg assigns the attribute "preferred" to all entities that have been assigned "student" by StateU
94 gnunet-abd --createIssuerSide --ego=eorg --attribute=$PREF_ATTR --subject="$STATEU_KEY $STATE_STUD_ATTR" --ttl=5m -c test_abd_lookup.conf
95
96 # (3) StateU assigns the attribute "student" to all entities that have been asssigned "student" by RegistrarB
97 gnunet-abd --createIssuerSide --ego=stateu --attribute=$STATE_STUD_ATTR --subject="$REGISTRARB_KEY $REG_STUD_ATTR" --ttl=5m -c test_abd_lookup.conf
98
99 # (4) RegistrarB issues Alice the credential "student"
100 SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=registrarb --attribute="$REG_STUD_ATTR" --subject="$ALICE_KEY" --ttl="2019-12-12 10:00:00"`
101 gnunet-abd --createSubjectSide --ego=alice --import="$SIGNED" --private
102
103 # Starting to resolve
104 echo "+++ Starting to Resolve +++"
105
106 # FORWARD
107 #DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=g --forward -c test_abd_lookup.conf | paste -d, -s - -`
108 #echo $DELS
109 #echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate=\'$DELS\' --forward -c test_abd_lookup.conf
110 #RES_DELS=`gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate="$DELS" --forward -c test_abd_lookup.conf`
111
112 # BACKWARD
113 DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice --backward -c test_abd_lookup.conf | paste -d, -s - -`
114 echo $DELS
115 echo gnunet-abd --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --delegate=\'$DELS\' --backward -c test_abd_lookup.conf
116 gnunet-abd --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --delegate="$DELS" --backward -c test_abd_lookup.conf
117
118 RES=$?
119
120 # Cleanup properly
121 gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_abd_lookup.conf
122 gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_abd_lookup.conf
123 gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_abd_lookup.conf
124 #gnunet-namestore -z a -d -n "@" -t DEL -c test_abd_lookup.conf
125 #gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
126 #gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
127 #gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
128 #gnunet-namestore -z g -d -n "@" -t DEL -c test_abd_lookup.conf
129
130
131 gnunet-arm -e -c test_abd_lookup.conf
132
133 if [ "$RES" == 0 ]
134 then
135   exit 0
136 else
137   echo "FAIL: Failed to verify credential."
138   exit 1
139 fi
140