diff options
author | Phil <phil.buschmann@tum.de> | 2018-08-08 03:59:08 +0200 |
---|---|---|
committer | Phil <phil.buschmann@tum.de> | 2018-08-08 03:59:08 +0200 |
commit | 9eb2df3407246f984f0d85af338bff872d5e6fba (patch) | |
tree | 9284695f8d44784308cdca7ffb1eb0d7a3e9201f /src/namestore/test_plugin_rest_namestore.sh | |
parent | 65f9785e7752b6d73e2ad8c6ff2735336ad5baa6 (diff) | |
download | gnunet-9eb2df3407246f984f0d85af338bff872d5e6fba.tar.gz gnunet-9eb2df3407246f984f0d85af338bff872d5e6fba.zip |
-wip namestore
Diffstat (limited to 'src/namestore/test_plugin_rest_namestore.sh')
-rwxr-xr-x | src/namestore/test_plugin_rest_namestore.sh | 270 |
1 files changed, 270 insertions, 0 deletions
diff --git a/src/namestore/test_plugin_rest_namestore.sh b/src/namestore/test_plugin_rest_namestore.sh new file mode 100755 index 000000000..7c1e97397 --- /dev/null +++ b/src/namestore/test_plugin_rest_namestore.sh | |||
@@ -0,0 +1,270 @@ | |||
1 | #!/usr/bin/bash | ||
2 | |||
3 | #First, start gnunet-arm and the rest-service. | ||
4 | #Exit 0 means success, exit 1 means failed test | ||
5 | |||
6 | namestore_link="http://localhost:7776/namestore" | ||
7 | wrong_link="http://localhost:7776/namestoreandmore" | ||
8 | |||
9 | |||
10 | curl_get () { | ||
11 | #$1 is link | ||
12 | #$2 is grep | ||
13 | cache="$(curl -v "$1" 2>&1 | grep "$2")" | ||
14 | echo $cache | ||
15 | if [ "" == "$cache" ] | ||
16 | then | ||
17 | exit 1 | ||
18 | fi | ||
19 | } | ||
20 | |||
21 | curl_post () { | ||
22 | #$1 is link | ||
23 | #$2 is data | ||
24 | #$3 is grep | ||
25 | cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")" | ||
26 | echo $cache | ||
27 | if [ "" == "$cache" ] | ||
28 | then | ||
29 | exit 1 | ||
30 | fi | ||
31 | } | ||
32 | |||
33 | curl_delete () { | ||
34 | #$1 is link | ||
35 | #$2 is grep | ||
36 | cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")" | ||
37 | echo $cache | ||
38 | if [ "" == "$cache" ] | ||
39 | then | ||
40 | exit 1 | ||
41 | fi | ||
42 | } | ||
43 | |||
44 | # curl_put () { | ||
45 | # #$1 is link | ||
46 | # #$2 is data | ||
47 | # #$3 is grep | ||
48 | # cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")" | ||
49 | # #echo $cache | ||
50 | # if [ "" == "$cache" ] | ||
51 | # then | ||
52 | # exit 1 | ||
53 | # fi | ||
54 | # } | ||
55 | |||
56 | #Test subsystem default identity | ||
57 | |||
58 | #Test GET | ||
59 | gnunet-identity -D "test_plugin_rest_namestore" | ||
60 | gnunet-identity -C "test_plugin_rest_namestore" | ||
61 | test="$(gnunet-namestore -D -z "test_plugin_rest_namestore")" | ||
62 | name="test_plugin_rest_namestore" | ||
63 | public="$(gnunet-identity -d | grep "test_plugin_rest_namestore" | awk 'NR==1{print $3}')" | ||
64 | if [ "" == "$test" ] | ||
65 | then | ||
66 | #if no entries for test_plugin_rest_namestore | ||
67 | curl_get "${namestore_link}?name=$name" "error" | ||
68 | curl_get "${namestore_link}?name=" "error" | ||
69 | curl_get "${namestore_link}?name=$public" "error" | ||
70 | |||
71 | curl_get "${namestore_link}?pubkey=$public" "error" | ||
72 | curl_get "${namestore_link}?pubkey=$name" "error" | ||
73 | curl_get "${namestore_link}?pubkey=" "error" | ||
74 | else | ||
75 | #if entries exists (that should not be possible) | ||
76 | curl_get "${namestore_link}" "HTTP/1.1 200 OK" | ||
77 | curl_get "${namestore_link}?name=$name" "HTTP/1.1 200 OK" | ||
78 | curl_get "${namestore_link}?name=" "error" | ||
79 | curl_get "${namestore_link}?name=$public" "error" | ||
80 | |||
81 | curl_get "${namestore_link}?pubkey=$public" "HTTP/1.1 200 OK" | ||
82 | curl_get "${namestore_link}?pubkey=$name" "error" | ||
83 | curl_get "${namestore_link}?pubkey=" "error" | ||
84 | fi | ||
85 | gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" | ||
86 | curl_get "${namestore_link}" "HTTP/1.1 200 OK" | ||
87 | curl_get "${namestore_link}?name=$name" "HTTP/1.1 200 OK" | ||
88 | curl_get "${namestore_link}?name=" "error" | ||
89 | curl_get "${namestore_link}?name=$public" "error" | ||
90 | curl_get "${namestore_link}?pubkey=$public" "HTTP/1.1 200 OK" | ||
91 | curl_get "${namestore_link}?pubkey=$name" "error" | ||
92 | curl_get "${namestore_link}?pubkey=" "error" | ||
93 | gnunet-namestore -z $name -d -n "test_entry" | ||
94 | |||
95 | #Test POST with NAME | ||
96 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
97 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
98 | #value | ||
99 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error" | ||
100 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
101 | curl_post "${namestore_link}?name=$name" '{"value":"", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error" | ||
102 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
103 | curl_post "${namestore_link}?name=$name" '{"value_missing":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error" | ||
104 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
105 | #time | ||
106 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"0d","flag":0,"label":"test_entry"}' "HTTP/1.1 204" | ||
107 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
108 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"10000d","flag":0,"label":"test_entry"}' "HTTP/1.1 204" | ||
109 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
110 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"now","flag":0,"label":"test_entry"}' "error" | ||
111 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
112 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"","flag":0,"label":"test_entry"}' "error" | ||
113 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
114 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time_missing":"1d","flag":0,"label":"test_entry"}' "error" | ||
115 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
116 | #flag | ||
117 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
118 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
119 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":2,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
120 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
121 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":8,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
122 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
123 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":16,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
124 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
125 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":-1,"label":"test_entry"}' "error" | ||
126 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
127 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":"Test","label":"test_entry"}' "error" | ||
128 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
129 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":,"label":"test_entry"}' "error" | ||
130 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
131 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag_missing":0,"label":"test_entry"}' "error" | ||
132 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
133 | #label | ||
134 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
135 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 409" | ||
136 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
137 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":""}' "error" | ||
138 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
139 | curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label_missing":"test_entry"}' "error" | ||
140 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
141 | |||
142 | #Test POST with PUBKEY | ||
143 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
144 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
145 | #value | ||
146 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error" | ||
147 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
148 | curl_post "${namestore_link}?pubkey=$public" '{"value":"", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error" | ||
149 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
150 | curl_post "${namestore_link}?pubkey=$public" '{"value_missing":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error" | ||
151 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
152 | #time | ||
153 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"0d","flag":0,"label":"test_entry"}' "HTTP/1.1 204" | ||
154 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
155 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"10000d","flag":0,"label":"test_entry"}' "HTTP/1.1 204" | ||
156 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
157 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"now","flag":0,"label":"test_entry"}' "error" | ||
158 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
159 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"","flag":0,"label":"test_entry"}' "error" | ||
160 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
161 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time_missing":"1d","flag":0,"label":"test_entry"}' "error" | ||
162 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
163 | #flag | ||
164 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
165 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
166 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":2,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
167 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
168 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":8,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
169 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
170 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":16,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
171 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
172 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":-1,"label":"test_entry"}' "error" | ||
173 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
174 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":"Test","label":"test_entry"}' "error" | ||
175 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
176 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":,"label":"test_entry"}' "error" | ||
177 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
178 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag_missing":0,"label":"test_entry"}' "error" | ||
179 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
180 | #label | ||
181 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content" | ||
182 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 409" | ||
183 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
184 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":""}' "error" | ||
185 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
186 | curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label_missing":"test_entry"}' "error" | ||
187 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
188 | |||
189 | #wrong zone | ||
190 | curl_post "${namestore_link}?name=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error" | ||
191 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
192 | curl_post "${namestore_link}?pubkey=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error" | ||
193 | gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1 | ||
194 | |||
195 | #Test DELETE | ||
196 | gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" | ||
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" | ||
199 | curl_delete "${namestore_link}?label=test_entry&pubkey=$public" "HTTP/1.1 204" | ||
200 | |||
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 | |||
268 | #test default subsystem | ||
269 | |||
270 | exit 0; | ||