diff options
Diffstat (limited to 'src/cli/gns/test_gns_lightest.sh')
-rwxr-xr-x | src/cli/gns/test_gns_lightest.sh | 141 |
1 files changed, 141 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..2d2203e66 --- /dev/null +++ b/src/cli/gns/test_gns_lightest.sh | |||
@@ -0,0 +1,141 @@ | |||
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 | START_EGO="startego" | ||
20 | MY_EGO="test-lightest" | ||
21 | LABEL="test-scheme" | ||
22 | PTR_LABEL="test-ptr" | ||
23 | TEST_URI="10 1 \"https://ec.europa.eu/tools/lotl/eu-lotl.xml\"" | ||
24 | TEST_SMIMEA="3 0 1 f7e8e4e554fb7c7a8f6f360e0ca2f59d466c8f9539a25963f5ed37e905f0c797" | ||
25 | SCHEME="_scheme" | ||
26 | TRUST="_trust" | ||
27 | TRANSLATION="_translation" | ||
28 | TEST_PTR="$SCHEME.$TRUST.$LABEL.$MY_EGO.$START_EGO" | ||
29 | TEST_PTR2="$TRANSLATION.$TRUST.$LABEL.$MY_EGO.$START_EGO" | ||
30 | gnunet-arm -s -c test_gns_lookup.conf | ||
31 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
32 | gnunet-identity -C $START_EGO -c test_gns_lookup.conf | ||
33 | PKEY=`gnunet-identity -d -e $MY_EGO -q -c test_gns_lookup.conf` | ||
34 | gnunet-namestore -p -z $MY_EGO -a -n $PTR_LABEL -t BOX -V "49152 49152 12 $TEST_PTR" -e never -c test_gns_lookup.conf | ||
35 | gnunet-namestore -p -z $MY_EGO -a -n $PTR_LABEL -t BOX -V "49152 49153 12 $TEST_PTR2" -e never -c test_gns_lookup.conf | ||
36 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49152 256 $TEST_URI" -e never -c test_gns_lookup.conf | ||
37 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49152 53 $TEST_SMIMEA" -e never -c test_gns_lookup.conf | ||
38 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49153 256 $TEST_URI" -e never -c test_gns_lookup.conf | ||
39 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49153 53 $TEST_SMIMEA" -e never -c test_gns_lookup.conf | ||
40 | gnunet-namestore -p -z $START_EGO -a -n $MY_EGO -t PKEY -V "$PKEY" -e never -c test_gns_lookup.conf | ||
41 | sleep 0.5 | ||
42 | PTR_SCHEME=`$DO_TIMEOUT gnunet-gns --raw -u $SCHEME.$TRUST.$PTR_LABEL.$MY_EGO.$START_EGO -t PTR -c test_gns_lookup.conf` | ||
43 | PTR_TRANSLATION=`$DO_TIMEOUT gnunet-gns --raw -u $TRANSLATION.$TRUST.$PTR_LABEL.$MY_EGO.$START_EGO -t PTR -c test_gns_lookup.conf` | ||
44 | |||
45 | SUCCESS=0 | ||
46 | if [ "$PTR_SCHEME" != "$TEST_PTR" ] | ||
47 | then | ||
48 | echo "Failed to resolve to proper PTR, got '$PTR_SCHEME'." | ||
49 | SUCCESS=1 | ||
50 | else | ||
51 | echo "Resolved to proper PTR, got '$PTR_SCHEME'." | ||
52 | fi | ||
53 | |||
54 | if [ "$PTR_TRANSLATION" != "$TEST_PTR2" ] | ||
55 | then | ||
56 | echo "Failed to resolve to proper PTR, got '$PTR_TRANSLATION'." | ||
57 | SUCCESS=1 | ||
58 | else | ||
59 | echo "Resolved to proper PTR, got '$PTR_TRANSLATION'." | ||
60 | fi | ||
61 | |||
62 | if [ "$SUCCESS" = "1" ] | ||
63 | then | ||
64 | gnunet-namestore -z $MY_EGO -X -c test_gns_lookup.conf | ||
65 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
66 | gnunet-arm -e -c test_gns_lookup.conf | ||
67 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
68 | exit 1 | ||
69 | fi | ||
70 | |||
71 | |||
72 | RES_URI_SCHEME=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_SCHEME -t URI -c test_gns_lookup.conf` | ||
73 | RES_SMIMEA_SCHEME=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_SCHEME -t SMIMEA -c test_gns_lookup.conf` | ||
74 | |||
75 | RES_URI_TRANSLATION=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_TRANSLATION -t URI -c test_gns_lookup.conf` | ||
76 | RES_SMIMEA_TRANSLATION=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_TRANSLATION -t SMIMEA -c test_gns_lookup.conf` | ||
77 | |||
78 | |||
79 | if [ "$RES_URI_SCHEME" != "$TEST_URI" ] | ||
80 | then | ||
81 | echo "Failed to resolve to proper URI, got '$RES_URI_SCHEME'." | ||
82 | SUCCESS=1 | ||
83 | else | ||
84 | echo "Resolved to proper URI, got '$RES_URI_SCHEME'." | ||
85 | fi | ||
86 | |||
87 | if [ "$RES_SMIMEA_SCHEME" != "$TEST_SMIMEA" ] | ||
88 | then | ||
89 | echo "Failed to resolve to proper SMIMEA, got '$RES_SMIMEA_SCHEME'." | ||
90 | SUCCESS=1 | ||
91 | else | ||
92 | echo "Resolved to proper SMIMEA, got '$RES_SMIMEA_SCHEME'." | ||
93 | fi | ||
94 | |||
95 | if [ "$RES_URI_TRANSLATION" != "$TEST_URI" ] | ||
96 | then | ||
97 | echo "Failed to resolve to proper URI, got '$RES_URI_TRANSLATION'." | ||
98 | SUCCESS=1 | ||
99 | else | ||
100 | echo "Resolved to proper URI, got '$RES_URI_TRANSLATION'." | ||
101 | fi | ||
102 | |||
103 | if [ "$RES_SMIMEA_TRANSLATION" != "$TEST_SMIMEA" ] | ||
104 | then | ||
105 | echo "Failed to resolve to proper SMIMEA, got '$RES_SMIMEA_TRANSLATION'." | ||
106 | SUCCESS=1 | ||
107 | else | ||
108 | echo "Resolved to proper SMIMEA, got '$RES_SMIMEA_TRANSLATION'." | ||
109 | fi | ||
110 | |||
111 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49152 256 10 1 \"thisisnotavaliduri\"" -e never -c test_gns_lookup.conf | ||
112 | status=$? | ||
113 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49152 256 10 1 mailto:thisrecordismalformed@test.com" -e never -c test_gns_lookup.conf | ||
114 | status2=$? | ||
115 | |||
116 | if [ "$status" = "0" ] | ||
117 | then | ||
118 | echo "Failed to detect malformed URI." | ||
119 | SUCCESS=1 | ||
120 | else | ||
121 | echo "Detected malformed URI." | ||
122 | fi | ||
123 | |||
124 | if [ "$status2" = "0" ] | ||
125 | then | ||
126 | echo "Failed to detect malformed URI Record Presentation." | ||
127 | SUCCESS=1 | ||
128 | else | ||
129 | echo "Detected malformed URI Presentation." | ||
130 | fi | ||
131 | |||
132 | |||
133 | |||
134 | gnunet-namestore -z $MY_EGO -X -c test_gns_lookup.conf | ||
135 | gnunet-namestore -z $START_EGO -X -c test_gns_lookup.conf | ||
136 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
137 | gnunet-identity -D $START_EGO -c test_gns_lookup.conf | ||
138 | gnunet-arm -e -c test_gns_lookup.conf | ||
139 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
140 | |||
141 | exit $SUCCESS \ No newline at end of file | ||