2 trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
4 LOCATION=$(which gnunet-config)
7 LOCATION="gnunet-config"
9 $LOCATION --version 1> /dev/null
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
16 rm -rf `gnunet-config -c test_namestore_api.conf -f -s paths -o GNUNET_TEST_HOME`
18 namestore_link="http://localhost:7776/namestore"
19 wrong_link="http://localhost:7776/namestoreandmore"
25 resp=$(curl -v "$1" 2>&1)
26 cache="$(echo $resp | grep "$2")"
30 echo "Error in get response: $resp, expected $2"
31 gnunet-arm -e -c test_namestore_api.conf
40 resp=$(curl -v -X "POST" "$1" --data "$2" 2>&1)
41 cache="$(echo $resp | grep "$3")"
45 echo "Error in post response: $resp ($2), expected $3"
46 gnunet-arm -e -c test_namestore_api.conf
54 resp=$(curl -v -X "DELETE" "$1" 2>&1)
55 cache="$(echo $resp | grep "$2")"
59 echo "Error in delete response: $resp, expected $2"
60 gnunet-arm -e -c test_namestore_api.conf
69 # cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")"
71 # if [ "" == "$cache" ]
77 #Test subsystem default identity
80 gnunet-arm -s -c test_namestore_api.conf
81 gnunet-arm -i rest -c test_namestore_api.conf
83 gnunet-identity -C $TEST_ID -c test_namestore_api.conf
84 test="$(gnunet-namestore -D -z $TEST_ID -c test_namestore_api.conf)"
86 public="$(gnunet-identity -d -c test_namestore_api.conf | grep $TEST_ID | awk 'NR==1{print $3}')"
87 gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" -c test_namestore_api.conf
88 curl_get "${namestore_link}" "HTTP/1.1 200 OK"
89 curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK"
90 curl_get "${namestore_link}/$public" "error"
91 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf
94 curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0}],"record_name":"test_entry"}' "HTTP/1.1 204 No Content"
95 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
98 curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "record_type":"PKEY", "expiration_time":"1d","flag":0}],"record_name":"test_entry"}' "error"
99 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
102 curl_post "${namestore_link}/$name" '{"data": [{"value":"", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name"}]:"test_entry"}' "error"
103 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
105 curl_post "${namestore_link}/$name" '{"data": [{"record_type":"PKEY", "expiration_time":"1d","flag":0}],"record_name":"test_entry"}' "error"
106 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
109 curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"0d","flag":0}],"record_name":"test_entry"}' "HTTP/1.1 204"
110 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
112 curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"10000d","flag":0}],"record_name":"test_entry"}' "HTTP/1.1 204"
113 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
115 curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"now","flag":0}],"record_name":"test_entry"}' "error"
116 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
118 curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time_missing":"1d","flag":0}],"record_name":"test_entry"}' "error"
119 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":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0}],"record_name":""}' "error"
123 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
124 curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0}],"record_name_missing":"test_entry"}' "error"
125 gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
128 gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" -c test_namestore_api.conf
129 curl_delete "${namestore_link}/$name?record_name=test_entry" "HTTP/1.1 204"
130 curl_delete "${namestore_link}/$name?record_name=test_entry" "error"
131 gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" -c test_namestore_api.conf
132 curl_delete "${namestore_link}/$public?record_name=test_entry" "error"
134 gnunet-arm -e -c test_namestore_api.conf