diff options
Diffstat (limited to 'src/credential/test_credential_own_and2.sh')
-rwxr-xr-x | src/credential/test_credential_own_and2.sh | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/credential/test_credential_own_and2.sh b/src/credential/test_credential_own_and2.sh new file mode 100755 index 000000000..bbce251ec --- /dev/null +++ b/src/credential/test_credential_own_and2.sh | |||
@@ -0,0 +1,88 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | trap "gnunet-arm -e -c test_credential_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_credential_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_credential_lookup.conf | ||
23 | |||
24 | gnunet-identity -C a -c test_credential_lookup.conf | ||
25 | gnunet-identity -C b -c test_credential_lookup.conf | ||
26 | gnunet-identity -C c -c test_credential_lookup.conf | ||
27 | gnunet-identity -C d -c test_credential_lookup.conf | ||
28 | gnunet-identity -C e -c test_credential_lookup.conf | ||
29 | gnunet-identity -C f -c test_credential_lookup.conf | ||
30 | gnunet-identity -C g -c test_credential_lookup.conf | ||
31 | gnunet-identity -C h -c test_credential_lookup.conf | ||
32 | AKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep a | awk '{print $3}') | ||
33 | BKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep b | awk '{print $3}') | ||
34 | CKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep c | awk '{print $3}') | ||
35 | DKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep d | awk '{print $3}') | ||
36 | EKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep e | awk '{print $3}') | ||
37 | FKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep f | awk '{print $3}') | ||
38 | GKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep g | awk '{print $3}') | ||
39 | HKEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep h | awk '{print $3}') | ||
40 | |||
41 | # (1) (A.a) <- B.b | ||
42 | # (2) (B.b) <- C.c AND G.g | ||
43 | # (3) C.c <- (F) priv | ||
44 | # (4) G.g <- (F) priv | ||
45 | |||
46 | # BIDIRECTIONAL | ||
47 | gnunet-credential --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_credential_lookup.conf | ||
48 | gnunet-namestore -D -z a | ||
49 | gnunet-credential --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_credential_lookup.conf | ||
50 | gnunet-namestore -D -z b | ||
51 | |||
52 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=g --attribute="g" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
53 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
54 | gnunet-namestore -D -z h | ||
55 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=c --attribute="c" --subject="$FKEY" --ttl="2019-12-12 10:00:00"` | ||
56 | gnunet-credential --createSubjectSide --ego=f --import "$SIGNED" --private | ||
57 | gnunet-namestore -D -z f | ||
58 | |||
59 | # Starting to resolve | ||
60 | echo "+++ Starting to Resolve +++" | ||
61 | |||
62 | DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$AKEY --attribute="a" --ego=f --backward -c test_credential_lookup.conf | paste -d, -s` | ||
63 | echo $DELS | ||
64 | echo gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --backward -c test_credential_lookup.conf | ||
65 | RES_DELS=`gnunet-credential --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --backward -c test_credential_lookup.conf` | ||
66 | |||
67 | # Cleanup properly | ||
68 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf | ||
69 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf | ||
70 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
71 | #gnunet-namestore -z a -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
72 | #gnunet-namestore -z d -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
73 | #gnunet-namestore -z e -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
74 | #gnunet-namestore -z f -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
75 | #gnunet-namestore -z g -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
76 | |||
77 | gnunet-arm -e -c test_credential_lookup.conf | ||
78 | |||
79 | if [ "$RES_DELS" != "Failed." ] | ||
80 | then | ||
81 | # TODO: replace echo -e bashism | ||
82 | echo -e "${RES_DELS}" | ||
83 | exit 0 | ||
84 | else | ||
85 | echo "FAIL: Failed to verify credential $RES_DELS." | ||
86 | exit 1 | ||
87 | fi | ||
88 | |||