diff options
author | Phil <phil.buschmann@tum.de> | 2018-07-25 16:59:08 +0200 |
---|---|---|
committer | Phil <phil.buschmann@tum.de> | 2018-07-25 16:59:08 +0200 |
commit | 9009fb0aa496cd72ff6f1ea3d20ac4a547055e1b (patch) | |
tree | dde1a437bdca9fe056667aaa2749d067dc4f6456 /src | |
parent | 8b89bb8b02c8949f3c74ad0668107d184aaa3788 (diff) | |
download | gnunet-9009fb0aa496cd72ff6f1ea3d20ac4a547055e1b.tar.gz gnunet-9009fb0aa496cd72ff6f1ea3d20ac4a547055e1b.zip |
-fix identity file
Diffstat (limited to 'src')
-rw-r--r-- | src/identity/plugin_rest_identity.c | 59 | ||||
-rwxr-xr-x | src/identity/test_plugin_identity_rest.sh | 252 |
2 files changed, 30 insertions, 281 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index 8d525b950..f1d33b0f3 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012-2015 GNUnet e.V. | 3 | Copyright (C) 2012-2015 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @author Martin Schanzenbach | 19 | * @author Martin Schanzenbach |
@@ -202,8 +200,9 @@ struct RequestHandle | |||
202 | * @param handle Handle to clean up | 200 | * @param handle Handle to clean up |
203 | */ | 201 | */ |
204 | static void | 202 | static void |
205 | cleanup_handle (struct RequestHandle *handle) | 203 | cleanup_handle (void *cls) |
206 | { | 204 | { |
205 | struct RequestHandle *handle = cls; | ||
207 | struct EgoEntry *ego_entry; | 206 | struct EgoEntry *ego_entry; |
208 | struct EgoEntry *ego_tmp; | 207 | struct EgoEntry *ego_tmp; |
209 | 208 | ||
@@ -248,20 +247,22 @@ do_error (void *cls) | |||
248 | { | 247 | { |
249 | struct RequestHandle *handle = cls; | 248 | struct RequestHandle *handle = cls; |
250 | struct MHD_Response *resp; | 249 | struct MHD_Response *resp; |
251 | char *json_error; | 250 | json_t *json_error = json_object(); |
251 | char *response; | ||
252 | 252 | ||
253 | if (NULL == handle->emsg) | 253 | if (NULL == handle->emsg) |
254 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_UNKNOWN); | 254 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_UNKNOWN); |
255 | 255 | ||
256 | GNUNET_asprintf (&json_error, "{\"error\": \"%s\"}", handle->emsg); | 256 | json_object_set_new(json_error,"error", json_string(handle->emsg)); |
257 | 257 | ||
258 | if (0 == handle->response_code) | 258 | if (0 == handle->response_code) |
259 | handle->response_code = MHD_HTTP_OK; | 259 | handle->response_code = MHD_HTTP_OK; |
260 | 260 | response = json_dumps (json_error, 0); | |
261 | resp = GNUNET_REST_create_response (json_error); | 261 | resp = GNUNET_REST_create_response (response); |
262 | handle->proc (handle->proc_cls, resp, handle->response_code); | 262 | handle->proc (handle->proc_cls, resp, handle->response_code); |
263 | cleanup_handle (handle); | 263 | json_decref(json_error); |
264 | GNUNET_free(json_error); | 264 | GNUNET_free(response); |
265 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | ||
265 | } | 266 | } |
266 | 267 | ||
267 | /** | 268 | /** |
@@ -306,7 +307,7 @@ ego_get_for_subsystem (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | |||
306 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 307 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
307 | GNUNET_free(result_str); | 308 | GNUNET_free(result_str); |
308 | GNUNET_free(public_key_string); | 309 | GNUNET_free(public_key_string); |
309 | cleanup_handle (handle); | 310 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
310 | } | 311 | } |
311 | 312 | ||
312 | /** | 313 | /** |
@@ -420,7 +421,7 @@ ego_get (struct GNUNET_REST_RequestHandle *con_handle, const char* url, | |||
420 | json_decref (json_root); | 421 | json_decref (json_root); |
421 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 422 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
422 | GNUNET_free(result_str); | 423 | GNUNET_free(result_str); |
423 | cleanup_handle (handle); | 424 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
424 | } | 425 | } |
425 | 426 | ||
426 | /** | 427 | /** |
@@ -444,7 +445,7 @@ do_finished (void *cls, const char *emsg) | |||
444 | } | 445 | } |
445 | resp = GNUNET_REST_create_response (NULL); | 446 | resp = GNUNET_REST_create_response (NULL); |
446 | handle->proc (handle->proc_cls, resp, handle->response_code); | 447 | handle->proc (handle->proc_cls, resp, handle->response_code); |
447 | cleanup_handle (handle); | 448 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
448 | } | 449 | } |
449 | 450 | ||
450 | /** | 451 | /** |
@@ -530,7 +531,7 @@ ego_edit (struct GNUNET_REST_RequestHandle *con_handle, const char* url, | |||
530 | json_decref (data_js); | 531 | json_decref (data_js); |
531 | resp = GNUNET_REST_create_response (NULL); | 532 | resp = GNUNET_REST_create_response (NULL); |
532 | handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); | 533 | handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); |
533 | cleanup_handle (handle); | 534 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
534 | return; | 535 | return; |
535 | } | 536 | } |
536 | //This is a rename | 537 | //This is a rename |
@@ -555,7 +556,7 @@ ego_edit (struct GNUNET_REST_RequestHandle *con_handle, const char* url, | |||
555 | json_decref (data_js); | 556 | json_decref (data_js); |
556 | resp = GNUNET_REST_create_response (NULL); | 557 | resp = GNUNET_REST_create_response (NULL); |
557 | handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); | 558 | handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); |
558 | cleanup_handle (handle); | 559 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
559 | return; | 560 | return; |
560 | } | 561 | } |
561 | } | 562 | } |
@@ -677,7 +678,7 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, const char* url, | |||
677 | json_decref (data_js); | 678 | json_decref (data_js); |
678 | resp = GNUNET_REST_create_response (NULL); | 679 | resp = GNUNET_REST_create_response (NULL); |
679 | handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); | 680 | handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); |
680 | cleanup_handle (handle); | 681 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
681 | return; | 682 | return; |
682 | } | 683 | } |
683 | } | 684 | } |
@@ -732,7 +733,7 @@ ego_delete (struct GNUNET_REST_RequestHandle *con_handle, const char* url, | |||
732 | { | 733 | { |
733 | resp = GNUNET_REST_create_response (NULL); | 734 | resp = GNUNET_REST_create_response (NULL); |
734 | handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); | 735 | handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); |
735 | cleanup_handle (handle); | 736 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
736 | return; | 737 | return; |
737 | } | 738 | } |
738 | handle->response_code = MHD_HTTP_NO_CONTENT; | 739 | handle->response_code = MHD_HTTP_NO_CONTENT; |
@@ -760,7 +761,7 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle, const char* url, | |||
760 | resp = GNUNET_REST_create_response (NULL); | 761 | resp = GNUNET_REST_create_response (NULL); |
761 | MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); | 762 | MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); |
762 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 763 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
763 | cleanup_handle (handle); | 764 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
764 | return; | 765 | return; |
765 | } | 766 | } |
766 | 767 | ||
diff --git a/src/identity/test_plugin_identity_rest.sh b/src/identity/test_plugin_identity_rest.sh deleted file mode 100755 index d43f4206b..000000000 --- a/src/identity/test_plugin_identity_rest.sh +++ /dev/null | |||
@@ -1,252 +0,0 @@ | |||
1 | #!/usr/bin/bash | ||
2 | |||
3 | #First, start gnunet-arm and the rest-service. Make sure, no identity exists | ||
4 | |||
5 | link_to_api="http://localhost:7776/identity" | ||
6 | wrong_link="http://localhost:7776/idenmmmy" | ||
7 | |||
8 | #Test GET (multiple identities) for error when no identity exists | ||
9 | |||
10 | echo "No test for subsystem available" | ||
11 | echo "The next test case can be ignored if you have already added identities" | ||
12 | cache="$(curl --silent "$link_to_api" | grep "error")" | ||
13 | if [ "" == "$cache" ] | ||
14 | then | ||
15 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for GET request when missing identity\n" | ||
16 | else | ||
17 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for GET request when missing identity\n" | ||
18 | fi | ||
19 | |||
20 | #Test POST success code, error response code and error json | ||
21 | echo "The next test case can be ignored if you have already added an identity with the name Test" | ||
22 | cache="$(curl -v -X "POST" "$link_to_api" --data "{\"name\":\"Test\"}" 2>&1 | grep "HTTP/1.1 201")" | ||
23 | if [ "" == "$cache" ] | ||
24 | then | ||
25 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Error for good POST request\n" | ||
26 | else | ||
27 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Success for good POST request\n" | ||
28 | fi | ||
29 | |||
30 | cache="$(curl -v -X "POST" "$link_to_api" --data "{\"name\":\"Test\"}" 2>&1 | grep "HTTP/1.1 409")" | ||
31 | if [ "" == "$cache" ] | ||
32 | then | ||
33 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for duplicate name POST request\n" | ||
34 | else | ||
35 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for duplicate name POST request\n" | ||
36 | fi | ||
37 | |||
38 | cache="$(curl -v -X "POST" "$link_to_api" 2>&1 | grep "error")" | ||
39 | if [ "" == "$cache" ] | ||
40 | then | ||
41 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for no data POST request\n" | ||
42 | else | ||
43 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for no data POST request\n" | ||
44 | fi | ||
45 | |||
46 | cache="$(curl -v -X "POST" "$link_to_api" --data "wrong" 2>&1 | grep "error")" | ||
47 | if [ "" == "$cache" ] | ||
48 | then | ||
49 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong data POST request\n" | ||
50 | else | ||
51 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong data POST request\n" | ||
52 | fi | ||
53 | |||
54 | cache="$(curl -v -X "POST" "$link_to_api" --data "[{}]" 2>&1 | grep "error")" | ||
55 | if [ "" == "$cache" ] | ||
56 | then | ||
57 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for json array input POST request\n" | ||
58 | else | ||
59 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for json array input POST request\n" | ||
60 | fi | ||
61 | |||
62 | cache="$(curl -v -X "POST" "$link_to_api" --data "{\"name\":\"Test\",\"other\":\"Test\"}" 2>&1 | grep "error")" | ||
63 | if [ "" == "$cache" ] | ||
64 | then | ||
65 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for multi element json POST request\n" | ||
66 | else | ||
67 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for multi element json POST request\n" | ||
68 | fi | ||
69 | |||
70 | cache="$(curl -v -X "POST" "$link_to_api" --data "{\"nam\":\"Test\"}" 2>&1 | grep "error")" | ||
71 | if [ "" == "$cache" ] | ||
72 | then | ||
73 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong json POST request\n" | ||
74 | else | ||
75 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong json POST request\n" | ||
76 | fi | ||
77 | |||
78 | cache="$(curl -v -X "POST" "$link_to_api" --data "{\"name\":123}" 2>&1 | grep "error")" | ||
79 | if [ "" == "$cache" ] | ||
80 | then | ||
81 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong json type POST request\n" | ||
82 | else | ||
83 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong json type POST request\n" | ||
84 | fi | ||
85 | |||
86 | cache="$(curl -v -X "POST" "$link_to_api" --data "{\"name\":""}" 2>&1 | grep "error")" | ||
87 | if [ "" == "$cache" ] | ||
88 | then | ||
89 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for no name POST request\n" | ||
90 | else | ||
91 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for no name POST request\n" | ||
92 | fi | ||
93 | |||
94 | |||
95 | #Test GET (multiple identities) for success and error json | ||
96 | cache="$(curl --silent "$link_to_api" | grep "error")" | ||
97 | if [ "" == "$cache" ] | ||
98 | then | ||
99 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Success for good GET request (multiple identities)\n" | ||
100 | else | ||
101 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Error for good GET request (multiple identities)\n" | ||
102 | fi | ||
103 | |||
104 | |||
105 | id="$(gnunet-identity -d | grep "Test - " | sed "s/Test - //g")" | ||
106 | #Test GET (one identity) for success and error json | ||
107 | cache="$(curl --silent "${link_to_api}/$id" | grep "error")" | ||
108 | if [ "" == "$cache" ] | ||
109 | then | ||
110 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Success for good GET request (one identity)\n" | ||
111 | else | ||
112 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Error for good GET request (one identity)\n" | ||
113 | fi | ||
114 | |||
115 | |||
116 | #Test DELETE success code, error response code and error json | ||
117 | echo "Next tests for DELETE will probably fail when POST fails" | ||
118 | cache="$(curl -v -X "DELETE" "${link_to_api}/$id" 2>&1 | grep "HTTP/1.1 404")" | ||
119 | if [ "" == "$cache" ] | ||
120 | then | ||
121 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Success for good DELETE request\n" | ||
122 | else | ||
123 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Error for good DELETE request\n" | ||
124 | fi | ||
125 | |||
126 | curl --silent -X "POST" "$link_to_api" --data "{\"name\":\"Test\"}" | ||
127 | id="$(gnunet-identity -d | grep "Test - " | sed "s/Test - //g")" | ||
128 | |||
129 | cache="$(curl -v -X "DELETE" "${link_to_api}/df1" 2>&1 | grep "HTTP/1.1 404")" | ||
130 | if [ "" == "$cache" ] | ||
131 | then | ||
132 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong DELETE request\n" | ||
133 | else | ||
134 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong DELETE request\n" | ||
135 | fi | ||
136 | |||
137 | #Test PUT success code, error response codes and error json | ||
138 | cache="$(curl -v -X "PUT" "${link_to_api}/$id" --data "{\"newname\":\"NewTest\"}" 2>&1 | grep "HTTP/1.1 204")" | ||
139 | if [ "" == "$cache" ] | ||
140 | then | ||
141 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Error for good PUT request\n" | ||
142 | else | ||
143 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Success for good PUT request\n" | ||
144 | fi | ||
145 | |||
146 | cache="$(curl -v -X "PUT" "${link_to_api}/${id}1" --data "{\"newname\":\"NewNewTest\"}" 2>&1 | grep "HTTP/1.1 404")" | ||
147 | if [ "" == "$cache" ] | ||
148 | then | ||
149 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong identity PUT request\n" | ||
150 | else | ||
151 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong identity PUT request\n" | ||
152 | fi | ||
153 | |||
154 | cache="$(curl -v -X "PUT" "$link_to_api/$id" --data "{\"newname\":\"NewTest\"}" 2>&1 | grep "error")" | ||
155 | if [ "" == "$cache" ] | ||
156 | then | ||
157 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for duplicate name PUT request\n" | ||
158 | else | ||
159 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for duplicate name PUT request\n" | ||
160 | fi | ||
161 | |||
162 | cache="$(curl -v -X "PUT" "$link_to_api/$id" 2>&1 | grep "error")" | ||
163 | if [ "" == "$cache" ] | ||
164 | then | ||
165 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for no data PUT request\n" | ||
166 | else | ||
167 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for no data PUT request\n" | ||
168 | fi | ||
169 | |||
170 | cache="$(curl -v -X "PUT" "$link_to_api/$id" --data "wrong" 2>&1 | grep "error")" | ||
171 | if [ "" == "$cache" ] | ||
172 | then | ||
173 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong data PUT request\n" | ||
174 | else | ||
175 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong data PUT request\n" | ||
176 | fi | ||
177 | |||
178 | cache="$(curl -v -X "PUT" "$link_to_api/$id" --data "[{}]" 2>&1 | grep "error")" | ||
179 | if [ "" == "$cache" ] | ||
180 | then | ||
181 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for json array input PUT request\n" | ||
182 | else | ||
183 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for json array input PUT request\n" | ||
184 | fi | ||
185 | |||
186 | cache="$(curl -v -X "PUT" "$link_to_api/$id" --data "{\"newname\":\"Test\",\"other\":\"Test\"}" 2>&1 | grep "error")" | ||
187 | if [ "" == "$cache" ] | ||
188 | then | ||
189 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for multi element json PUT request\n" | ||
190 | else | ||
191 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for multi element json PUT request\n" | ||
192 | fi | ||
193 | |||
194 | cache="$(curl -v -X "PUT" "$link_to_api/$id" --data "{\"newnam\":\"Test\"}" 2>&1 | grep "error")" | ||
195 | if [ "" == "$cache" ] | ||
196 | then | ||
197 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong json PUT request\n" | ||
198 | else | ||
199 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong json PUT request\n" | ||
200 | fi | ||
201 | |||
202 | cache="$(curl -v -X "PUT" "$link_to_api/$id" --data "{\"newname\":123}" 2>&1 | grep "error")" | ||
203 | if [ "" == "$cache" ] | ||
204 | then | ||
205 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong json type PUT request\n" | ||
206 | else | ||
207 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong json type PUT request\n" | ||
208 | fi | ||
209 | |||
210 | cache="$(curl -v -X "PUT" "$link_to_api/$id" --data "{\"newname\":""}" 2>&1 | grep "error")" | ||
211 | if [ "" == "$cache" ] | ||
212 | then | ||
213 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for no name PUT request\n" | ||
214 | else | ||
215 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for no name PUT request\n" | ||
216 | fi | ||
217 | #TODO Missing subsystem test | ||
218 | |||
219 | #Missing OPTIONS success - nothing can really go wrong here | ||
220 | |||
221 | #Test wrong url | ||
222 | cache="$(curl -v "$wrong_link" 2>&1 | grep "HTTP/1.1 404")" | ||
223 | if [ "" == "$cache" ] | ||
224 | then | ||
225 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong url GET request \n" | ||
226 | else | ||
227 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong url GET request \n" | ||
228 | fi | ||
229 | |||
230 | cache="$(curl -X "PUT" -v "$wrong_link/$id" --data "{\"newname\":\"Testing\"}" 2>&1 | grep "HTTP/1.1 404")" | ||
231 | if [ "" == "$cache" ] | ||
232 | then | ||
233 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong url GET request \n" | ||
234 | else | ||
235 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong url GET request \n" | ||
236 | fi | ||
237 | |||
238 | cache="$(curl -X "POST" -v "$wrong_link/$id" --data "{\"name\":\"Test\"}" 2>&1 | grep "HTTP/1.1 404")" | ||
239 | if [ "" == "$cache" ] | ||
240 | then | ||
241 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong url POST request \n" | ||
242 | else | ||
243 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong url POST request \n" | ||
244 | fi | ||
245 | |||
246 | cache="$(curl -X "DELETE" -v "${wrong_link}/$id" 2>&1 | grep "HTTP/1.1 404")" | ||
247 | if [ "" == "$cache" ] | ||
248 | then | ||
249 | echo -n -e "[\033[0;31m FAILURE\033[0m ] Success for wrong url DELETE request \n" | ||
250 | else | ||
251 | echo -n -e "[\033[0;32m SUCCESS\033[0m ] Error for wrong url DELETE request \n" | ||
252 | fi | ||