diff options
Diffstat (limited to 'src/credential/test_credential_own.sh')
-rwxr-xr-x | src/credential/test_credential_own.sh | 103 |
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 | ||
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 | # (1) EPub.discount <- EOrg.preferred | ||
19 | # (2) EOrg.preferred <- StateU.student | ||
20 | # (3) StateU.student <- RegistrarB.student | ||
21 | # (4) RegistrarB.student <- Alice | ||
22 | |||
23 | |||
24 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
25 | gnunet-arm -s -c test_credential_lookup.conf | ||
26 | gnunet-identity -C epub -c test_credential_lookup.conf | ||
27 | gnunet-identity -C eorg -c test_credential_lookup.conf | ||
28 | gnunet-identity -C stateu -c test_credential_lookup.conf | ||
29 | gnunet-identity -C registrarb -c test_credential_lookup.conf | ||
30 | gnunet-identity -C alice -c test_credential_lookup.conf | ||
31 | |||
32 | EPUB_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep epub | awk '{print $3}') | ||
33 | EORG_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep eorg | awk '{print $3}') | ||
34 | STATEU_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep stateu | awk '{print $3}') | ||
35 | REGISTRARB_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep registrarb | awk '{print $3}') | ||
36 | ALICE_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep alice | awk '{print $3}') | ||
37 | |||
38 | |||
39 | DISC_ATTR="discount" | ||
40 | PREF_ATTR="preferred" | ||
41 | STATE_STUD_ATTR="student" | ||
42 | REG_STUD_ATTR="student" | ||
43 | END_ATTR="end" | ||
44 | |||
45 | TEST_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 | ||
62 | gnunet-namestore -p -z epub -a -n $DISC_ATTR -t ATTR -V "$EORG_KEY $PREF_ATTR" -e 5m -c test_credential_lookup.conf | ||
63 | gnunet-namestore -D -z epub | ||
64 | |||
65 | # (2) EOrg assigns the attribute "preferred" to all entities that have been assigned "student" by StateU | ||
66 | gnunet-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 | ||
69 | gnunet-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" | ||
72 | CRED=`$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" | ||
75 | gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf | ||
76 | |||
77 | # Starting to resolve | ||
78 | echo "+++++Starting Collect" | ||
79 | |||
80 | CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice -c test_credential_lookup.conf | paste -d, -s` | ||
81 | echo $CREDS | ||
82 | echo gnunet-credential --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --credential=\'$CREDS\' -c test_credential_lookup.conf | ||
83 | |||
84 | RES_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 | ||
88 | gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf | ||
89 | gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_credential_lookup.conf | ||
90 | gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_credential_lookup.conf | ||
91 | gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_credential_lookup.conf | ||
92 | gnunet-arm -e -c test_credential_lookup.conf | ||
93 | |||
94 | if [ "$RES_CRED" != "Failed." ] | ||
95 | then | ||
96 | # TODO: replace echo -e bashism | ||
97 | echo -e "${RES_CRED}" | ||
98 | exit 0 | ||
99 | else | ||
100 | echo "FAIL: Failed to verify credential $RES_CRED." | ||
101 | exit 1 | ||
102 | fi | ||
103 | |||