aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_plugin_rest_namestore.sh
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2023-10-19 09:37:26 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2023-10-19 09:37:26 +0200
commitb7a1d4379ebcff1c878d068cbd8df34fd16d81d4 (patch)
treef7f1c37fb5f106ca165a79a5c5fb4f3e13abbdc2 /src/namestore/test_plugin_rest_namestore.sh
parent54a37c4239d34fc3b681df78a5a8b4d6a7bde902 (diff)
downloadgnunet-b7a1d4379ebcff1c878d068cbd8df34fd16d81d4.tar.gz
gnunet-b7a1d4379ebcff1c878d068cbd8df34fd16d81d4.zip
BUILD: Move namestore to service
Diffstat (limited to 'src/namestore/test_plugin_rest_namestore.sh')
-rwxr-xr-xsrc/namestore/test_plugin_rest_namestore.sh131
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
2trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_namestore_api.conf -f -s paths -o GNUNET_TEST_HOME`
17
18namestore_link="http://localhost:7776/namestore"
19wrong_link="http://localhost:7776/namestoreandmore"
20
21curl_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
35curl_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
50curl_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
78TEST_ID="test"
79gnunet-arm -s -c test_namestore_api.conf
80#Test GET
81gnunet-identity -C $TEST_ID -c test_namestore_api.conf
82test="$(gnunet-namestore -D -z $TEST_ID -c test_namestore_api.conf)"
83name=$TEST_ID
84public="$(gnunet-identity -d -c test_namestore_api.conf | grep $TEST_ID | awk 'NR==1{print $3}')"
85echo "$name $public"
86gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8" -t "PKEY" -c test_namestore_api.conf
87sleep 1
88gnunet-arm -i rest -c test_namestore_api.conf
89sleep 1
90curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK"
91curl_get "${namestore_link}/$public" "error"
92gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf
93
94#Test POST with NAME
95curl_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"
96gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
97
98# invalid values
99curl_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"
100gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
101
102
103curl_post "${namestore_link}/$name" '{"data": [{"value":"", "record_type":"PKEY", "relative_expiration": 86400000000,"flag":0,"record_name"}]:"test_entry"}' "error"
104gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
105
106curl_post "${namestore_link}/$name" '{"data": [{"record_type":"PKEY", "relative_expiration": 86400000000,"flag":0}],"record_name":"test_entry"}' "error"
107gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
108
109#expirations
110curl_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"
111gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
112
113curl_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"
114gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
115
116curl_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"
117gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
118
119#record_name
120curl_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"
121gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
122curl_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"
123gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
124
125#Test DELETE
126gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8" -t "PKEY" -c test_namestore_api.conf
127curl_delete "${namestore_link}/$name/test_entry" "HTTP/1.1 204"
128
129gnunet-arm -e -c test_namestore_api.conf
130exit 0;
131