diff options
author | Phil <phil.buschmann@tum.de> | 2018-08-08 23:24:10 +0200 |
---|---|---|
committer | Phil <phil.buschmann@tum.de> | 2018-08-08 23:24:10 +0200 |
commit | 0d239903075f518edef85277f13d1b5d303443bf (patch) | |
tree | 915dd42806aee47625ffed4bce82be9476e5bd36 /src/namestore/test_plugin_rest_namestore.sh | |
parent | 9eb2df3407246f984f0d85af338bff872d5e6fba (diff) | |
download | gnunet-0d239903075f518edef85277f13d1b5d303443bf.tar.gz gnunet-0d239903075f518edef85277f13d1b5d303443bf.zip |
Namestore Rest API finished
Diffstat (limited to 'src/namestore/test_plugin_rest_namestore.sh')
-rwxr-xr-x | src/namestore/test_plugin_rest_namestore.sh | 78 |
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 | |||
197 | curl_delete "${namestore_link}?label=test_entry&name=$name" "HTTP/1.1 204" | 197 | curl_delete "${namestore_link}?label=test_entry&name=$name" "HTTP/1.1 204" |
198 | gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" | 198 | gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" |
199 | curl_delete "${namestore_link}?label=test_entry&pubkey=$public" "HTTP/1.1 204" | 199 | curl_delete "${namestore_link}?label=test_entry&pubkey=$public" "HTTP/1.1 204" |
200 | gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" | ||
201 | curl_delete "${namestore_link}?label=test_entry&pubkey=$name" "HTTP/1.1 404" | ||
200 | 202 | ||
201 | exit 0; | ||
202 | |||
203 | |||
204 | |||
205 | #pubkey zone | ||
206 | #name zone | ||
207 | curl_post "${namestore_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 201 Created" | ||
208 | curl_post "${namestore_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 409" | ||
209 | curl_post "${namestore_link}" '{"name":"Test_plugin_rest_identity"}' "HTTP/1.1 409" | ||
210 | curl_post "${namestore_link}" '{}' "error" | ||
211 | curl_post "${namestore_link}" '' "error" | ||
212 | curl_post "${namestore_link}" '{"name":""}' "error" | ||
213 | curl_post "${namestore_link}" '{"name":123}' "error" | ||
214 | curl_post "${namestore_link}" '{"name":[]}' "error" | ||
215 | curl_post "${namestore_link}" '{"name1":"test_plugin_rest_identity"}' "error" | ||
216 | curl_post "${namestore_link}" '{"other":""}' "error" | ||
217 | curl_post "${namestore_link}" '{"name":"test_plugin_rest_identity1", "other":"test_plugin_rest_identity2"}' "error" | ||
218 | |||
219 | #Test PUT | ||
220 | name="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $1}')" | ||
221 | public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')" | ||
222 | |||
223 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'"}' "HTTP/1.1 204" | ||
224 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'"}' "HTTP/1.1 409" | ||
225 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'xx"}' "HTTP/1.1 404" | ||
226 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":""}' "HTTP/1.1 404" | ||
227 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubke":""}' "HTTP/1.1 404" | ||
228 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubke":"","other":"sdfdsf"}' "HTTP/1.1 404" | ||
229 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubke":"","name":"sdfdsf"}' "HTTP/1.1 404" | ||
230 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity","pubke":"","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204" | ||
231 | curl_put "${namestore_link}" '{"newnam":"test_plugin_rest_identity","pubkey":"'$public'"}' "error" | ||
232 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","name":"test_plugin_rest_identity"}' "HTTP/1.1 204" | ||
233 | curl_put "${namestore_link}" '{"newname":"TEST_plugin_rest_identity1","name":"test_plugin_rest_identity1"}' "HTTP/1.1 409" | ||
234 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","name":"test_plugin_rest_identity1"}' "HTTP/1.1 409" | ||
235 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity","name":"test_plugin_rest_identityxxx"}' "HTTP/1.1 404" | ||
236 | curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204" | ||
237 | curl_put "${namestore_link}" '{"newnam":"test_plugin_rest_identityfail","name":"test_plugin_rest_identity"}' "error" | ||
238 | |||
239 | |||
240 | #Test subsystem | ||
241 | curl_put "${identity_link}" '{"subsystem":"namestore","name":"test_plugin_rest_identity"}' "HTTP/1.1 204" | ||
242 | curl_put "${identity_link}" '{"subsystem":"namestore","name":"test_plugin_rest_identity"}' "HTTP/1.1 204" | ||
243 | curl_get "${identity_link}?subsystem=namestore" "test_plugin_rest_identity" | ||
244 | curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created" | ||
245 | public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')" | ||
246 | curl_put "${identity_link}" '{"subsystem":"namestore","pubkey":"'"$public"'"}' "HTTP/1.1 204" | ||
247 | curl_get "${identity_link}?subsystem=namestore" "test_plugin_rest_identity1" | ||
248 | curl_get "${identity_link}?subsystem=test_plugin_rest_identity_no_subsystem" "error" | ||
249 | curl_put "${identity_link}" '{"subsystem":"test_plugin_rest_identity_no_subsystem","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204" | ||
250 | curl_get "${identity_link}?subsystem=test_plugin_rest_identity_no_subsystem" "test_plugin_rest_identity1" | ||
251 | |||
252 | curl_put "${identity_link}" '{"subsyste":"test_plugin_rest_identity_no_subsystem","name":"test_plugin_rest_identity1"}' "error" | ||
253 | curl_put "${identity_link}" '{"subsystem":"test_plugin_rest_identity_no_subsystem","name":"Test_plugin_rest_identity1"}' "HTTP/1.1 204" | ||
254 | |||
255 | #Test DELETE | ||
256 | curl_delete "${identity_link}?name=test_plugin_rest_identity" "HTTP/1.1 204" | ||
257 | curl_get "${identity_link}?name=test_plugin_rest_identity" "error" | ||
258 | curl_delete "${identity_link}?name=TEST_plugin_rest_identity1" "HTTP/1.1 404" | ||
259 | curl_delete "${identity_link}?name=test_plugin_rest_identity1" "HTTP/1.1 204" | ||
260 | curl_get "${identity_link}?name=test_plugin_rest_identity1" "error" | ||
261 | curl_delete "${identity_link}?name=test_plugin_rest_identity_not_found" "HTTP/1.1 404" | ||
262 | curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created" | ||
263 | public="$(gnunet-identity -d | grep "test_plugin_rest_identity1" | awk 'NR==1{print $3}')" | ||
264 | curl_delete "${identity_link}?pubkey=$public" "HTTP/1.1 204" | ||
265 | curl_delete "${identity_link}?pubke=$public" "error" | ||
266 | curl_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 | ||
270 | exit 0; | 207 | exit 0; |
208 | |||