diff options
Diffstat (limited to 'src/namestore/test_plugin_rest_namestore.sh')
-rwxr-xr-x | src/namestore/test_plugin_rest_namestore.sh | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/src/namestore/test_plugin_rest_namestore.sh b/src/namestore/test_plugin_rest_namestore.sh deleted file mode 100755 index 50b3c8c12..000000000 --- a/src/namestore/test_plugin_rest_namestore.sh +++ /dev/null | |||
@@ -1,135 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | trap "gnunet-arm -e -c test_gns_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_namestore_api.conf -f -s paths -o GNUNET_TEST_HOME` | ||
17 | |||
18 | namestore_link="http://localhost:7776/namestore" | ||
19 | wrong_link="http://localhost:7776/namestoreandmore" | ||
20 | |||
21 | |||
22 | curl_get () { | ||
23 | #$1 is link | ||
24 | #$2 is grep | ||
25 | resp=$(curl -v "$1" 2>&1) | ||
26 | cache="$(echo $resp | grep "$2")" | ||
27 | #echo $cache | ||
28 | if [ "" = "$cache" ] | ||
29 | then | ||
30 | echo "Error in get response: $resp, expected $2" | ||
31 | gnunet-arm -e -c test_namestore_api.conf | ||
32 | exit 1 | ||
33 | fi | ||
34 | } | ||
35 | |||
36 | curl_post () { | ||
37 | #$1 is link | ||
38 | #$2 is data | ||
39 | #$3 is grep | ||
40 | resp=$(curl -v -X "POST" "$1" --data "$2" 2>&1) | ||
41 | cache="$(echo $resp | grep "$3")" | ||
42 | #echo $cache | ||
43 | if [ "" = "$cache" ] | ||
44 | then | ||
45 | echo "Error in post response: $resp ($2), expected $3" | ||
46 | gnunet-arm -e -c test_namestore_api.conf | ||
47 | exit 1 | ||
48 | fi | ||
49 | } | ||
50 | |||
51 | curl_delete () { | ||
52 | #$1 is link | ||
53 | #$2 is grep | ||
54 | resp=$(curl -v -X "DELETE" "$1" 2>&1) | ||
55 | cache="$(echo $resp | grep "$2")" | ||
56 | #echo $cache | ||
57 | if [ "" = "$cache" ] | ||
58 | then | ||
59 | echo "Error in delete response: $resp, expected $2" | ||
60 | gnunet-arm -e -c test_namestore_api.conf | ||
61 | exit 1 | ||
62 | fi | ||
63 | } | ||
64 | |||
65 | # curl_put () { | ||
66 | # #$1 is link | ||
67 | # #$2 is data | ||
68 | # #$3 is grep | ||
69 | # cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")" | ||
70 | # #echo $cache | ||
71 | # if [ "" == "$cache" ] | ||
72 | # then | ||
73 | # exit 1 | ||
74 | # fi | ||
75 | # } | ||
76 | |||
77 | #Test subsystem default identity | ||
78 | |||
79 | TEST_ID="test" | ||
80 | gnunet-arm -s -c test_namestore_api.conf | ||
81 | #Test GET | ||
82 | gnunet-identity -C $TEST_ID -c test_namestore_api.conf | ||
83 | test="$(gnunet-namestore -D -z $TEST_ID -c test_namestore_api.conf)" | ||
84 | name=$TEST_ID | ||
85 | public="$(gnunet-identity -d -c test_namestore_api.conf | grep $TEST_ID | awk 'NR==1{print $3}')" | ||
86 | echo "$name $public" | ||
87 | gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8" -t "PKEY" -c test_namestore_api.conf | ||
88 | sleep 1 | ||
89 | gnunet-arm -i rest -c test_namestore_api.conf | ||
90 | sleep 1 | ||
91 | curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK" | ||
92 | curl_get "${namestore_link}/$public" "error" | ||
93 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf | ||
94 | |||
95 | #Test POST with NAME | ||
96 | curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "HTTP/1.1 204 No Content" | ||
97 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
98 | |||
99 | # invalid values | ||
100 | curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "error" | ||
101 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
102 | |||
103 | |||
104 | curl_post "${namestore_link}/$name" '{"data": [{"value":"", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name"}]:"test_entry"}' "error" | ||
105 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
106 | |||
107 | curl_post "${namestore_link}/$name" '{"data": [{"record_type":"PKEY", "expiration_time":"1d","flag":0}],"record_name":"test_entry"}' "error" | ||
108 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
109 | |||
110 | #expirations | ||
111 | curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"0d","private": false, "relative_expiration": true, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "HTTP/1.1 204" | ||
112 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
113 | |||
114 | curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"10000d","private": false, "relative_expiration": true, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "HTTP/1.1 204" | ||
115 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
116 | |||
117 | curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"now","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "error" | ||
118 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
119 | |||
120 | curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time_missing":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "error" | ||
121 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
122 | |||
123 | #record_name | ||
124 | curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":""}' "error" | ||
125 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
126 | curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name_missing":"test_entry"}' "error" | ||
127 | gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 | ||
128 | |||
129 | #Test DELETE | ||
130 | gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8" -t "PKEY" -c test_namestore_api.conf | ||
131 | curl_delete "${namestore_link}/$name/test_entry" "HTTP/1.1 204" | ||
132 | |||
133 | gnunet-arm -e -c test_namestore_api.conf | ||
134 | exit 0; | ||
135 | |||