diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-14 23:16:12 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-14 23:16:12 +0100 |
commit | fb662a6b560d84903e5b9601a1df1778dd12ae44 (patch) | |
tree | 589d30b3080df25658bce2e5ef883ee322d2f86a /src/credential | |
parent | 745f0dc8f07ef5275f829b13524d6afcc251e58a (diff) | |
download | gnunet-fb662a6b560d84903e5b9601a1df1778dd12ae44.tar.gz gnunet-fb662a6b560d84903e5b9601a1df1778dd12ae44.zip |
-tests
Diffstat (limited to 'src/credential')
-rw-r--r-- | src/credential/Makefile.am | 3 | ||||
-rw-r--r-- | src/credential/test_credential_lookup.conf | 2 | ||||
-rwxr-xr-x | src/credential/test_credential_verify_and.sh | 81 |
3 files changed, 84 insertions, 2 deletions
diff --git a/src/credential/Makefile.am b/src/credential/Makefile.am index 5852bd0a0..5f3b60270 100644 --- a/src/credential/Makefile.am +++ b/src/credential/Makefile.am | |||
@@ -98,7 +98,8 @@ libgnunet_plugin_rest_credential_la_LDFLAGS = \ | |||
98 | check_SCRIPTS = \ | 98 | check_SCRIPTS = \ |
99 | test_credential_issue.sh \ | 99 | test_credential_issue.sh \ |
100 | test_credential_verify_simple.sh \ | 100 | test_credential_verify_simple.sh \ |
101 | test_credential_verify.sh | 101 | test_credential_verify.sh \ |
102 | test_credential_verify_and.sh | ||
102 | 103 | ||
103 | if ENABLE_TEST_RUN | 104 | if ENABLE_TEST_RUN |
104 | if HAVE_SQLITE | 105 | if HAVE_SQLITE |
diff --git a/src/credential/test_credential_lookup.conf b/src/credential/test_credential_lookup.conf index bf321f9db..57c62fab3 100644 --- a/src/credential/test_credential_lookup.conf +++ b/src/credential/test_credential_lookup.conf | |||
@@ -11,7 +11,7 @@ PLUGINS = | |||
11 | 11 | ||
12 | [credential] | 12 | [credential] |
13 | AUTOSTART = YES | 13 | AUTOSTART = YES |
14 | PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/credlog | 14 | #PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/credlog |
15 | 15 | ||
16 | [gns] | 16 | [gns] |
17 | #PREFIX = valgrind --leak-check=full --track-origins=yes | 17 | #PREFIX = valgrind --leak-check=full --track-origins=yes |
diff --git a/src/credential/test_credential_verify_and.sh b/src/credential/test_credential_verify_and.sh new file mode 100755 index 000000000..833d36f95 --- /dev/null +++ b/src/credential/test_credential_verify_and.sh | |||
@@ -0,0 +1,81 @@ | |||
1 | #!/bin/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) Service.user -> GNU.project.member | ||
19 | # (2) GNU.project -> GNUnet | ||
20 | # (3) GNUnet.member -> GNUnet.developer | ||
21 | # (4) GNUnet.member -> GNUnet.user | ||
22 | # (5) GNUnet.developer -> Alice | ||
23 | |||
24 | |||
25 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
26 | gnunet-arm -s -c test_credential_lookup.conf | ||
27 | gnunet-identity -C service -c test_credential_lookup.conf | ||
28 | gnunet-identity -C alice -c test_credential_lookup.conf | ||
29 | gnunet-identity -C gnu -c test_credential_lookup.conf | ||
30 | gnunet-identity -C gnunet -c test_credential_lookup.conf | ||
31 | |||
32 | GNU_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep gnu | grep -v gnunet | awk '{print $3}') | ||
33 | ALICE_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep alice | awk '{print $3}') | ||
34 | GNUNET_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep gnunet | awk '{print $3}') | ||
35 | SERVICE_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep service | awk '{print $3}') | ||
36 | |||
37 | USER_ATTR="user" | ||
38 | GNU_PROJECT_ATTR="project" | ||
39 | MEMBER_ATTR="member" | ||
40 | DEVELOPER_ATTR="developer" | ||
41 | DEV_ATTR="developer" | ||
42 | TEST_CREDENTIAL="mygnunetcreds" | ||
43 | |||
44 | # (1) A service assigns the attribute "user" to all entities that have been assigned "member" by entities that werde assigned "project" from GNU | ||
45 | 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 | ||
46 | |||
47 | # (2) GNU recognized GNUnet as a GNU project and delegates the "project" attribute | ||
48 | gnunet-namestore -p -z gnu -a -n $GNU_PROJECT_ATTR -t ATTR -V "$GNUNET_KEY" -e 5m -c test_credential_lookup.conf | ||
49 | |||
50 | # (3+4) GNUnet assigns the attribute "member" to all entities gnunet has also assigned "developer" or "user" | ||
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 | ||
52 | |||
53 | # (5) GNUnet issues Alice the credential "developer" | ||
54 | CRED1=`$DO_TIMEOUT gnunet-credential --issue --ego=gnunet --subject=$ALICE_KEY --attribute=$DEV_ATTR --ttl=5m -c test_credential_lookup.conf` | ||
55 | # (5) GNUnet issues Alice the credential "user" | ||
56 | CRED2=`$DO_TIMEOUT gnunet-credential --issue --ego=gnunet --subject=$ALICE_KEY --attribute=$USER_ATTR --ttl=5m -c test_credential_lookup.conf` | ||
57 | |||
58 | |||
59 | # Alice stores the credential under "mygnunetcreds" | ||
60 | gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED1" -e 5m -c test_credential_lookup.conf | ||
61 | gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED2" -e 5m -c test_credential_lookup.conf | ||
62 | |||
63 | #TODO2 Add -z swich like in gnunet-gns | ||
64 | RES_CRED=`gnunet-credential --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf` | ||
65 | |||
66 | |||
67 | #TODO cleanup properly | ||
68 | gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf | ||
69 | 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 | ||
71 | gnunet-namestore -z service -d -n $USER_ATTR -t ATTR -c test_credential_lookup.conf | ||
72 | gnunet-arm -e -c test_credential_lookup.conf | ||
73 | |||
74 | if [ "$RES_CRED" != "Failed." ] | ||
75 | then | ||
76 | echo -e "${RES_CRED}" | ||
77 | exit 0 | ||
78 | else | ||
79 | echo "FAIL: Failed to verify credential $RES_CRED." | ||
80 | exit 1 | ||
81 | fi | ||