aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_plugin_rest_namestore.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/namestore/test_plugin_rest_namestore.sh')
-rwxr-xr-xsrc/namestore/test_plugin_rest_namestore.sh78
1 files changed, 8 insertions, 70 deletions
diff --git a/src/namestore/test_plugin_rest_namestore.sh b/src/namestore/test_plugin_rest_namestore.sh
index 7c1e97397..de02dfafc 100755
--- a/src/namestore/test_plugin_rest_namestore.sh
+++ b/src/namestore/test_plugin_rest_namestore.sh
@@ -11,7 +11,7 @@ curl_get () {
11 #$1 is link 11 #$1 is link
12 #$2 is grep 12 #$2 is grep
13 cache="$(curl -v "$1" 2>&1 | grep "$2")" 13 cache="$(curl -v "$1" 2>&1 | grep "$2")"
14 echo $cache 14 #echo $cache
15 if [ "" == "$cache" ] 15 if [ "" == "$cache" ]
16 then 16 then
17 exit 1 17 exit 1
@@ -23,7 +23,7 @@ curl_post () {
23 #$2 is data 23 #$2 is data
24 #$3 is grep 24 #$3 is grep
25 cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")" 25 cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")"
26 echo $cache 26 #echo $cache
27 if [ "" == "$cache" ] 27 if [ "" == "$cache" ]
28 then 28 then
29 exit 1 29 exit 1
@@ -34,7 +34,7 @@ curl_delete () {
34 #$1 is link 34 #$1 is link
35 #$2 is grep 35 #$2 is grep
36 cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")" 36 cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")"
37 echo $cache 37 #echo $cache
38 if [ "" == "$cache" ] 38 if [ "" == "$cache" ]
39 then 39 then
40 exit 1 40 exit 1
@@ -197,74 +197,12 @@ gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9
197curl_delete "${namestore_link}?label=test_entry&name=$name" "HTTP/1.1 204" 197curl_delete "${namestore_link}?label=test_entry&name=$name" "HTTP/1.1 204"
198gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" 198gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
199curl_delete "${namestore_link}?label=test_entry&pubkey=$public" "HTTP/1.1 204" 199curl_delete "${namestore_link}?label=test_entry&pubkey=$public" "HTTP/1.1 204"
200gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
201curl_delete "${namestore_link}?label=test_entry&pubkey=$name" "HTTP/1.1 404"
200 202
201exit 0;
202
203
204
205#pubkey zone
206#name zone
207curl_post "${namestore_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 201 Created"
208curl_post "${namestore_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 409"
209curl_post "${namestore_link}" '{"name":"Test_plugin_rest_identity"}' "HTTP/1.1 409"
210curl_post "${namestore_link}" '{}' "error"
211curl_post "${namestore_link}" '' "error"
212curl_post "${namestore_link}" '{"name":""}' "error"
213curl_post "${namestore_link}" '{"name":123}' "error"
214curl_post "${namestore_link}" '{"name":[]}' "error"
215curl_post "${namestore_link}" '{"name1":"test_plugin_rest_identity"}' "error"
216curl_post "${namestore_link}" '{"other":""}' "error"
217curl_post "${namestore_link}" '{"name":"test_plugin_rest_identity1", "other":"test_plugin_rest_identity2"}' "error"
218
219#Test PUT
220name="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $1}')"
221public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')"
222
223curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'"}' "HTTP/1.1 204"
224curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'"}' "HTTP/1.1 409"
225curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'xx"}' "HTTP/1.1 404"
226curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":""}' "HTTP/1.1 404"
227curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubke":""}' "HTTP/1.1 404"
228curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubke":"","other":"sdfdsf"}' "HTTP/1.1 404"
229curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubke":"","name":"sdfdsf"}' "HTTP/1.1 404"
230curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity","pubke":"","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
231curl_put "${namestore_link}" '{"newnam":"test_plugin_rest_identity","pubkey":"'$public'"}' "error"
232curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","name":"test_plugin_rest_identity"}' "HTTP/1.1 204"
233curl_put "${namestore_link}" '{"newname":"TEST_plugin_rest_identity1","name":"test_plugin_rest_identity1"}' "HTTP/1.1 409"
234curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","name":"test_plugin_rest_identity1"}' "HTTP/1.1 409"
235curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity","name":"test_plugin_rest_identityxxx"}' "HTTP/1.1 404"
236curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
237curl_put "${namestore_link}" '{"newnam":"test_plugin_rest_identityfail","name":"test_plugin_rest_identity"}' "error"
238
239
240#Test subsystem
241curl_put "${identity_link}" '{"subsystem":"namestore","name":"test_plugin_rest_identity"}' "HTTP/1.1 204"
242curl_put "${identity_link}" '{"subsystem":"namestore","name":"test_plugin_rest_identity"}' "HTTP/1.1 204"
243curl_get "${identity_link}?subsystem=namestore" "test_plugin_rest_identity"
244curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created"
245public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')"
246curl_put "${identity_link}" '{"subsystem":"namestore","pubkey":"'"$public"'"}' "HTTP/1.1 204"
247curl_get "${identity_link}?subsystem=namestore" "test_plugin_rest_identity1"
248curl_get "${identity_link}?subsystem=test_plugin_rest_identity_no_subsystem" "error"
249curl_put "${identity_link}" '{"subsystem":"test_plugin_rest_identity_no_subsystem","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
250curl_get "${identity_link}?subsystem=test_plugin_rest_identity_no_subsystem" "test_plugin_rest_identity1"
251
252curl_put "${identity_link}" '{"subsyste":"test_plugin_rest_identity_no_subsystem","name":"test_plugin_rest_identity1"}' "error"
253curl_put "${identity_link}" '{"subsystem":"test_plugin_rest_identity_no_subsystem","name":"Test_plugin_rest_identity1"}' "HTTP/1.1 204"
254
255#Test DELETE
256curl_delete "${identity_link}?name=test_plugin_rest_identity" "HTTP/1.1 204"
257curl_get "${identity_link}?name=test_plugin_rest_identity" "error"
258curl_delete "${identity_link}?name=TEST_plugin_rest_identity1" "HTTP/1.1 404"
259curl_delete "${identity_link}?name=test_plugin_rest_identity1" "HTTP/1.1 204"
260curl_get "${identity_link}?name=test_plugin_rest_identity1" "error"
261curl_delete "${identity_link}?name=test_plugin_rest_identity_not_found" "HTTP/1.1 404"
262curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created"
263public="$(gnunet-identity -d | grep "test_plugin_rest_identity1" | awk 'NR==1{print $3}')"
264curl_delete "${identity_link}?pubkey=$public" "HTTP/1.1 204"
265curl_delete "${identity_link}?pubke=$public" "error"
266curl_delete "${identity_link}?pubkey=$public&other=232" "HTTP/1.1 404"
267 203
268#test default subsystem 204#Test default identity
205#not possible without defining
269 206
270exit 0; 207exit 0;
208