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