diff options
-rw-r--r-- | src/transport/test_http_common.c | 285 |
1 files changed, 37 insertions, 248 deletions
diff --git a/src/transport/test_http_common.c b/src/transport/test_http_common.c index 05c4adb64..d7a203336 100644 --- a/src/transport/test_http_common.c +++ b/src/transport/test_http_common.c | |||
@@ -113,280 +113,69 @@ check (struct SplittedHTTPAddress *addr, | |||
113 | } | 113 | } |
114 | 114 | ||
115 | void | 115 | void |
116 | test_hostname () | 116 | check_pass (char *src, |
117 | char * protocol, | ||
118 | char * host, | ||
119 | int port, | ||
120 | char * path) | ||
117 | { | 121 | { |
118 | struct SplittedHTTPAddress * spa; | 122 | struct SplittedHTTPAddress * spa; |
119 | spa = http_split_address ("http://test.local"); | 123 | spa = http_split_address (src); |
120 | if (NULL == spa) | ||
121 | { | ||
122 | GNUNET_break (0); | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, "")) | ||
127 | { | ||
128 | GNUNET_break (0); | ||
129 | } | ||
130 | clean (spa); | ||
131 | } | ||
132 | |||
133 | spa = http_split_address ("http://test.local"); | ||
134 | if (NULL == spa) | 124 | if (NULL == spa) |
135 | { | 125 | { |
136 | GNUNET_break (0); | 126 | GNUNET_break (0); |
137 | } | 127 | } |
138 | else | 128 | else |
139 | { | 129 | { |
140 | if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, "")) | 130 | if (GNUNET_OK != check(spa, protocol, host, port, path)) |
141 | { | 131 | { |
142 | GNUNET_break (0); | 132 | GNUNET_break (0); |
143 | } | 133 | } |
144 | clean (spa); | 134 | clean (spa); |
145 | } | 135 | } |
136 | } | ||
146 | 137 | ||
138 | void | ||
139 | test_hostname () | ||
140 | { | ||
141 | check_pass("http://test.local", "http", "test.local", HTTP_DEFAULT_PORT, ""); | ||
142 | check_pass("http://test.local/", "http", "test.local", HTTP_DEFAULT_PORT, "/"); | ||
143 | check_pass("http://test.local/path", "http", "test.local", HTTP_DEFAULT_PORT, "/path"); | ||
144 | check_pass("http://test.local/path/", "http", "test.local", HTTP_DEFAULT_PORT, "/path/"); | ||
145 | check_pass("http://test.local:81", "http", "test.local", 81, ""); | ||
146 | check_pass("http://test.local:81/", "http", "test.local", 81, "/"); | ||
147 | check_pass("http://test.local:81/path", "http", "test.local", 81, "/path"); | ||
148 | check_pass("http://test.local:81/path/", "http", "test.local", 81, "/path/"); | ||
147 | 149 | ||
148 | spa = http_split_address ("http://test.local/"); | ||
149 | if (NULL == spa) | ||
150 | { | ||
151 | GNUNET_break (0); | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, "/")) | ||
156 | { | ||
157 | GNUNET_break (0); | ||
158 | } | ||
159 | clean (spa); | ||
160 | } | ||
161 | |||
162 | spa = http_split_address ("http://test.local/path"); | ||
163 | if (NULL == spa) | ||
164 | { | ||
165 | GNUNET_break (0); | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, "/path")) | ||
170 | { | ||
171 | GNUNET_break (0); | ||
172 | } | ||
173 | clean (spa); | ||
174 | } | ||
175 | |||
176 | spa = http_split_address ("http://test.local/path/"); | ||
177 | if (NULL == spa) | ||
178 | { | ||
179 | GNUNET_break (0); | ||
180 | } | ||
181 | else | ||
182 | { | ||
183 | if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, "/path/")) | ||
184 | { | ||
185 | GNUNET_break (0); | ||
186 | } | ||
187 | clean (spa); | ||
188 | |||
189 | |||
190 | } | ||
191 | |||
192 | spa = http_split_address ("http://test.local:1000/path/"); | ||
193 | if (NULL == spa) | ||
194 | { | ||
195 | GNUNET_break (0); | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | if (GNUNET_OK != check(spa, "http", "test.local", 1000, "/path/")) | ||
200 | { | ||
201 | GNUNET_break (0); | ||
202 | } | ||
203 | clean (spa); | ||
204 | } | ||
205 | } | 150 | } |
206 | 151 | ||
207 | void | 152 | void |
208 | test_ipv4 () | 153 | test_ipv4 () |
209 | { | 154 | { |
210 | struct SplittedHTTPAddress * spa; | 155 | check_pass("http://127.0.0.1", "http", "127.0.0.1", HTTP_DEFAULT_PORT, ""); |
211 | spa = http_split_address ("http://127.0.0.1"); | 156 | check_pass("http://127.0.0.1/", "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/"); |
212 | if (NULL == spa) | 157 | check_pass("http://127.0.0.1/path", "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/path"); |
213 | { | 158 | check_pass("http://127.0.0.1/path/", "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/path/"); |
214 | GNUNET_break (0); | 159 | check_pass("http://127.0.0.1:81", "http", "127.0.0.1", 81, ""); |
215 | } | 160 | check_pass("http://127.0.0.1:81/", "http", "127.0.0.1", 81, "/"); |
216 | else | 161 | check_pass("http://127.0.0.1:81/path", "http", "127.0.0.1", 81, "/path"); |
217 | { | 162 | check_pass("http://127.0.0.1:81/path/", "http", "127.0.0.1", 81, "/path/"); |
218 | if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, "")) | ||
219 | { | ||
220 | GNUNET_break (0); | ||
221 | } | ||
222 | clean (spa); | ||
223 | } | ||
224 | |||
225 | spa = http_split_address ("http://127.0.0.1"); | ||
226 | if (NULL == spa) | ||
227 | { | ||
228 | GNUNET_break (0); | ||
229 | } | ||
230 | else | ||
231 | { | ||
232 | if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, "")) | ||
233 | { | ||
234 | GNUNET_break (0); | ||
235 | } | ||
236 | clean (spa); | ||
237 | } | ||
238 | |||
239 | |||
240 | spa = http_split_address ("http://127.0.0.1/"); | ||
241 | if (NULL == spa) | ||
242 | { | ||
243 | GNUNET_break (0); | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/")) | ||
248 | { | ||
249 | GNUNET_break (0); | ||
250 | } | ||
251 | clean (spa); | ||
252 | } | ||
253 | |||
254 | spa = http_split_address ("http://127.0.0.1/path"); | ||
255 | if (NULL == spa) | ||
256 | { | ||
257 | GNUNET_break (0); | ||
258 | } | ||
259 | else | ||
260 | { | ||
261 | if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/path")) | ||
262 | { | ||
263 | GNUNET_break (0); | ||
264 | } | ||
265 | clean (spa); | ||
266 | } | ||
267 | |||
268 | spa = http_split_address ("http://127.0.0.1/path/"); | ||
269 | if (NULL == spa) | ||
270 | { | ||
271 | GNUNET_break (0); | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/path/")) | ||
276 | { | ||
277 | GNUNET_break (0); | ||
278 | } | ||
279 | clean (spa); | ||
280 | |||
281 | |||
282 | } | ||
283 | |||
284 | spa = http_split_address ("http://127.0.0.1:1000/path/"); | ||
285 | if (NULL == spa) | ||
286 | { | ||
287 | GNUNET_break (0); | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | if (GNUNET_OK != check(spa, "http", "127.0.0.1", 1000, "/path/")) | ||
292 | { | ||
293 | GNUNET_break (0); | ||
294 | } | ||
295 | clean (spa); | ||
296 | } | ||
297 | } | 163 | } |
298 | 164 | ||
299 | void | 165 | void |
300 | test_ipv6 () | 166 | test_ipv6 () |
301 | { | 167 | { |
302 | struct SplittedHTTPAddress * spa; | 168 | check_pass("http://[::1]", "http", "[::1]", HTTP_DEFAULT_PORT, ""); |
303 | spa = http_split_address ("http://[::1]"); | 169 | check_pass("http://[::1]/", "http", "[::1]", HTTP_DEFAULT_PORT, "/"); |
304 | if (NULL == spa) | 170 | check_pass("http://[::1]/path", "http", "[::1]", HTTP_DEFAULT_PORT, "/path"); |
305 | { | 171 | check_pass("http://[::1]/path/", "http", "[::1]", HTTP_DEFAULT_PORT, "/path/"); |
306 | GNUNET_break (0); | 172 | check_pass("http://[::1]:81", "http", "[::1]", 81, ""); |
307 | } | 173 | check_pass("http://[::1]:81/", "http", "[::1]", 81, "/"); |
308 | else | 174 | check_pass("http://[::1]:81/path", "http", "[::1]", 81, "/path"); |
309 | { | 175 | check_pass("http://[::1]:81/path/", "http", "[::1]", 81, "/path/"); |
310 | if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, "")) | 176 | } |
311 | { | ||
312 | GNUNET_break (0); | ||
313 | } | ||
314 | clean (spa); | ||
315 | } | ||
316 | |||
317 | spa = http_split_address ("http://[::1]"); | ||
318 | if (NULL == spa) | ||
319 | { | ||
320 | GNUNET_break (0); | ||
321 | } | ||
322 | else | ||
323 | { | ||
324 | if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, "")) | ||
325 | { | ||
326 | GNUNET_break (0); | ||
327 | } | ||
328 | clean (spa); | ||
329 | } | ||
330 | |||
331 | |||
332 | spa = http_split_address ("http://[::1]/"); | ||
333 | if (NULL == spa) | ||
334 | { | ||
335 | GNUNET_break (0); | ||
336 | } | ||
337 | else | ||
338 | { | ||
339 | if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, "/")) | ||
340 | { | ||
341 | GNUNET_break (0); | ||
342 | } | ||
343 | clean (spa); | ||
344 | } | ||
345 | |||
346 | spa = http_split_address ("http://[::1]/path"); | ||
347 | if (NULL == spa) | ||
348 | { | ||
349 | GNUNET_break (0); | ||
350 | } | ||
351 | else | ||
352 | { | ||
353 | if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, "/path")) | ||
354 | { | ||
355 | GNUNET_break (0); | ||
356 | } | ||
357 | clean (spa); | ||
358 | } | ||
359 | |||
360 | spa = http_split_address ("http://[::1]/path/"); | ||
361 | if (NULL == spa) | ||
362 | { | ||
363 | GNUNET_break (0); | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, "/path/")) | ||
368 | { | ||
369 | GNUNET_break (0); | ||
370 | } | ||
371 | clean (spa); | ||
372 | 177 | ||
373 | 178 | ||
374 | } | ||
375 | |||
376 | spa = http_split_address ("http://[::1]:1000/path/"); | ||
377 | if (NULL == spa) | ||
378 | { | ||
379 | GNUNET_break (0); | ||
380 | } | ||
381 | else | ||
382 | { | ||
383 | if (GNUNET_OK != check(spa, "http", "[::1]", 1000, "/path/")) | ||
384 | { | ||
385 | GNUNET_break (0); | ||
386 | } | ||
387 | clean (spa); | ||
388 | } | ||
389 | } | ||
390 | 179 | ||
391 | int | 180 | int |
392 | main (int argc, char *argv[]) | 181 | main (int argc, char *argv[]) |