aboutsummaryrefslogtreecommitdiff
path: root/src/credential/test_credential_own.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/credential/test_credential_own.sh')
-rwxr-xr-xsrc/credential/test_credential_own.sh103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/credential/test_credential_own.sh b/src/credential/test_credential_own.sh
new file mode 100755
index 000000000..a5f567511
--- /dev/null
+++ b/src/credential/test_credential_own.sh
@@ -0,0 +1,103 @@
1#!/usr/bin/env 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) EPub.discount <- EOrg.preferred
19# (2) EOrg.preferred <- StateU.student
20# (3) StateU.student <- RegistrarB.student
21# (4) RegistrarB.student <- Alice
22
23
24which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
25gnunet-arm -s -c test_credential_lookup.conf
26gnunet-identity -C epub -c test_credential_lookup.conf
27gnunet-identity -C eorg -c test_credential_lookup.conf
28gnunet-identity -C stateu -c test_credential_lookup.conf
29gnunet-identity -C registrarb -c test_credential_lookup.conf
30gnunet-identity -C alice -c test_credential_lookup.conf
31
32EPUB_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep epub | awk '{print $3}')
33EORG_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep eorg | awk '{print $3}')
34STATEU_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep stateu | awk '{print $3}')
35REGISTRARB_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep registrarb | awk '{print $3}')
36ALICE_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep alice | awk '{print $3}')
37
38
39DISC_ATTR="discount"
40PREF_ATTR="preferred"
41STATE_STUD_ATTR="student"
42REG_STUD_ATTR="student"
43END_ATTR="end"
44
45TEST_CREDENTIAL="mygnunetcreds"
46# Test for forward search (0) StateU.student -> EOrg.end
47# gnunet-namestore -p -z eorg -a -n "@" -t DEL -V "$STATEU_KEY $STATE_STUD_ATTR <- $EORG_KEY $END_ATTR" -e 60m -c test_credential_lookup.conf
48# gnunet-namestore -D -z eorg
49
50# Alternative Format that is being implemented at the moment:
51# Issuerside:
52# gnunet-credential --create --ego=A --attribute="a" --subject="B.b" --where="is"
53 gnunet-credential --createIssuerSide --ego=epub --attribute="aasds" --subject="$EORG_KEY basd" --ttl=60m
54 SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=epub --attribute="asd" --subject="$EORG_KEY basd" --ttl=60m`
55 echo $SIGNED
56 gnunet-credential --createSubjectSide --extension "$SIGNED"
57# Subjectside:
58# X = gnunet-credential --create -e E -a "a" -s "B.b" -w ss
59# gnunet-credential --add -e E -x X
60
61# (1) EPub assigns the attribute "discount" to all entities that have been assigned "preferred" by EOrg
62gnunet-namestore -p -z epub -a -n $DISC_ATTR -t ATTR -V "$EORG_KEY $PREF_ATTR" -e 5m -c test_credential_lookup.conf
63gnunet-namestore -D -z epub
64
65# (2) EOrg assigns the attribute "preferred" to all entities that have been assigned "student" by StateU
66gnunet-namestore -p -z eorg -a -n $PREF_ATTR -t ATTR -V "$STATEU_KEY $STATE_STUD_ATTR" -e 5m -c test_credential_lookup.conf
67
68# (3) StateU assigns the attribute "student" to all entities that have been asssigned "student" by RegistrarB
69gnunet-namestore -p -z stateu -a -n $STATE_STUD_ATTR -t ATTR -V "$REGISTRARB_KEY $REG_STUD_ATTR" -e 5m -c test_credential_lookup.conf
70
71# (4) RegistrarB issues Alice the credential "student"
72CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=registrarb --subject=$ALICE_KEY --attribute=$REG_STUD_ATTR --ttl=5m -c test_credential_lookup.conf`
73
74# Alice stores the credential under "mygnunetcreds"
75gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf
76
77# Starting to resolve
78echo "+++++Starting Collect"
79
80CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice -c test_credential_lookup.conf | paste -d, -s`
81echo $CREDS
82echo gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential=\'$CREDS\' -c test_credential_lookup.conf
83
84RES_CRED=`gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential="$CREDS" -c test_credential_lookup.conf`
85
86
87# Cleanup properly
88gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf
89gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf
90gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf
91gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf
92gnunet-arm -e -c test_credential_lookup.conf
93
94if [ "$RES_CRED" != "Failed." ]
95then
96 # TODO: replace echo -e bashism
97 echo -e "${RES_CRED}"
98 exit 0
99else
100 echo "FAIL: Failed to verify credential $RES_CRED."
101 exit 1
102fi
103