diff options
Diffstat (limited to 'src/credential/test_credential_verify_and.sh')
-rwxr-xr-x | src/credential/test_credential_verify_and.sh | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/src/credential/test_credential_verify_and.sh b/src/credential/test_credential_verify_and.sh index aaabcd753..03313c692 100755 --- a/src/credential/test_credential_verify_and.sh +++ b/src/credential/test_credential_verify_and.sh | |||
@@ -17,8 +17,8 @@ rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f` | |||
17 | 17 | ||
18 | # (1) Service.user -> GNU.project.member | 18 | # (1) Service.user -> GNU.project.member |
19 | # (2) GNU.project -> GNUnet | 19 | # (2) GNU.project -> GNUnet |
20 | # (3) GNUnet.member -> GNUnet.developer and (4)GNUnet.user | 20 | # (3) GNUnet.member -> GNUnet.developer AND GNUnet.user |
21 | # (5) GNUnet.developer -> Alice | 21 | # (4) GNUnet.developer -> Alice |
22 | 22 | ||
23 | 23 | ||
24 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | 24 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" |
@@ -39,43 +39,47 @@ MEMBER_ATTR="member" | |||
39 | DEVELOPER_ATTR="developer" | 39 | DEVELOPER_ATTR="developer" |
40 | DEV_ATTR="developer" | 40 | DEV_ATTR="developer" |
41 | TEST_CREDENTIAL="mygnunetcreds" | 41 | TEST_CREDENTIAL="mygnunetcreds" |
42 | set -x | 42 | |
43 | # (1) A service assigns the attribute "user" to all entities that have been assigned "member" by entities that werde assigned "project" from GNU | 43 | # (1) A service assigns the attribute "user" to all entities that have been assigned "member" by entities that werde assigned "project" from GNU |
44 | gnunet-namestore -p -z service -a -n $USER_ATTR -t ATTR -V "$GNU_KEY $GNU_PROJECT_ATTR.$MEMBER_ATTR" -e 5m -c test_credential_lookup.conf | 44 | gnunet-credential --createIssuerSide --ego=service --attribute="$USER_ATTR" --subject="$GNU_KEY $GNU_PROJECT_ATTR.$MEMBER_ATTR" --ttl="2019-12-12 10:00:00" -c test_credential_lookup.conf |
45 | gnunet-namestore -D -z service | ||
45 | 46 | ||
46 | # (2) GNU recognized GNUnet as a GNU project and delegates the "project" attribute | 47 | # (2) GNU recognized GNUnet as a GNU project and delegates the "project" attribute |
47 | gnunet-namestore -p -z gnu -a -n $GNU_PROJECT_ATTR -t ATTR -V "$GNUNET_KEY" -e 5m -c test_credential_lookup.conf | 48 | gnunet-credential --createIssuerSide --ego=gnu --attribute="$GNU_PROJECT_ATTR" --subject="$GNUNET_KEY" --ttl="2019-12-12 10:00:00" -c test_credential_lookup.conf |
49 | gnunet-namestore -D -z gnu | ||
48 | 50 | ||
49 | # (3+4) GNUnet assigns the attribute "member" to all entities gnunet has also | 51 | # (3+4) GNUnet assigns the attribute "member" to all entities gnunet has also assigned "developer" or "user" |
50 | # assigned "developer" and "user" | 52 | gnunet-credential --createIssuerSide --ego=gnunet --attribute="$MEMBER_ATTR" --subject="$GNUNET_KEY $DEVELOPER_ATTR, $GNUNET_KEY $USER_ATTR" --ttl="2019-12-12 10:00:00" -c test_credential_lookup.conf |
51 | gnunet-namestore -p -z gnunet -a -n $MEMBER_ATTR -t ATTR -V "$GNUNET_KEY $DEVELOPER_ATTR,$GNUNET_KEY $USER_ATTR" -e 5m -c test_credential_lookup.conf | 53 | gnunet-namestore -D -z gnunet |
52 | 54 | ||
53 | # (5) GNUnet issues Alice the credential "developer" | 55 | # (5) GNUnet signes the delegates and Alice stores it |
54 | CRED1=`$DO_TIMEOUT gnunet-credential --issue --ego=gnunet --subject=$ALICE_KEY --attribute=$DEV_ATTR --ttl=5m -c test_credential_lookup.conf` | 56 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=gnunet --attribute=$DEV_ATTR --subject=$ALICE_KEY --ttl="2019-12-12 10:00:00"` |
55 | # (5) GNUnet issues Alice the credential "user" | 57 | gnunet-credential --createSubjectSide --ego=alice --import "$SIGNED" --private |
56 | CRED2=`$DO_TIMEOUT gnunet-credential --issue --ego=gnunet --subject=$ALICE_KEY --attribute=$USER_ATTR --ttl=5m -c test_credential_lookup.conf` | 58 | SIGNED=`$DO_TIMEOUT gnunet-credential --signSubjectSide --ego=gnunet --attribute=$USER_ATTR --subject=$ALICE_KEY --ttl="2019-12-12 10:00:00"` |
57 | # Alice stores the credential under "mygnunetcreds" | 59 | gnunet-credential --createSubjectSide --ego=alice --import "$SIGNED" --private |
58 | gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED1" -e 5m -c test_credential_lookup.conf | 60 | gnunet-namestore -D -z alice |
59 | gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED2" -e 5m -c test_credential_lookup.conf | ||
60 | 61 | ||
61 | CREDS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$SERVICE_KEY --attribute=$USER_ATTR --ego=alice -c test_credential_lookup.conf | paste -d, -s` | 62 | # Starting to resolve |
63 | echo "+++ Starting to Resolve +++" | ||
62 | 64 | ||
63 | #TODO2 Add -z swich like in gnunet-gns | 65 | DELS=`$DO_TIMEOUT gnunet-credential --collect --issuer=$SERVICE_KEY --attribute=$USER_ATTR --ego=alice --backward -c test_credential_lookup.conf | paste -d, -s` |
64 | RES_CRED=`gnunet-credential --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --credential="$CREDS" -c test_credential_lookup.conf` | 66 | echo $DELS |
67 | echo gnunet-credential --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --delegate=\'$DELS\' --backward -c test_credential_lookup.conf | ||
68 | gnunet-credential --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --delegate="$DELS" --backward -c test_credential_lookup.conf | ||
65 | 69 | ||
70 | RES=$? | ||
66 | 71 | ||
67 | #TODO cleanup properly | 72 | # Cleanup properly |
68 | gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf | 73 | gnunet-namestore -z alice -d -n "@" -t DEL -c test_credential_lookup.conf |
69 | gnunet-namestore -z gnu -d -n $GNU_PROJECT_ATTR -t ATTR -c test_credential_lookup.conf | 74 | gnunet-namestore -z gnu -d -n $GNU_PROJECT_ATTR -t ATTR -c test_credential_lookup.conf |
70 | gnunet-namestore -z gnunet -d -n $MEMBER_ATTR -t ATTR -c test_credential_lookup.conf | 75 | gnunet-namestore -z gnunet -d -n $MEMBER_ATTR -t ATTR -c test_credential_lookup.conf |
71 | gnunet-namestore -z service -d -n $USER_ATTR -t ATTR -c test_credential_lookup.conf | 76 | gnunet-namestore -z service -d -n $USER_ATTR -t ATTR -c test_credential_lookup.conf |
72 | gnunet-arm -e -c test_credential_lookup.conf | 77 | gnunet-arm -e -c test_credential_lookup.conf |
73 | 78 | ||
74 | if [ "$RES_CRED" != "Failed." ] | 79 | if [ "$RES" == 0 ] |
75 | then | 80 | then |
76 | echo -e "${RES_CRED}" | ||
77 | exit 0 | 81 | exit 0 |
78 | else | 82 | else |
79 | echo "FAIL: Failed to verify credential $RES_CRED." | 83 | echo "FAIL: Failed to verify credential $RES_CRED." |
80 | exit 1 | 84 | exit 1 |
81 | fi \ No newline at end of file | 85 | fi |