diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-05 22:18:50 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-05 22:18:50 +0100 |
commit | a97e16efa84b72dd51dcb181d4ebdbcc58a111f9 (patch) | |
tree | 6f034a61e50765685c715cfac86ad394530fb829 /src/credential | |
parent | 01fcfd11a5e4c170e0b31c60157fb9748c0d3277 (diff) | |
download | gnunet-a97e16efa84b72dd51dcb181d4ebdbcc58a111f9.tar.gz gnunet-a97e16efa84b72dd51dcb181d4ebdbcc58a111f9.zip |
- add better test for verification
Diffstat (limited to 'src/credential')
-rwxr-xr-x | src/credential/test_credential_lookup.sh | 66 | ||||
-rwxr-xr-x | src/credential/test_credential_verify.sh | 62 |
2 files changed, 62 insertions, 66 deletions
diff --git a/src/credential/test_credential_lookup.sh b/src/credential/test_credential_lookup.sh deleted file mode 100755 index fc6a59c50..000000000 --- a/src/credential/test_credential_lookup.sh +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
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) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | TEST_ISSUER="PKEY1" | ||
25 | TEST_ATTR="user" | ||
26 | TEST_SUB_ATTR="resu" | ||
27 | TEST_DELEGATION_SUBJECT="PKEY2" | ||
28 | TEST_DELEGATION_ATTR="$TEST_SUB_ATTR.$TEST_ATTR" | ||
29 | TEST_SUBDELEGATION_SUBJECT="PKEY3" | ||
30 | TEST_SUBJECT="PKEY4" | ||
31 | TEST_CREDENTIAL="c1" | ||
32 | gnunet-arm -s -c test_credential_lookup.conf | ||
33 | gnunet-identity -C testone -c test_credential_lookup.conf | ||
34 | gnunet-identity -C testtwo -c test_credential_lookup.conf | ||
35 | gnunet-identity -C testthree -c test_credential_lookup.conf | ||
36 | gnunet-identity -C testfour -c test_credential_lookup.conf | ||
37 | |||
38 | #TODO1 Get credential and store it with subject (3) | ||
39 | CRED=`$DO_TIMEOUT gnunet-credential --issue --issuer=$TEST_SUBDELEGATION_SUBJECT --attribute=$TEST_SUB_ATTR --expiration 1m -c test_credential_lookup.conf` | ||
40 | gnunet-namestore -p -z testfour -a -n $TEST_CREDENTIAL -t CRED -V $CRED -e 5m -c test_credential_lookup.conf | ||
41 | |||
42 | # (1) | ||
43 | gnunet-namestore -p -z testone -a -n $TEST_ATTR -t ATTR -V "$TEST_DELEGATION_SUBJECT $TEST_DELEGATION_ATTR" | ||
44 | |||
45 | # (2) | ||
46 | gnunet-namestore -p -z testtwo -a -n $TEST_SUB_ATTR -t ATTR -V "$TEST_SUBDELEGATION_SUBJECT" | ||
47 | |||
48 | |||
49 | #TODO2 Add -z swich like in gnunet-gns | ||
50 | RES_IP=`$DO_TIMEOUT gnunet-credential --verify --issuer=$TEST_ISSUER --attribute="$TEST_DELEGATION_ATTR" --subject=$TEST_SUBJECT --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf` | ||
51 | |||
52 | #TODO cleanup properly | ||
53 | gnunet-namestore -z testsubject -d -n newcred -t CRED -e never -c test_credential_lookup.conf | ||
54 | gnunet-identity -D testsubject -c test_credential_lookup.conf | ||
55 | gnunet-arm -e -c test_credential_lookup.conf | ||
56 | |||
57 | #TODO3 proper test | ||
58 | exit 0 | ||
59 | |||
60 | #if [ "$RES_IP" == "$TEST_CRED" ] | ||
61 | #then | ||
62 | # exit 0 | ||
63 | #else | ||
64 | # echo "FAIL: Failed to resolve to proper IP, got $RES_IP." | ||
65 | # exit 1 | ||
66 | #fi | ||
diff --git a/src/credential/test_credential_verify.sh b/src/credential/test_credential_verify.sh new file mode 100755 index 000000000..6e5ba4647 --- /dev/null +++ b/src/credential/test_credential_verify.sh | |||
@@ -0,0 +1,62 @@ | |||
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) Authority.test -> Intermediate.org.user | ||
19 | # (2) Intermediate.org -> Issuer | ||
20 | # (3) Issuer.user -> Subject | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | gnunet-arm -s -c test_credential_lookup.conf | ||
25 | gnunet-identity -C testissuer -c test_credential_lookup.conf | ||
26 | gnunet-identity -C testsubject -c test_credential_lookup.conf | ||
27 | gnunet-identity -C testintermediate -c test_credential_lookup.conf | ||
28 | gnunet-identity -C testauthority -c test_credential_lookup.conf | ||
29 | |||
30 | TEST_ATTR="user" | ||
31 | INTERMEDIATE_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testintermediate | awk '{print $3}') | ||
32 | SUBJECT_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testsubject | awk '{print $3}') | ||
33 | ISSUER_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testissuer | awk '{print $3}') | ||
34 | CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY --attribute=$TEST_ATTR -c test_credential_lookup.conf` | ||
35 | |||
36 | TEST_CREDENTIAL="t1" | ||
37 | gnunet-namestore -p -z testsubject -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf | ||
38 | |||
39 | INTERMEDIATE_ATTR="org" | ||
40 | gnunet-namestore -p -z testintermediate -a -n $INTERMEDIATE_ATTR -t ATTR -V "$ISSUER_KEY" -e 5m -c test_credential_lookup.conf | ||
41 | |||
42 | AUTHORITY_ATTR="test" | ||
43 | gnunet-namestore -p -z testauthority -a -n $AUTHORITY_ATTR -t ATTR -V "$INTERMEDIATE_KEY $INTERMEDIATE_ATTR.$TEST_ATTR" -e 5m -c test_credential_lookup.conf | ||
44 | |||
45 | #TODO2 Add -z swich like in gnunet-gns | ||
46 | #RES_CRED=`$DO_TIMEOUT gnunet-credential --verify --issuer=$ISSUER_KEY --attribute="$TEST_ATTR" --subject=$SUBJECT_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf` | ||
47 | valgrind gnunet-credential --verify --issuer=$AUTHORITY_KEY --attribute=$AUTHORITY_ATTR --subject=$SUBJECT_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf | ||
48 | |||
49 | #TODO cleanup properly | ||
50 | gnunet-namestore -z testsubject -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf | ||
51 | gnunet-arm -e -c test_credential_lookup.conf | ||
52 | |||
53 | #TODO3 proper test | ||
54 | exit 0 | ||
55 | |||
56 | if [ "$RES_CRED" == "Ok!" ] | ||
57 | then | ||
58 | exit 0 | ||
59 | else | ||
60 | echo "FAIL: Failed to verify credential $RES_IP." | ||
61 | exit 1 | ||
62 | fi | ||