From 341c1dd692c62a88eeff34fca155ce2377677d4b Mon Sep 17 00:00:00 2001 From: Phil Date: Mon, 13 Aug 2018 11:23:13 +0200 Subject: moved test files and fixed namestore --- src/gns/test_plugin_rest_gns.sh | 50 ------- src/identity/test_plugin_rest_identity.sh | 157 -------------------- src/namestore/test_plugin_rest_namestore.sh | 147 ------------------- src/rest-plugins/plugin_rest_namestore.c | 193 +++++++++++++++++++------ src/rest-plugins/test_plugin_rest_gns.sh | 50 +++++++ src/rest-plugins/test_plugin_rest_identity.sh | 157 ++++++++++++++++++++ src/rest-plugins/test_plugin_rest_namestore.sh | 147 +++++++++++++++++++ 7 files changed, 500 insertions(+), 401 deletions(-) delete mode 100755 src/gns/test_plugin_rest_gns.sh delete mode 100755 src/identity/test_plugin_rest_identity.sh delete mode 100755 src/namestore/test_plugin_rest_namestore.sh create mode 100755 src/rest-plugins/test_plugin_rest_gns.sh create mode 100755 src/rest-plugins/test_plugin_rest_identity.sh create mode 100755 src/rest-plugins/test_plugin_rest_namestore.sh (limited to 'src') diff --git a/src/gns/test_plugin_rest_gns.sh b/src/gns/test_plugin_rest_gns.sh deleted file mode 100755 index ec495a04b..000000000 --- a/src/gns/test_plugin_rest_gns.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/bash - -#First, start gnunet-arm and the rest-service. -#Exit 0 means success, exit 1 means failed test - -gns_link="http://localhost:7776/gns" -wrong_link="http://localhost:7776/gnsandmore" - -curl_get () { - #$1 is link - #$2 is grep - cache="$(curl -v "$1" 2>&1 | grep "$2")" - #echo $cache - if [ "" == "$cache" ] - then - exit 1 - fi -} - -gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 - -curl_get "$gns_link/www.test_plugin_rest_gns" "error" - -gnunet-identity -C "test_plugin_rest_gns" - -curl_get "$gns_link/www.test_plugin_rest_gns" "\[\]" - -gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.1 -t A - -curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.1" - -gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1::1 -t AAAA - -curl_get "$gns_link/www.test_plugin_rest_gns" "1::1.*1.1.1.1" - -gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.2 -t A - -curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.2.*1::1.*1.1.1.1" -curl_get "$gns_link/www.test_plugin_rest_gns?record_type=A" "1.1.1.2.*1.1.1.1" -curl_get "$gns_link/www.test_plugin_rest_gns?record_type=AAAA" "1::1" -curl_get "$gns_link/www.test_plugin_rest_gns?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1" - -gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www1 -e 1d -V 1.1.1.1 -t A -curl_get "$gns_link/www1.test_plugin_rest_gns" "1.1.1.1" - -gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 - -curl_get "$gns_link/www1.test_plugin_rest_gns" "error" - -exit 0 diff --git a/src/identity/test_plugin_rest_identity.sh b/src/identity/test_plugin_rest_identity.sh deleted file mode 100755 index a5879dd7e..000000000 --- a/src/identity/test_plugin_rest_identity.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/bash - -#First, start gnunet-arm and the rest-service. -#Exit 0 means success, exit 1 means failed test - -identity_link="http://localhost:7776/identity" -wrong_link="http://localhost:7776/identityandmore" - - -curl_get () { - #$1 is link - #$2 is grep - cache="$(curl -v "$1" 2>&1 | grep "$2")" - #echo $cache - if [ "" == "$cache" ] - then - exit 1 - fi -} - -curl_post () { - #$1 is link - #$2 is data - #$3 is grep - cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")" - #echo $cache - if [ "" == "$cache" ] - then - exit 1 - fi -} - -curl_delete () { - #$1 is link - #$2 is grep - cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")" - #echo $cache - if [ "" == "$cache" ] - then - exit 1 - fi -} - -curl_put () { - #$1 is link - #$2 is data - #$3 is grep - cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")" - #echo $cache - if [ "" == "$cache" ] - then - exit 1 - fi -} - -#Test GET -test="$(gnunet-identity -d)" -#if no identity exists -if [ "" == "$test" ] -then - curl_get "$identity_link/all" "error" - gnunet-identity -C "test_plugin_rest_identity" - name="$(gnunet-identity -d | awk 'NR==1{print $1}')" - public="$(gnunet-identity -d | awk 'NR==1{print $3}')" - - curl_get "${identity_link}/name/$name" "$public" - curl_get "${identity_link}/name/$public" "error" - curl_get "${identity_link}/name/" "error" - - curl_get "${identity_link}/pubkey/$public" "$name" - curl_get "${identity_link}/pubkey/$name" "error" - curl_get "${identity_link}/pubkey/" "error" - - gnunet-identity -D "test_plugin_rest_identity" -else - name="$(gnunet-identity -d | awk 'NR==1{print $1}')" - public="$(gnunet-identity -d | awk 'NR==1{print $3}')" - - curl_get "${identity_link}/name/$name" "$public" - curl_get "${identity_link}/name/$public" "error" - curl_get "${identity_link}/name/" "error" - - curl_get "${identity_link}/pubkey/$public" "$name" - curl_get "${identity_link}/pubkey/$name" "error" - curl_get "${identity_link}/pubkey/" "error" -fi - -#Test POST -gnunet-identity -D "test_plugin_rest_identity" > /dev/null 2>&1 -gnunet-identity -D "test_plugin_rest_identity1" > /dev/null 2>&1 - -curl_post "${identity_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 201 Created" -curl_post "${identity_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 409" -curl_post "${identity_link}" '{"name":"Test_plugin_rest_identity"}' "HTTP/1.1 409" -curl_post "${identity_link}" '{}' "error" -curl_post "${identity_link}" '' "error" -curl_post "${identity_link}" '{"name":""}' "error" -curl_post "${identity_link}" '{"name":123}' "error" -curl_post "${identity_link}" '{"name":[]}' "error" -curl_post "${identity_link}" '{"name1":"test_plugin_rest_identity"}' "error" -curl_post "${identity_link}" '{"other":""}' "error" -curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1", "other":"test_plugin_rest_identity2"}' "error" - -#Test PUT -name="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $1}')" -public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')" - -curl_put "${identity_link}/pubkey/$public" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 204" -curl_put "${identity_link}/pubkey/$public" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 409" -curl_put "${identity_link}/pubkey/${public}xx" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404" -curl_put "${identity_link}/pubkey/" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404" -curl_put "${identity_link}/pubke" '{"newname":"test_plugin_rest_identity1"}' "error" -curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","other":"sdfdsf"}' "error" -curl_put "${identity_link}/pubkey/$name" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404" -curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"test_plugin_rest_identity"}' "HTTP/1.1 204" -curl_put "${identity_link}/pubkey/$public" '{"newnam":"test_plugin_rest_identity"}' "error" -curl_put "${identity_link}/name/test_plugin_rest_identity" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 204" -curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"TEST_plugin_rest_identity1"}' "HTTP/1.1 409" -curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 409" -curl_put "${identity_link}/name/test_plugin_rest_identityxxx" '{"newname":"test_plugin_rest_identity"}' "HTTP/1.1 404" -curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"test_plugin_rest_identity"}' "HTTP/1.1 204" -curl_put "${identity_link}/name/test_plugin_rest_identity" '{"newnam":"test_plugin_rest_identityfail"}' "error" - -#Test subsystem -curl_put "${identity_link}/subsystem/test_plugin_rest_identity" '{"subsystem":"namestore"}' "HTTP/1.1 204" -curl_put "${identity_link}/subsystem/test_plugin_rest_identity" '{"subsystem":"namestore"}' "HTTP/1.1 204" -curl_get "${identity_link}/subsystem/namestore" "test_plugin_rest_identity" -public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')" -curl_put "${identity_link}/subsystem/$public" '{"subsystem":"namestore"}' "HTTP/1.1 404" -curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created" -curl_get "${identity_link}/subsystem/test_plugin_rest_identity_no_subsystem" "error" -curl_put "${identity_link}/subsystem/test_plugin_rest_identity1" '{"subsystem":"test_plugin_rest_identity_no_subsystem"}' "HTTP/1.1 204" -curl_get "${identity_link}/subsystem/test_plugin_rest_identity_no_subsystem" "test_plugin_rest_identity1" - -curl_put "${identity_link}/subsystem/test_plugin_rest_identity1" '{"subsyste":"test_plugin_rest_identity_no_subsystem"}' "error" -curl_put "${identity_link}/subsystem/test_plugin_rest_identity1" '{"subsystem":"test_plugin_rest_identity_no_subsystem"}' "HTTP/1.1 204" - -#Test DELETE -curl_delete "${identity_link}/name/test_plugin_rest_identity" "HTTP/1.1 204" -curl_get "${identity_link}/name/test_plugin_rest_identity" "error" -curl_delete "${identity_link}/name/TEST_plugin_rest_identity1" "HTTP/1.1 204" -curl_delete "${identity_link}/name/test_plugin_rest_identity1" "HTTP/1.1 404" -curl_get "${identity_link}/name/test_plugin_rest_identity1" "error" -curl_delete "${identity_link}/name/test_plugin_rest_identity_not_found" "HTTP/1.1 404" -curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created" -public="$(gnunet-identity -d | grep "test_plugin_rest_identity1" | awk 'NR==1{print $3}')" -curl_delete "${identity_link}/pubkey/$public" "HTTP/1.1 204" -curl_delete "${identity_link}/pubke/$public" "error" -curl_delete "${identity_link}/pubkey/${public}other=232" "HTTP/1.1 404" - -#Test wrong_link -curl_get "$wrong_link" "HTTP/1.1 404" -curl_post "$wrong_link" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 404" -curl_put "$wrong_link/name/test_plugin_rest_identity" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404" -curl_delete "$wrong_link/name/test_plugin_rest_identity1" "HTTP/1.1 404" - -exit 0; diff --git a/src/namestore/test_plugin_rest_namestore.sh b/src/namestore/test_plugin_rest_namestore.sh deleted file mode 100755 index 532c7caae..000000000 --- a/src/namestore/test_plugin_rest_namestore.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/bash - -#First, start gnunet-arm and the rest-service. -#Exit 0 means success, exit 1 means failed test - -namestore_link="http://localhost:7776/namestore" -wrong_link="http://localhost:7776/namestoreandmore" - - -curl_get () { - #$1 is link - #$2 is grep - cache="$(curl -v "$1" 2>&1 | grep "$2")" - echo $cache - if [ "" == "$cache" ] - then - exit 1 - fi -} - -curl_post () { - #$1 is link - #$2 is data - #$3 is grep - cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")" - echo $cache - if [ "" == "$cache" ] - then - exit 1 - fi -} - -curl_delete () { - #$1 is link - #$2 is grep - cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")" - echo $cache - if [ "" == "$cache" ] - then - exit 1 - fi -} - -# curl_put () { -# #$1 is link -# #$2 is data -# #$3 is grep -# cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")" -# #echo $cache -# if [ "" == "$cache" ] -# then -# exit 1 -# fi -# } - -#Test subsystem default identity - -#Test GET -gnunet-identity -D "test_plugin_rest_namestore" -gnunet-identity -C "test_plugin_rest_namestore" -test="$(gnunet-namestore -D -z "test_plugin_rest_namestore")" -name="test_plugin_rest_namestore" -public="$(gnunet-identity -d | grep "test_plugin_rest_namestore" | awk 'NR==1{print $3}')" -if [ "" == "$test" ] -then - #if no entries for test_plugin_rest_namestore - curl_get "${namestore_link}/$name" "error" - curl_get "${namestore_link}/" "error" - curl_get "${namestore_link}/$public" "error" -else - #if entries exists (that should not be possible) - curl_get "${namestore_link}" "HTTP/1.1 200 OK" - curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK" - curl_get "${namestore_link}/" "error" - curl_get "${namestore_link}/$public" "error" -fi -gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" -curl_get "${namestore_link}" "HTTP/1.1 200 OK" -curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK" -curl_get "${namestore_link}/" "error" -curl_get "${namestore_link}/$public" "error" -gnunet-namestore -z $name -d -n "test_entry" - -#Test POST with NAME -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -#value -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value_missing":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -#time -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"0d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"10000d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"now","flag":0,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"","flag":0,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time_missing":"1d","flag":0,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -#flag -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":2,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":8,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":16,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":-1,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":"Test","record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag_missing":0,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -#record_name -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":""}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 -curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name_missing":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 - -#wrong zone -curl_post "${namestore_link}/$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error" -gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 - -#Test DELETE -gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" -curl_delete "${namestore_link}/$name?record_name=test_entry" "HTTP/1.1 204" -curl_delete "${namestore_link}/$name?record_name=test_entry" "error" -gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" -curl_delete "${namestore_link}/$public?record_name=test_entry" "error" - - -#Test default identity -#not possible without defining - -exit 0; - diff --git a/src/rest-plugins/plugin_rest_namestore.c b/src/rest-plugins/plugin_rest_namestore.c index 1d72d13ff..2926f4b90 100644 --- a/src/rest-plugins/plugin_rest_namestore.c +++ b/src/rest-plugins/plugin_rest_namestore.c @@ -458,10 +458,7 @@ namestore_list_finished (void *cls) handle->list_it = NULL; if (NULL == handle->resp_object) - { - GNUNET_SCHEDULER_add_now (&do_error, handle); - return; - } + handle->resp_object = json_array(); result_str = json_dumps (handle->resp_object, 0); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); @@ -508,6 +505,48 @@ namestore_list_iteration (void *cls, GNUNET_NAMESTORE_zone_iterator_next (handle->list_it, 1); } +/** + * @param cls closure + * @param ego ego handle + * @param ctx context for application to store data for this ego + * (during the lifetime of this process, initially NULL) + * @param identifier identifier assigned by the user for this ego, + * NULL if the user just deleted the ego and it + * must thus no longer be used + */ +static void +default_ego_get (void *cls, + struct GNUNET_IDENTITY_Ego *ego, + void **ctx, + const char *identifier) +{ + struct RequestHandle *handle = cls; + handle->op = NULL; + + if (ego == NULL) + { + handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } + handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego); + + handle->list_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle, + handle->zone_pkey, + &namestore_iteration_error, + handle, + &namestore_list_iteration, + handle, + &namestore_list_finished, + handle); + if (NULL == handle->list_it) + { + handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } +} + /** * Handle namestore GET request @@ -546,10 +585,13 @@ namestore_get (struct GNUNET_REST_RequestHandle *con_handle, { handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); } + if (NULL == handle->zone_pkey) { - handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE); - GNUNET_SCHEDULER_add_now (&do_error, handle); + handle->op = GNUNET_IDENTITY_get (handle->identity_handle, + "namestore", + &default_ego_get, + handle); return; } handle->list_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle, @@ -569,6 +611,48 @@ namestore_get (struct GNUNET_REST_RequestHandle *con_handle, } +/** + * @param cls closure + * @param ego ego handle + * @param ctx context for application to store data for this ego + * (during the lifetime of this process, initially NULL) + * @param identifier identifier assigned by the user for this ego, + * NULL if the user just deleted the ego and it + * must thus no longer be used + */ +static void +default_ego_post (void *cls, + struct GNUNET_IDENTITY_Ego *ego, + void **ctx, + const char *identifier) +{ + struct RequestHandle *handle = cls; + handle->op = NULL; + + if (ego == NULL) + { + handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } + handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego); + + handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle, + handle->zone_pkey, + handle->record_name, + 1, + handle->rd, + &create_finished, + handle); + if (NULL == handle->add_qe) + { + handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } +} + + /** * Handle namestore POST request * @@ -662,18 +746,62 @@ namestore_add (struct GNUNET_REST_RequestHandle *con_handle, handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); } if (NULL == handle->zone_pkey) + { + handle->op = GNUNET_IDENTITY_get (handle->identity_handle, + "namestore", + &default_ego_post, + handle); + return; + } + handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle, + handle->zone_pkey, + handle->record_name, + 1, + handle->rd, + &create_finished, + handle); + if (NULL == handle->add_qe) + { + handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED); + GNUNET_SCHEDULER_add_now (&do_error, handle); + return; + } +} + + +/** + * @param cls closure + * @param ego ego handle + * @param ctx context for application to store data for this ego + * (during the lifetime of this process, initially NULL) + * @param identifier identifier assigned by the user for this ego, + * NULL if the user just deleted the ego and it + * must thus no longer be used + */ +static void +default_ego_delete (void *cls, + struct GNUNET_IDENTITY_Ego *ego, + void **ctx, + const char *identifier) +{ + struct RequestHandle *handle = cls; + handle->op = NULL; + + if (ego == NULL) { handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE); GNUNET_SCHEDULER_add_now (&do_error, handle); return; } + handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego); + handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle, - handle->zone_pkey, - handle->record_name, - 1, - handle->rd, - &create_finished, - handle); + handle->zone_pkey, + handle->record_name, + 0, + NULL, + &del_finished, + handle); if (NULL == handle->add_qe) { handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED); @@ -736,8 +864,10 @@ namestore_delete (struct GNUNET_REST_RequestHandle *con_handle, if (NULL == handle->zone_pkey) { - handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE); - GNUNET_SCHEDULER_add_now (&do_error, handle); + handle->op = GNUNET_IDENTITY_get (handle->identity_handle, + "namestore", + &default_ego_delete, + handle); return; } @@ -811,30 +941,6 @@ init_cont (struct RequestHandle *handle) } } -/** - * @param cls closure - * @param ego ego handle - * @param ctx context for application to store data for this ego - * (during the lifetime of this process, initially NULL) - * @param identifier identifier assigned by the user for this ego, - * NULL if the user just deleted the ego and it - * must thus no longer be used - */ -static void -default_ego_cb (void *cls, - struct GNUNET_IDENTITY_Ego *ego, - void **ctx, - const char *identifier) -{ - struct RequestHandle *handle = cls; - handle->op = NULL; - - if (ego != NULL) - { - handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego); - } -} - /** * This function is initially called for all egos and then again @@ -877,17 +983,10 @@ id_connect_cb (void *cls, struct EgoEntry *ego_entry; struct GNUNET_CRYPTO_EcdsaPublicKey pk; - if ((NULL == ego) && (NULL == handle->zone_pkey)) - { - handle->op = GNUNET_IDENTITY_get (handle->identity_handle, - "namestore", - &default_ego_cb, - handle); - } if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state)) { handle->state = ID_REST_STATE_POST_INIT; - init_cont (handle); + init_cont(handle); return; } if (ID_REST_STATE_INIT == handle->state) @@ -934,8 +1033,8 @@ rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle, handle->url[strlen (handle->url)-1] = '\0'; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); - handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, handle); handle->ns_handle = GNUNET_NAMESTORE_connect (cfg); + handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, handle); handle->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, diff --git a/src/rest-plugins/test_plugin_rest_gns.sh b/src/rest-plugins/test_plugin_rest_gns.sh new file mode 100755 index 000000000..ec495a04b --- /dev/null +++ b/src/rest-plugins/test_plugin_rest_gns.sh @@ -0,0 +1,50 @@ +#!/usr/bin/bash + +#First, start gnunet-arm and the rest-service. +#Exit 0 means success, exit 1 means failed test + +gns_link="http://localhost:7776/gns" +wrong_link="http://localhost:7776/gnsandmore" + +curl_get () { + #$1 is link + #$2 is grep + cache="$(curl -v "$1" 2>&1 | grep "$2")" + #echo $cache + if [ "" == "$cache" ] + then + exit 1 + fi +} + +gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 + +curl_get "$gns_link/www.test_plugin_rest_gns" "error" + +gnunet-identity -C "test_plugin_rest_gns" + +curl_get "$gns_link/www.test_plugin_rest_gns" "\[\]" + +gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.1 -t A + +curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.1" + +gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1::1 -t AAAA + +curl_get "$gns_link/www.test_plugin_rest_gns" "1::1.*1.1.1.1" + +gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.2 -t A + +curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.2.*1::1.*1.1.1.1" +curl_get "$gns_link/www.test_plugin_rest_gns?record_type=A" "1.1.1.2.*1.1.1.1" +curl_get "$gns_link/www.test_plugin_rest_gns?record_type=AAAA" "1::1" +curl_get "$gns_link/www.test_plugin_rest_gns?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1" + +gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www1 -e 1d -V 1.1.1.1 -t A +curl_get "$gns_link/www1.test_plugin_rest_gns" "1.1.1.1" + +gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 + +curl_get "$gns_link/www1.test_plugin_rest_gns" "error" + +exit 0 diff --git a/src/rest-plugins/test_plugin_rest_identity.sh b/src/rest-plugins/test_plugin_rest_identity.sh new file mode 100755 index 000000000..a5879dd7e --- /dev/null +++ b/src/rest-plugins/test_plugin_rest_identity.sh @@ -0,0 +1,157 @@ +#!/usr/bin/bash + +#First, start gnunet-arm and the rest-service. +#Exit 0 means success, exit 1 means failed test + +identity_link="http://localhost:7776/identity" +wrong_link="http://localhost:7776/identityandmore" + + +curl_get () { + #$1 is link + #$2 is grep + cache="$(curl -v "$1" 2>&1 | grep "$2")" + #echo $cache + if [ "" == "$cache" ] + then + exit 1 + fi +} + +curl_post () { + #$1 is link + #$2 is data + #$3 is grep + cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")" + #echo $cache + if [ "" == "$cache" ] + then + exit 1 + fi +} + +curl_delete () { + #$1 is link + #$2 is grep + cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")" + #echo $cache + if [ "" == "$cache" ] + then + exit 1 + fi +} + +curl_put () { + #$1 is link + #$2 is data + #$3 is grep + cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")" + #echo $cache + if [ "" == "$cache" ] + then + exit 1 + fi +} + +#Test GET +test="$(gnunet-identity -d)" +#if no identity exists +if [ "" == "$test" ] +then + curl_get "$identity_link/all" "error" + gnunet-identity -C "test_plugin_rest_identity" + name="$(gnunet-identity -d | awk 'NR==1{print $1}')" + public="$(gnunet-identity -d | awk 'NR==1{print $3}')" + + curl_get "${identity_link}/name/$name" "$public" + curl_get "${identity_link}/name/$public" "error" + curl_get "${identity_link}/name/" "error" + + curl_get "${identity_link}/pubkey/$public" "$name" + curl_get "${identity_link}/pubkey/$name" "error" + curl_get "${identity_link}/pubkey/" "error" + + gnunet-identity -D "test_plugin_rest_identity" +else + name="$(gnunet-identity -d | awk 'NR==1{print $1}')" + public="$(gnunet-identity -d | awk 'NR==1{print $3}')" + + curl_get "${identity_link}/name/$name" "$public" + curl_get "${identity_link}/name/$public" "error" + curl_get "${identity_link}/name/" "error" + + curl_get "${identity_link}/pubkey/$public" "$name" + curl_get "${identity_link}/pubkey/$name" "error" + curl_get "${identity_link}/pubkey/" "error" +fi + +#Test POST +gnunet-identity -D "test_plugin_rest_identity" > /dev/null 2>&1 +gnunet-identity -D "test_plugin_rest_identity1" > /dev/null 2>&1 + +curl_post "${identity_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 201 Created" +curl_post "${identity_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 409" +curl_post "${identity_link}" '{"name":"Test_plugin_rest_identity"}' "HTTP/1.1 409" +curl_post "${identity_link}" '{}' "error" +curl_post "${identity_link}" '' "error" +curl_post "${identity_link}" '{"name":""}' "error" +curl_post "${identity_link}" '{"name":123}' "error" +curl_post "${identity_link}" '{"name":[]}' "error" +curl_post "${identity_link}" '{"name1":"test_plugin_rest_identity"}' "error" +curl_post "${identity_link}" '{"other":""}' "error" +curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1", "other":"test_plugin_rest_identity2"}' "error" + +#Test PUT +name="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $1}')" +public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')" + +curl_put "${identity_link}/pubkey/$public" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 204" +curl_put "${identity_link}/pubkey/$public" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 409" +curl_put "${identity_link}/pubkey/${public}xx" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404" +curl_put "${identity_link}/pubkey/" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404" +curl_put "${identity_link}/pubke" '{"newname":"test_plugin_rest_identity1"}' "error" +curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","other":"sdfdsf"}' "error" +curl_put "${identity_link}/pubkey/$name" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404" +curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"test_plugin_rest_identity"}' "HTTP/1.1 204" +curl_put "${identity_link}/pubkey/$public" '{"newnam":"test_plugin_rest_identity"}' "error" +curl_put "${identity_link}/name/test_plugin_rest_identity" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 204" +curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"TEST_plugin_rest_identity1"}' "HTTP/1.1 409" +curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 409" +curl_put "${identity_link}/name/test_plugin_rest_identityxxx" '{"newname":"test_plugin_rest_identity"}' "HTTP/1.1 404" +curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"test_plugin_rest_identity"}' "HTTP/1.1 204" +curl_put "${identity_link}/name/test_plugin_rest_identity" '{"newnam":"test_plugin_rest_identityfail"}' "error" + +#Test subsystem +curl_put "${identity_link}/subsystem/test_plugin_rest_identity" '{"subsystem":"namestore"}' "HTTP/1.1 204" +curl_put "${identity_link}/subsystem/test_plugin_rest_identity" '{"subsystem":"namestore"}' "HTTP/1.1 204" +curl_get "${identity_link}/subsystem/namestore" "test_plugin_rest_identity" +public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')" +curl_put "${identity_link}/subsystem/$public" '{"subsystem":"namestore"}' "HTTP/1.1 404" +curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created" +curl_get "${identity_link}/subsystem/test_plugin_rest_identity_no_subsystem" "error" +curl_put "${identity_link}/subsystem/test_plugin_rest_identity1" '{"subsystem":"test_plugin_rest_identity_no_subsystem"}' "HTTP/1.1 204" +curl_get "${identity_link}/subsystem/test_plugin_rest_identity_no_subsystem" "test_plugin_rest_identity1" + +curl_put "${identity_link}/subsystem/test_plugin_rest_identity1" '{"subsyste":"test_plugin_rest_identity_no_subsystem"}' "error" +curl_put "${identity_link}/subsystem/test_plugin_rest_identity1" '{"subsystem":"test_plugin_rest_identity_no_subsystem"}' "HTTP/1.1 204" + +#Test DELETE +curl_delete "${identity_link}/name/test_plugin_rest_identity" "HTTP/1.1 204" +curl_get "${identity_link}/name/test_plugin_rest_identity" "error" +curl_delete "${identity_link}/name/TEST_plugin_rest_identity1" "HTTP/1.1 204" +curl_delete "${identity_link}/name/test_plugin_rest_identity1" "HTTP/1.1 404" +curl_get "${identity_link}/name/test_plugin_rest_identity1" "error" +curl_delete "${identity_link}/name/test_plugin_rest_identity_not_found" "HTTP/1.1 404" +curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created" +public="$(gnunet-identity -d | grep "test_plugin_rest_identity1" | awk 'NR==1{print $3}')" +curl_delete "${identity_link}/pubkey/$public" "HTTP/1.1 204" +curl_delete "${identity_link}/pubke/$public" "error" +curl_delete "${identity_link}/pubkey/${public}other=232" "HTTP/1.1 404" + +#Test wrong_link +curl_get "$wrong_link" "HTTP/1.1 404" +curl_post "$wrong_link" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 404" +curl_put "$wrong_link/name/test_plugin_rest_identity" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404" +curl_delete "$wrong_link/name/test_plugin_rest_identity1" "HTTP/1.1 404" + +exit 0; diff --git a/src/rest-plugins/test_plugin_rest_namestore.sh b/src/rest-plugins/test_plugin_rest_namestore.sh new file mode 100755 index 000000000..532c7caae --- /dev/null +++ b/src/rest-plugins/test_plugin_rest_namestore.sh @@ -0,0 +1,147 @@ +#!/usr/bin/bash + +#First, start gnunet-arm and the rest-service. +#Exit 0 means success, exit 1 means failed test + +namestore_link="http://localhost:7776/namestore" +wrong_link="http://localhost:7776/namestoreandmore" + + +curl_get () { + #$1 is link + #$2 is grep + cache="$(curl -v "$1" 2>&1 | grep "$2")" + echo $cache + if [ "" == "$cache" ] + then + exit 1 + fi +} + +curl_post () { + #$1 is link + #$2 is data + #$3 is grep + cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")" + echo $cache + if [ "" == "$cache" ] + then + exit 1 + fi +} + +curl_delete () { + #$1 is link + #$2 is grep + cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")" + echo $cache + if [ "" == "$cache" ] + then + exit 1 + fi +} + +# curl_put () { +# #$1 is link +# #$2 is data +# #$3 is grep +# cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")" +# #echo $cache +# if [ "" == "$cache" ] +# then +# exit 1 +# fi +# } + +#Test subsystem default identity + +#Test GET +gnunet-identity -D "test_plugin_rest_namestore" +gnunet-identity -C "test_plugin_rest_namestore" +test="$(gnunet-namestore -D -z "test_plugin_rest_namestore")" +name="test_plugin_rest_namestore" +public="$(gnunet-identity -d | grep "test_plugin_rest_namestore" | awk 'NR==1{print $3}')" +if [ "" == "$test" ] +then + #if no entries for test_plugin_rest_namestore + curl_get "${namestore_link}/$name" "error" + curl_get "${namestore_link}/" "error" + curl_get "${namestore_link}/$public" "error" +else + #if entries exists (that should not be possible) + curl_get "${namestore_link}" "HTTP/1.1 200 OK" + curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK" + curl_get "${namestore_link}/" "error" + curl_get "${namestore_link}/$public" "error" +fi +gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" +curl_get "${namestore_link}" "HTTP/1.1 200 OK" +curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK" +curl_get "${namestore_link}/" "error" +curl_get "${namestore_link}/$public" "error" +gnunet-namestore -z $name -d -n "test_entry" + +#Test POST with NAME +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +#value +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value_missing":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +#time +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"0d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"10000d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"now","flag":0,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"","flag":0,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time_missing":"1d","flag":0,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +#flag +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":2,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":8,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":16,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":-1,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":"Test","record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag_missing":0,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +#record_name +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":""}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 +curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name_missing":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 + +#wrong zone +curl_post "${namestore_link}/$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error" +gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 + +#Test DELETE +gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" +curl_delete "${namestore_link}/$name?record_name=test_entry" "HTTP/1.1 204" +curl_delete "${namestore_link}/$name?record_name=test_entry" "error" +gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" +curl_delete "${namestore_link}/$public?record_name=test_entry" "error" + + +#Test default identity +#not possible without defining + +exit 0; + -- cgit v1.2.3