diff options
author | Sebastian Nadler <sebastian.nadler@tum.de> | 2023-11-19 17:07:45 +0100 |
---|---|---|
committer | Sebastian Nadler <sebastian.nadler@tum.de> | 2023-11-30 19:33:50 +0100 |
commit | fe90b359885e02363f1d4442bb4c2d41fd75c680 (patch) | |
tree | 67b1503bf5231915fae9ff2457eaeaf7bf504218 | |
parent | 8b0cafb1d8545fc06c5670f42b759b00d5c059b5 (diff) | |
download | gnunet-fe90b359885e02363f1d4442bb4c2d41fd75c680.tar.gz gnunet-fe90b359885e02363f1d4442bb4c2d41fd75c680.zip |
test_gns_lightest.sh for lightest lookup tests
-rwxr-xr-x | src/cli/gns/test_gns_lightest.sh | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/src/cli/gns/test_gns_lightest.sh b/src/cli/gns/test_gns_lightest.sh new file mode 100755 index 000000000..03c313a7b --- /dev/null +++ b/src/cli/gns/test_gns_lightest.sh | |||
@@ -0,0 +1,135 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
19 | MY_EGO="test-lightest" | ||
20 | LABEL="test-scheme" | ||
21 | PTR_LABEL="test-ptr" | ||
22 | TEST_URI="10 1 \"https://ec.europa.eu/tools/lotl/eu-lotl.xml\"" | ||
23 | TEST_SMIMEA="3 0 1 f7e8e4e554fb7c7a8f6f360e0ca2f59d466c8f9539a25963f5ed37e905f0c797" | ||
24 | SCHEME="_scheme" | ||
25 | TRUST="_trust" | ||
26 | TRUSTLIST="_trustlist" | ||
27 | TEST_PTR="$SCHEME.$TRUST.$LABEL.$MY_EGO" | ||
28 | TEST_PTR2="$TRUSTLIST.$TRUST.$LABEL.$MY_EGO" | ||
29 | gnunet-arm -s -c test_gns_lookup.conf | ||
30 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
31 | gnunet-namestore -p -z $MY_EGO -a -n $PTR_LABEL -t BOX -V "242 1003 12 $TEST_PTR" -e never -c test_gns_lookup.conf | ||
32 | gnunet-namestore -p -z $MY_EGO -a -n $PTR_LABEL -t BOX -V "242 1002 12 $TEST_PTR2" -e never -c test_gns_lookup.conf | ||
33 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "242 1003 256 $TEST_URI" -e never -c test_gns_lookup.conf | ||
34 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "242 1003 53 $TEST_SMIMEA" -e never -c test_gns_lookup.conf | ||
35 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "242 1002 256 $TEST_URI" -e never -c test_gns_lookup.conf | ||
36 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "242 1002 53 $TEST_SMIMEA" -e never -c test_gns_lookup.conf | ||
37 | sleep 0.5 | ||
38 | PTR_SCHEME=`$DO_TIMEOUT gnunet-gns --raw -u $SCHEME.$TRUST.$PTR_LABEL.$MY_EGO -t PTR -c test_gns_lookup.conf` | ||
39 | PTR_TRUSTLIST=`$DO_TIMEOUT gnunet-gns --raw -u $TRUSTLIST.$TRUST.$PTR_LABEL.$MY_EGO -t PTR -c test_gns_lookup.conf` | ||
40 | |||
41 | SUCCESS=0 | ||
42 | if [ "$PTR_SCHEME" != "$TEST_PTR" ] | ||
43 | then | ||
44 | echo "Failed to resolve to proper PTR, got '$PTR_SCHEME'." | ||
45 | SUCCESS=1 | ||
46 | else | ||
47 | echo "Resolved to proper PTR, got '$PTR_SCHEME'." | ||
48 | fi | ||
49 | |||
50 | if [ "$PTR_TRUSTLIST" != "$TEST_PTR2" ] | ||
51 | then | ||
52 | echo "Failed to resolve to proper PTR, got '$PTR_TRUSTLIST'." | ||
53 | SUCCESS=1 | ||
54 | else | ||
55 | echo "Resolved to proper PTR, got '$PTR_TRUSTLIST'." | ||
56 | fi | ||
57 | |||
58 | if [ "$SUCCESS" = "1" ] | ||
59 | then | ||
60 | gnunet-namestore -z $MY_EGO -X -c test_gns_lookup.conf | ||
61 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
62 | gnunet-arm -e -c test_gns_lookup.conf | ||
63 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
64 | exit 1 | ||
65 | fi | ||
66 | |||
67 | |||
68 | RES_URI_SCHEME=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_SCHEME -t URI -c test_gns_lookup.conf` | ||
69 | RES_SMIMEA_SCHEME=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_SCHEME -t SMIMEA -c test_gns_lookup.conf` | ||
70 | |||
71 | RES_URI_TRUSTLIST=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_TRUSTLIST -t URI -c test_gns_lookup.conf` | ||
72 | RES_SMIMEA_TRUSTLIST=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_TRUSTLIST -t SMIMEA -c test_gns_lookup.conf` | ||
73 | |||
74 | |||
75 | if [ "$RES_URI_SCHEME" != "$TEST_URI" ] | ||
76 | then | ||
77 | echo "Failed to resolve to proper URI, got '$RES_URI_SCHEME'." | ||
78 | SUCCESS=1 | ||
79 | else | ||
80 | echo "Resolved to proper URI, got '$RES_URI_SCHEME'." | ||
81 | fi | ||
82 | |||
83 | if [ "$RES_SMIMEA_SCHEME" != "$TEST_SMIMEA" ] | ||
84 | then | ||
85 | echo "Failed to resolve to proper SMIMEA, got '$RES_SMIMEA_SCHEME'." | ||
86 | SUCCESS=1 | ||
87 | else | ||
88 | echo "Resolved to proper SMIMEA, got '$RES_SMIMEA_SCHEME'." | ||
89 | fi | ||
90 | |||
91 | if [ "$RES_URI_TRUSTLIST" != "$TEST_URI" ] | ||
92 | then | ||
93 | echo "Failed to resolve to proper URI, got '$RES_URI_TRUSTLIST'." | ||
94 | SUCCESS=1 | ||
95 | else | ||
96 | echo "Resolved to proper URI, got '$RES_URI_TRUSTLIST'." | ||
97 | fi | ||
98 | |||
99 | if [ "$RES_SMIMEA_TRUSTLIST" != "$TEST_SMIMEA" ] | ||
100 | then | ||
101 | echo "Failed to resolve to proper SMIMEA, got '$RES_SMIMEA_TRUSTLIST'." | ||
102 | SUCCESS=1 | ||
103 | else | ||
104 | echo "Resolved to proper SMIMEA, got '$RES_SMIMEA_TRUSTLIST'." | ||
105 | fi | ||
106 | |||
107 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "242 1003 256 10 1 \"thisisnotavaliduri\"" -e never -c test_gns_lookup.conf | ||
108 | status=$? | ||
109 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "242 1003 256 10 1 mailto:thisrecordismilformed@test.com" -e never -c test_gns_lookup.conf | ||
110 | status2=$? | ||
111 | |||
112 | if [ "$status" = "0" ] | ||
113 | then | ||
114 | echo "Failed to detect malformed URI." | ||
115 | SUCCESS=1 | ||
116 | else | ||
117 | echo "Detected malformed URI." | ||
118 | fi | ||
119 | |||
120 | if [ "$status2" = "0" ] | ||
121 | then | ||
122 | echo "Failed to detect malformed URI Record Presentation." | ||
123 | SUCCESS=1 | ||
124 | else | ||
125 | echo "Detected malformed URI Presentation." | ||
126 | fi | ||
127 | |||
128 | |||
129 | |||
130 | gnunet-namestore -z $MY_EGO -X -c test_gns_lookup.conf | ||
131 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
132 | gnunet-arm -e -c test_gns_lookup.conf | ||
133 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
134 | |||
135 | exit $SUCCESS \ No newline at end of file | ||