Line data Source code
1 : /**
2 : * @file suite_libhttp.c
3 : * @brief Check testsuite for libhttp functions
4 : * @author François Cerbelle (Fanfan), francois@cerbelle.net
5 : *
6 : * @internal
7 : * Created: 20/03/2022
8 : * Revision: none
9 : * Last modified: 2024-12-03 13:53
10 : * Compiler: gcc
11 : * Organization: Cerbelle.net
12 : * Copyright: Copyright (c) 2024, François Cerbelle
13 : *
14 : * This source code is released for free distribution under the terms of the
15 : * GNU General Public License as published by the Free Software Foundation.
16 : */
17 :
18 : #ifdef HAVE_CONFIG_H
19 : #include "config.h"
20 : #endif
21 :
22 : #include <check.h>
23 : #include <stdlib.h>
24 : #include "checktools.inc"
25 :
26 : #include "libhttp.h"
27 : #include <stdio.h> /* perror */
28 :
29 : /** Dummy test to trigger fixtures
30 : *
31 : * This test is defined and added to all testcases in order to execute at
32 : * least one test test in each testcase of the testsuite, trigger the
33 : * fixtures and have a decent coverage report.
34 : */
35 3 : START_TEST(libhttp_test) {
36 : /* This test is supposed to trigger a SIGABRT(6) and will crash the
37 : * whole testsuite if not caught or not in a child process */
38 3 : forktest_only;
39 :
40 2 : abort();
41 : }
42 : END_TEST
43 :
44 3 : START_TEST(libhttp_new) {
45 : HTTP_t* http;
46 : char* body;
47 : HTTPHeader_t* header;
48 :
49 3 : http = HTTP_new();
50 3 : ck_assert(http);
51 :
52 3 : body = HTTP_getbody(http);
53 3 : ck_assert(body);
54 3 : ck_assert(strcmp(body,"")==0);
55 :
56 3 : header = HTTP_firstheader(http);
57 3 : ck_assert(header==NULL);
58 :
59 3 : HTTP_del(http);
60 3 : }
61 : END_TEST
62 :
63 3 : START_TEST(libhttp_del_null) {
64 : /* SIG6 in debug builds, SIG11 in release builds */
65 3 : forktest_only;
66 :
67 2 : HTTP_del(NULL);
68 : }
69 : END_TEST
70 :
71 3 : START_TEST(libhttp_del_empty) {
72 : HTTP_t* http;
73 :
74 3 : http = HTTP_new();
75 3 : ck_assert(http);
76 3 : HTTP_del(http);
77 3 : }
78 : END_TEST
79 :
80 3 : START_TEST(libhttp_del_populated) {
81 : HTTP_t* http;
82 : HTTPHeader_t* header;
83 :
84 3 : http = HTTP_new();
85 3 : ck_assert(http);
86 :
87 3 : header = HTTP_addheader(http,"name1","value1");
88 3 : ck_assert(header);
89 :
90 3 : header = HTTP_addheader(http,"name2","value2");
91 3 : ck_assert(header);
92 :
93 3 : http = HTTP_setbody(http,"<HTML></HTML>");
94 3 : ck_assert(http);
95 :
96 3 : HTTP_del(http);
97 3 : }
98 : END_TEST
99 :
100 3 : START_TEST(libhttp_setbody_nullhttp) {
101 : /* SIG6 in debug builds, SIG11 in release builds */
102 3 : forktest_only;
103 :
104 2 : HTTP_setbody(NULL,"");
105 : }
106 : END_TEST
107 :
108 3 : START_TEST(libhttp_setbody_nullbody) {
109 : HTTP_t* http;
110 :
111 : /* SIG6 in debug builds, SIG11 in release builds */
112 3 : forktest_only;
113 :
114 2 : http = HTTP_new();
115 2 : ck_assert(http);
116 :
117 2 : HTTP_setbody(http,NULL);
118 : }
119 : END_TEST
120 :
121 3 : START_TEST(libhttp_setbody_empty) {
122 : HTTP_t* http;
123 : char* body;
124 :
125 3 : http = HTTP_new();
126 3 : ck_assert(http);
127 :
128 3 : http = HTTP_setbody(http,"");
129 3 : ck_assert(http);
130 3 : body = HTTP_getbody(http);
131 3 : ck_assert(strcmp(body,"")==0);
132 :
133 3 : HTTP_del(http);
134 3 : }
135 : END_TEST
136 :
137 3 : START_TEST(libhttp_setbody_valid) {
138 : HTTP_t* http;
139 : char* body;
140 :
141 3 : http = HTTP_new();
142 3 : ck_assert(http);
143 :
144 3 : http = HTTP_setbody(http,"<HTML></HTML>");
145 3 : ck_assert(http);
146 3 : body = HTTP_getbody(http);
147 3 : ck_assert(strcmp(body,"<HTML></HTML>")==0);
148 :
149 3 : HTTP_del(http);
150 3 : }
151 : END_TEST
152 :
153 3 : START_TEST(libhttp_getbody_null) {
154 : /* SIG6 in debug builds, SIG11 in release builds */
155 3 : forktest_only;
156 :
157 2 : HTTP_getbody(NULL);
158 : }
159 : END_TEST
160 :
161 3 : START_TEST(libhttp_getbody_populated) {
162 : HTTP_t* http;
163 : char* body;
164 :
165 3 : http = HTTP_new();
166 3 : ck_assert(http);
167 :
168 3 : body = HTTP_getbody(http);
169 3 : ck_assert(body);
170 3 : ck_assert(strcmp(body,"")==0);
171 :
172 3 : http = HTTP_setbody(http,"<HTML></HTML>");
173 3 : ck_assert(http);
174 :
175 3 : body = HTTP_getbody(http);
176 3 : ck_assert(body);
177 3 : ck_assert(strcmp(body,"<HTML></HTML>")==0);
178 :
179 3 : HTTP_del(http);
180 3 : }
181 : END_TEST
182 :
183 3 : START_TEST(libhttp_addheader_nullhttp) {
184 : /* SIG6 in debug builds, SIG11 in release builds */
185 3 : forktest_only;
186 2 : HTTP_addheader(NULL,"name","value");
187 : }
188 : END_TEST
189 :
190 3 : START_TEST(libhttp_addheader_nullname) {
191 : HTTP_t* http;
192 :
193 : /* SIG6 in debug builds, SIG11 in release builds */
194 3 : forktest_only;
195 :
196 2 : http=HTTP_new();
197 2 : HTTP_addheader(http,NULL,"value");
198 : }
199 : END_TEST
200 :
201 3 : START_TEST(libhttp_addheader_nullvalue) {
202 : HTTP_t* http;
203 :
204 : /* SIG6 in debug builds, SIG11 in release builds */
205 3 : forktest_only;
206 :
207 2 : http=HTTP_new();
208 2 : HTTP_addheader(http,"name",NULL);
209 : }
210 : END_TEST
211 :
212 3 : START_TEST(libhttp_addheader_emptyname) {
213 : HTTP_t* http;
214 : HTTPHeader_t *header;
215 :
216 3 : http=HTTP_new();
217 3 : header = HTTP_addheader(http,"","value");
218 3 : ck_assert(NULL==header);
219 3 : HTTP_del(http);
220 3 : }
221 : END_TEST
222 :
223 3 : START_TEST(libhttp_addheader_emptyvalue) {
224 : HTTP_t* http;
225 : HTTPHeader_t *header;
226 :
227 3 : http=HTTP_new();
228 3 : header = HTTP_addheader(http,"name","");
229 3 : ck_assert(NULL!=header);
230 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
231 3 : ck_assert(0==strcmp("",HTTPHeader_getvalue(header)));
232 3 : HTTP_del(http);
233 3 : }
234 : END_TEST
235 :
236 3 : START_TEST(libhttp_addheader_valid) {
237 : HTTP_t* http;
238 : HTTPHeader_t *header;
239 :
240 3 : http=HTTP_new();
241 3 : header = HTTP_addheader(http,"name","value");
242 3 : ck_assert(NULL!=header);
243 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
244 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
245 3 : HTTP_del(http);
246 3 : }
247 : END_TEST
248 :
249 3 : START_TEST(libhttp_addbasicauth_nullhttp) {
250 : /* SIG6 in debug builds, SIG11 in release builds */
251 3 : forktest_only;
252 2 : HTTP_addbasicauth(NULL,"login","pass");
253 : }
254 : END_TEST
255 :
256 3 : START_TEST(libhttp_addbasicauth_nulllogin) {
257 : HTTP_t* http;
258 :
259 : /* SIG6 in debug builds, SIG11 in release builds */
260 3 : forktest_only;
261 :
262 2 : http=HTTP_new();
263 2 : HTTP_addbasicauth(http,NULL,"pass");
264 : }
265 : END_TEST
266 :
267 3 : START_TEST(libhttp_addbasicauth_nullpass) {
268 : HTTP_t* http;
269 :
270 : /* SIG6 in debug builds, SIG11 in release builds */
271 3 : forktest_only;
272 :
273 2 : http=HTTP_new();
274 2 : HTTP_addbasicauth(http,"login",NULL);
275 : }
276 : END_TEST
277 :
278 3 : START_TEST(libhttp_addbasicauth_emptylogin) {
279 : HTTP_t* http;
280 : HTTPHeader_t *header;
281 :
282 3 : http=HTTP_new();
283 3 : header = HTTP_addbasicauth(http,"","pass");
284 3 : ck_assert(NULL!=header);
285 3 : ck_assert(0==strcmp("Authorization",HTTPHeader_getname(header)));
286 3 : ck_assert(0==strcmp("Basic OnBhc3M=",HTTPHeader_getvalue(header)));
287 3 : HTTP_del(http);
288 3 : }
289 : END_TEST
290 :
291 3 : START_TEST(libhttp_addbasicauth_emptypass) {
292 : HTTP_t* http;
293 : HTTPHeader_t *header;
294 :
295 3 : http=HTTP_new();
296 3 : header = HTTP_addbasicauth(http,"login","");
297 3 : ck_assert(NULL!=header);
298 3 : ck_assert(0==strcmp("Authorization",HTTPHeader_getname(header)));
299 3 : ck_assert(0==strcmp("Basic bG9naW46",HTTPHeader_getvalue(header)));
300 3 : HTTP_del(http);
301 3 : }
302 : END_TEST
303 :
304 3 : START_TEST(libhttp_addbasicauth_valid) {
305 : HTTP_t* http;
306 : HTTPHeader_t *header;
307 :
308 3 : http=HTTP_new();
309 3 : header = HTTP_addbasicauth(http,"login","pass");
310 3 : ck_assert(NULL!=header);
311 3 : ck_assert(0==strcmp("Authorization",HTTPHeader_getname(header)));
312 3 : ck_assert(0==strcmp("Basic bG9naW46cGFzcw==",HTTPHeader_getvalue(header)));
313 3 : HTTP_del(http);
314 3 : }
315 : END_TEST
316 :
317 3 : START_TEST(libhttp_setname_nullheader) {
318 : /* SIG6 in debug builds, SIG11 in release builds */
319 3 : forktest_only;
320 2 : HTTPHeader_setname(NULL,"name");
321 : }
322 : END_TEST
323 :
324 3 : START_TEST(libhttp_setname_nullname) {
325 : HTTP_t* http;
326 : HTTPHeader_t *header;
327 :
328 : /* SIG6 in debug builds, SIG11 in release builds */
329 3 : forktest_only;
330 :
331 2 : http=HTTP_new();
332 2 : header = HTTP_addheader(http,"name","value");
333 2 : ck_assert(NULL!=header);
334 2 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
335 2 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
336 :
337 2 : header = HTTPHeader_setname(header,NULL);
338 : }
339 : END_TEST
340 :
341 3 : START_TEST(libhttp_setname_emptyname) {
342 : HTTP_t* http;
343 : HTTPHeader_t *header;
344 :
345 3 : http=HTTP_new();
346 3 : header = HTTP_addheader(http,"name","value");
347 3 : ck_assert(NULL!=header);
348 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
349 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
350 :
351 3 : header = HTTPHeader_setname(header,"");
352 3 : ck_assert(NULL==header);
353 3 : header = HTTP_firstheader(http);
354 3 : ck_assert(NULL!=header);
355 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
356 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
357 3 : HTTP_del(http);
358 3 : }
359 : END_TEST
360 :
361 3 : START_TEST(libhttp_setname_valid) {
362 : HTTP_t* http;
363 : HTTPHeader_t *header;
364 :
365 3 : http=HTTP_new();
366 3 : header = HTTP_addheader(http,"name","value");
367 3 : ck_assert(NULL!=header);
368 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
369 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
370 :
371 3 : header = HTTPHeader_setname(header,"newname");
372 3 : ck_assert(NULL!=header);
373 3 : ck_assert(0==strcmp("newname",HTTPHeader_getname(header)));
374 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
375 3 : HTTP_del(http);
376 3 : }
377 : END_TEST
378 :
379 3 : START_TEST(libhttp_getname_nullheader) {
380 : /* SIG6 in debug builds, SIG11 in release builds */
381 3 : forktest_only;
382 2 : HTTPHeader_getname(NULL);
383 : }
384 : END_TEST
385 :
386 3 : START_TEST(libhttp_getname_valid) {
387 : HTTP_t* http;
388 : HTTPHeader_t *header;
389 :
390 3 : http=HTTP_new();
391 3 : header = HTTP_addheader(http,"name","value");
392 3 : ck_assert(NULL!=header);
393 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
394 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
395 3 : HTTP_del(http);
396 3 : }
397 : END_TEST
398 :
399 3 : START_TEST(libhttp_setvalue_nullheader) {
400 : /* SIG6 in debug builds, SIG11 in release builds */
401 3 : forktest_only;
402 2 : HTTPHeader_setvalue(NULL,"value");
403 : }
404 : END_TEST
405 :
406 3 : START_TEST(libhttp_setvalue_nullvalue) {
407 : HTTP_t* http;
408 : HTTPHeader_t *header;
409 :
410 : /* SIG6 in debug builds, SIG11 in release builds */
411 3 : forktest_only;
412 :
413 2 : http=HTTP_new();
414 2 : header = HTTP_addheader(http,"name","value");
415 2 : ck_assert(NULL!=header);
416 2 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
417 2 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
418 :
419 2 : header = HTTPHeader_setvalue(header,NULL);
420 : }
421 : END_TEST
422 :
423 3 : START_TEST(libhttp_setvalue_emptyvalue) {
424 : HTTP_t* http;
425 : HTTPHeader_t *header;
426 :
427 3 : http=HTTP_new();
428 3 : header = HTTP_addheader(http,"name","value");
429 3 : ck_assert(NULL!=header);
430 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
431 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
432 :
433 3 : header = HTTPHeader_setvalue(header,"");
434 3 : ck_assert(NULL!=header);
435 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
436 3 : ck_assert(0==strcmp("",HTTPHeader_getvalue(header)));
437 3 : HTTP_del(http);
438 3 : }
439 : END_TEST
440 :
441 3 : START_TEST(libhttp_setvalue_valid) {
442 : HTTP_t* http;
443 : HTTPHeader_t *header;
444 :
445 3 : http=HTTP_new();
446 3 : header = HTTP_addheader(http,"name","value");
447 3 : ck_assert(NULL!=header);
448 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
449 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
450 :
451 3 : header = HTTPHeader_setvalue(header,"newvalue");
452 3 : ck_assert(NULL!=header);
453 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
454 3 : ck_assert(0==strcmp("newvalue",HTTPHeader_getvalue(header)));
455 3 : HTTP_del(http);
456 3 : }
457 : END_TEST
458 :
459 3 : START_TEST(libhttp_getvalue_nullheader) {
460 : /* SIG6 in debug builds, SIG11 in release builds */
461 3 : forktest_only;
462 2 : HTTPHeader_getvalue(NULL);
463 : }
464 : END_TEST
465 :
466 3 : START_TEST(libhttp_getvalue_valid) {
467 : HTTP_t* http;
468 : HTTPHeader_t *header;
469 :
470 3 : http=HTTP_new();
471 3 : header = HTTP_addheader(http,"name","value");
472 3 : ck_assert(NULL!=header);
473 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
474 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
475 3 : HTTP_del(http);
476 3 : }
477 : END_TEST
478 :
479 3 : START_TEST(libhttp_firstheader_nullhttp) {
480 : /* SIG6 in debug builds, SIG11 in release builds */
481 3 : forktest_only;
482 2 : HTTP_firstheader(NULL);
483 : }
484 : END_TEST
485 :
486 3 : START_TEST(libhttp_firstheader_empty) {
487 : HTTP_t* http;
488 : HTTPHeader_t *header;
489 :
490 3 : http=HTTP_new();
491 3 : header = HTTP_firstheader(http);
492 3 : ck_assert(NULL==header);
493 3 : HTTP_del(http);
494 3 : }
495 : END_TEST
496 :
497 3 : START_TEST(libhttp_firstheader_single) {
498 : HTTP_t* http;
499 : HTTPHeader_t *header;
500 :
501 3 : http=HTTP_new();
502 3 : header = HTTP_addheader(http,"name","value");
503 3 : ck_assert(NULL!=header);
504 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
505 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
506 :
507 3 : header = HTTP_firstheader(http);
508 3 : ck_assert(NULL!=header);
509 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
510 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
511 3 : HTTP_del(http);
512 3 : }
513 : END_TEST
514 :
515 3 : START_TEST(libhttp_firstheader_multi) {
516 : HTTP_t* http;
517 : HTTPHeader_t *header;
518 :
519 3 : http=HTTP_new();
520 3 : header = HTTP_addheader(http,"name1","value1");
521 3 : ck_assert(NULL!=header);
522 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
523 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
524 3 : header = HTTP_addheader(http,"name2","value2");
525 3 : ck_assert(NULL!=header);
526 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
527 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
528 :
529 3 : header = HTTP_firstheader(http);
530 3 : ck_assert(NULL!=header);
531 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
532 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
533 3 : HTTP_del(http);
534 3 : }
535 : END_TEST
536 :
537 3 : START_TEST(libhttp_nextheader_nullheader) {
538 : /* SIG6 in debug builds, SIG11 in release builds */
539 3 : forktest_only;
540 2 : HTTP_nextheader(NULL);
541 : }
542 : END_TEST
543 :
544 3 : START_TEST(libhttp_nextheader_empty) {
545 : HTTP_t* http;
546 : HTTPHeader_t *header;
547 :
548 : /* SIG6 in debug builds, SIG11 in release builds */
549 3 : forktest_only;
550 :
551 2 : http=HTTP_new();
552 2 : header = HTTP_firstheader(http);
553 2 : header = HTTP_nextheader(header);
554 : }
555 : END_TEST
556 :
557 3 : START_TEST(libhttp_nextheader_single) {
558 : HTTP_t* http;
559 : HTTPHeader_t *header;
560 :
561 3 : http=HTTP_new();
562 3 : header = HTTP_addheader(http,"name","value");
563 3 : ck_assert(NULL!=header);
564 3 : ck_assert(0==strcmp("name",HTTPHeader_getname(header)));
565 3 : ck_assert(0==strcmp("value",HTTPHeader_getvalue(header)));
566 :
567 3 : header = HTTP_firstheader(http);
568 3 : header = HTTP_nextheader(header);
569 3 : ck_assert(NULL==header);
570 :
571 3 : HTTP_del(http);
572 3 : }
573 : END_TEST
574 :
575 3 : START_TEST(libhttp_nextheader_multi) {
576 : HTTP_t* http;
577 : HTTPHeader_t *header;
578 :
579 3 : http=HTTP_new();
580 3 : header = HTTP_addheader(http,"name1","value1");
581 3 : ck_assert(NULL!=header);
582 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
583 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
584 3 : header = HTTP_addheader(http,"name2","value2");
585 3 : ck_assert(NULL!=header);
586 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
587 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
588 3 : header = HTTP_addheader(http,"name3","value3");
589 3 : ck_assert(NULL!=header);
590 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
591 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
592 :
593 3 : header = HTTP_firstheader(http);
594 3 : ck_assert(NULL!=header);
595 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
596 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
597 3 : header = HTTP_nextheader(header);
598 3 : ck_assert(NULL!=header);
599 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
600 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
601 3 : header = HTTP_nextheader(header);
602 3 : ck_assert(NULL!=header);
603 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
604 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
605 3 : header = HTTP_nextheader(header);
606 3 : ck_assert(NULL==header);
607 :
608 3 : HTTP_del(http);
609 3 : }
610 : END_TEST
611 :
612 3 : START_TEST(libhttp_findheader_nullheader) {
613 : /* SIG6 in debug builds, SIG11 in release builds */
614 3 : forktest_only;
615 2 : HTTP_findheader(NULL,"");
616 : }
617 : END_TEST
618 :
619 3 : START_TEST(libhttp_findheader_nullname) {
620 : HTTP_t* http;
621 : HTTPHeader_t *header;
622 :
623 : /* SIG6 in debug builds, SIG11 in release builds */
624 3 : forktest_only;
625 :
626 2 : http=HTTP_new();
627 2 : HTTP_addheader(http,"name1","value1");
628 2 : HTTP_addheader(http,"name2","value2");
629 2 : HTTP_addheader(http,"name3","value3");
630 2 : header = HTTP_firstheader(http);
631 2 : HTTP_findheader(header,NULL);
632 : }
633 : END_TEST
634 :
635 3 : START_TEST(libhttp_findheader_emptyname) {
636 : HTTP_t* http;
637 : HTTPHeader_t *header;
638 :
639 3 : http=HTTP_new();
640 3 : HTTP_addheader(http,"name1","value1");
641 3 : HTTP_addheader(http,"name2","value2");
642 3 : HTTP_addheader(http,"name3","value3");
643 3 : header = HTTP_firstheader(http);
644 3 : header = HTTP_findheader(header,"");
645 : /* Search accepted despite empty header name forbidden, will return NULL
646 : * because there will always be a miss */
647 3 : ck_assert(NULL==header);
648 :
649 3 : HTTP_del(http);
650 3 : }
651 : END_TEST
652 :
653 3 : START_TEST(libhttp_findheader_missingname) {
654 : HTTP_t* http;
655 : HTTPHeader_t *header;
656 :
657 3 : http=HTTP_new();
658 3 : HTTP_addheader(http,"name1","value1");
659 3 : HTTP_addheader(http,"name2","value2");
660 3 : HTTP_addheader(http,"name3","value3");
661 3 : header = HTTP_firstheader(http);
662 3 : header = HTTP_findheader(header,"name4");
663 3 : ck_assert(NULL==header);
664 :
665 3 : HTTP_del(http);
666 3 : }
667 : END_TEST
668 :
669 3 : START_TEST(libhttp_findheader_firstname) {
670 : HTTP_t* http;
671 : HTTPHeader_t *header;
672 :
673 3 : http=HTTP_new();
674 3 : HTTP_addheader(http,"name1","value1");
675 3 : HTTP_addheader(http,"name2","value2");
676 3 : HTTP_addheader(http,"name3","value3");
677 3 : header = HTTP_firstheader(http);
678 3 : header = HTTP_findheader(header,"name1");
679 3 : ck_assert(NULL!=header);
680 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
681 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
682 :
683 3 : HTTP_del(http);
684 3 : }
685 : END_TEST
686 :
687 3 : START_TEST(libhttp_findheader_middlename) {
688 : HTTP_t* http;
689 : HTTPHeader_t *header;
690 :
691 3 : http=HTTP_new();
692 3 : HTTP_addheader(http,"name1","value1");
693 3 : HTTP_addheader(http,"name2","value2");
694 3 : HTTP_addheader(http,"name3","value3");
695 3 : header = HTTP_firstheader(http);
696 3 : header = HTTP_findheader(header,"name2");
697 3 : ck_assert(NULL!=header);
698 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
699 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
700 :
701 3 : HTTP_del(http);
702 3 : }
703 : END_TEST
704 :
705 3 : START_TEST(libhttp_findheader_lastname) {
706 : HTTP_t* http;
707 : HTTPHeader_t *header;
708 :
709 3 : http=HTTP_new();
710 3 : HTTP_addheader(http,"name1","value1");
711 3 : HTTP_addheader(http,"name2","value2");
712 3 : HTTP_addheader(http,"name3","value3");
713 3 : header = HTTP_firstheader(http);
714 3 : header = HTTP_findheader(header,"name3");
715 3 : ck_assert(NULL!=header);
716 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
717 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
718 :
719 3 : HTTP_del(http);
720 3 : }
721 : END_TEST
722 :
723 3 : START_TEST(libhttp_findheader_secondmiddle) {
724 : HTTP_t* http;
725 : HTTPHeader_t *header;
726 :
727 3 : http=HTTP_new();
728 3 : HTTP_addheader(http,"name1","value1");
729 3 : HTTP_addheader(http,"name2","value2");
730 3 : HTTP_addheader(http,"name1","value4");
731 3 : HTTP_addheader(http,"name3","value3");
732 3 : header = HTTP_firstheader(http);
733 3 : header = HTTP_findheader(header,"name1");
734 3 : ck_assert(NULL!=header);
735 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
736 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
737 3 : header = HTTP_nextheader(header);
738 3 : header = HTTP_findheader(header,"name1");
739 3 : ck_assert(NULL!=header);
740 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
741 3 : ck_assert(0==strcmp("value4",HTTPHeader_getvalue(header)));
742 :
743 3 : HTTP_del(http);
744 3 : }
745 : END_TEST
746 :
747 3 : START_TEST(libhttp_findheader_secondlast) {
748 : HTTP_t* http;
749 : HTTPHeader_t *header;
750 :
751 3 : http=HTTP_new();
752 3 : HTTP_addheader(http,"name1","value1");
753 3 : HTTP_addheader(http,"name2","value2");
754 3 : HTTP_addheader(http,"name1","value3");
755 3 : header = HTTP_firstheader(http);
756 3 : header = HTTP_findheader(header,"name1");
757 3 : ck_assert(NULL!=header);
758 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
759 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
760 3 : header = HTTP_nextheader(header);
761 3 : header = HTTP_findheader(header,"name1");
762 3 : ck_assert(NULL!=header);
763 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
764 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
765 :
766 3 : HTTP_del(http);
767 3 : }
768 : END_TEST
769 :
770 3 : START_TEST(libhttp_remheader_nullhttp) {
771 : HTTP_t* http;
772 : HTTPHeader_t *header;
773 :
774 : /* SIG6 in debug builds, SIG11 in release builds */
775 3 : forktest_only;
776 :
777 2 : http=HTTP_new();
778 2 : header = HTTP_addheader(http,"name1","value1");
779 2 : HTTP_remheader(NULL,header);
780 : }
781 : END_TEST
782 :
783 3 : START_TEST(libhttp_remheader_nullheader) {
784 : HTTP_t* http;
785 :
786 : /* SIG6 in debug builds, SIG11 in release builds */
787 3 : forktest_only;
788 :
789 2 : http=HTTP_new();
790 2 : HTTP_remheader(http,NULL);
791 : }
792 : END_TEST
793 :
794 3 : START_TEST(libhttp_remheader_missingheader) {
795 : HTTP_t* http;
796 : HTTP_t* http2;
797 : HTTPHeader_t *header;
798 :
799 3 : http=HTTP_new();
800 3 : HTTP_addheader(http,"name1","value1");
801 3 : HTTP_addheader(http,"name2","value2");
802 3 : HTTP_addheader(http,"name3","value3");
803 :
804 3 : http2=HTTP_new();
805 3 : HTTP_addheader(http2,"name4","value4");
806 3 : header = HTTP_firstheader(http2);
807 :
808 : /* Try to remove http2 header from http (not here) */
809 3 : ck_assert(NULL==HTTP_remheader(http,header));
810 :
811 3 : header = HTTP_firstheader(http);
812 3 : ck_assert(NULL!=header);
813 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
814 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
815 3 : header = HTTP_nextheader(header);
816 3 : ck_assert(NULL!=header);
817 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
818 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
819 3 : header = HTTP_nextheader(header);
820 3 : ck_assert(NULL!=header);
821 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
822 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
823 3 : header = HTTP_nextheader(header);
824 3 : ck_assert(NULL==header);
825 3 : header = HTTP_firstheader(http2);
826 3 : ck_assert(NULL!=header);
827 3 : ck_assert(0==strcmp("name4",HTTPHeader_getname(header)));
828 3 : ck_assert(0==strcmp("value4",HTTPHeader_getvalue(header)));
829 3 : header = HTTP_nextheader(header);
830 3 : ck_assert(NULL==header);
831 :
832 3 : HTTP_del(http);
833 3 : HTTP_del(http2);
834 3 : }
835 : END_TEST
836 :
837 3 : START_TEST(libhttp_remheader_firstheader) {
838 : HTTP_t* http;
839 : HTTPHeader_t *header;
840 :
841 3 : http=HTTP_new();
842 3 : HTTP_addheader(http,"name1","value1");
843 3 : HTTP_addheader(http,"name2","value2");
844 3 : HTTP_addheader(http,"name3","value3");
845 :
846 3 : header = HTTP_firstheader(http);
847 3 : ck_assert(http==HTTP_remheader(http,header));
848 :
849 3 : header = HTTP_firstheader(http);
850 3 : ck_assert(NULL!=header);
851 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
852 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
853 3 : header = HTTP_nextheader(header);
854 3 : ck_assert(NULL!=header);
855 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
856 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
857 3 : header = HTTP_nextheader(header);
858 3 : ck_assert(NULL==header);
859 :
860 3 : HTTP_del(http);
861 3 : }
862 : END_TEST
863 :
864 3 : START_TEST(libhttp_remheader_middleheader) {
865 : HTTP_t* http;
866 : HTTPHeader_t *header;
867 :
868 3 : http=HTTP_new();
869 3 : HTTP_addheader(http,"name1","value1");
870 3 : HTTP_addheader(http,"name2","value2");
871 3 : HTTP_addheader(http,"name3","value3");
872 :
873 3 : header = HTTP_findheader(HTTP_firstheader(http),"name2");
874 3 : ck_assert(http==HTTP_remheader(http,header));
875 :
876 3 : header = HTTP_firstheader(http);
877 3 : ck_assert(NULL!=header);
878 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
879 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
880 3 : header = HTTP_nextheader(header);
881 3 : ck_assert(NULL!=header);
882 3 : ck_assert(0==strcmp("name3",HTTPHeader_getname(header)));
883 3 : ck_assert(0==strcmp("value3",HTTPHeader_getvalue(header)));
884 3 : header = HTTP_nextheader(header);
885 3 : ck_assert(NULL==header);
886 :
887 3 : HTTP_del(http);
888 3 : }
889 : END_TEST
890 :
891 3 : START_TEST(libhttp_remheader_lastheader) {
892 : HTTP_t* http;
893 : HTTPHeader_t *header;
894 :
895 3 : http=HTTP_new();
896 3 : HTTP_addheader(http,"name1","value1");
897 3 : HTTP_addheader(http,"name2","value2");
898 3 : HTTP_addheader(http,"name3","value3");
899 :
900 3 : header = HTTP_findheader(HTTP_firstheader(http),"name3");
901 3 : ck_assert(http==HTTP_remheader(http,header));
902 :
903 3 : header = HTTP_firstheader(http);
904 3 : ck_assert(NULL!=header);
905 3 : ck_assert(0==strcmp("name1",HTTPHeader_getname(header)));
906 3 : ck_assert(0==strcmp("value1",HTTPHeader_getvalue(header)));
907 3 : header = HTTP_nextheader(header);
908 3 : ck_assert(NULL!=header);
909 3 : ck_assert(0==strcmp("name2",HTTPHeader_getname(header)));
910 3 : ck_assert(0==strcmp("value2",HTTPHeader_getvalue(header)));
911 3 : header = HTTP_nextheader(header);
912 3 : ck_assert(NULL==header);
913 :
914 3 : HTTP_del(http);
915 3 : }
916 : END_TEST
917 :
918 3 : START_TEST(libhttp_remheader_onlyheader) {
919 : HTTP_t* http;
920 : HTTPHeader_t *header;
921 :
922 3 : http=HTTP_new();
923 3 : HTTP_addheader(http,"name1","value1");
924 :
925 3 : header = HTTP_firstheader(http);
926 3 : ck_assert(http==HTTP_remheader(http,header));
927 :
928 3 : header = HTTP_firstheader(http);
929 3 : ck_assert(NULL==header);
930 :
931 3 : HTTP_del(http);
932 3 : }
933 : END_TEST
934 :
935 3 : START_TEST(libhttp_buildheaders_null) {
936 : /* SIG6 in debug builds, SIG11 in release builds */
937 3 : forktest_only;
938 :
939 2 : HTTP_buildheaders(NULL);
940 : }
941 : END_TEST
942 :
943 3 : START_TEST(libhttp_buildheaders_empty) {
944 : HTTP_t* http;
945 : char* headers;
946 :
947 3 : http=HTTP_new();
948 3 : headers = HTTP_buildheaders(http);
949 3 : ck_assert(0==strcmp(headers,""));
950 3 : free(headers);
951 3 : HTTP_del(http);
952 3 : }
953 : END_TEST
954 :
955 3 : START_TEST(libhttp_buildheaders_single) {
956 : HTTP_t* http;
957 : HTTPHeader_t* header;
958 : char* headers;
959 :
960 3 : http=HTTP_new();
961 3 : header = HTTP_addheader(http,"name1","value1");
962 3 : ck_assert(header);
963 3 : headers = HTTP_buildheaders(http);
964 3 : ck_assert(0==strcmp(headers,"name1: value1\r\n"));
965 3 : free(headers);
966 3 : HTTP_del(http);
967 3 : }
968 : END_TEST
969 :
970 3 : START_TEST(libhttp_buildheaders_multi) {
971 : HTTP_t* http;
972 : HTTPHeader_t* header;
973 : char* headers;
974 :
975 3 : http=HTTP_new();
976 3 : header = HTTP_addheader(http,"name1","value1");
977 3 : ck_assert(header);
978 3 : header = HTTP_addheader(http,"name2","value2");
979 3 : headers = HTTP_buildheaders(http);
980 3 : ck_assert(0==strcmp(headers,"name1: value1\r\nname2: value2\r\n"));
981 3 : free(headers);
982 3 : HTTP_del(http);
983 3 : }
984 : END_TEST
985 :
986 3 : START_TEST(libhttp_buildrequest_nullhttp) {
987 : /* SIG6 in debug builds, SIG11 in release builds */
988 3 : forktest_only;
989 :
990 2 : HTTP_buildrequest(NULL, HTTPMETHOD_GET, "/v1", HTTPVERSION_HTTP11);
991 :
992 : }
993 : END_TEST
994 :
995 3 : START_TEST(libhttp_buildrequest_nulluri) {
996 : HTTP_t* http;
997 :
998 : /* SIG6 in debug builds, SIG11 in release builds */
999 3 : forktest_only;
1000 :
1001 2 : http=HTTP_new();
1002 2 : HTTP_buildrequest(http, HTTPMETHOD_GET, NULL, HTTPVERSION_HTTP11);
1003 : }
1004 : END_TEST
1005 :
1006 3 : START_TEST(libhttp_buildrequest_badmethod) {
1007 : HTTP_t* http;
1008 : char* request;
1009 :
1010 3 : http=HTTP_new();
1011 3 : request=HTTP_buildrequest(http, HTTPMETHOD_INVALID+1, "/v1", HTTPVERSION_HTTP11);
1012 3 : ck_assert(NULL==request);
1013 3 : HTTP_del(http);
1014 3 : }
1015 : END_TEST
1016 :
1017 3 : START_TEST(libhttp_buildrequest_badversion) {
1018 : HTTP_t* http;
1019 : char* request;
1020 :
1021 3 : http=HTTP_new();
1022 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "/v1", HTTPVERSION_INVALID+1);
1023 3 : ck_assert(NULL==request);
1024 3 : HTTP_del(http);
1025 3 : }
1026 : END_TEST
1027 :
1028 3 : START_TEST(libhttp_buildrequest_emptyuri) {
1029 : HTTP_t* http;
1030 : char* request;
1031 :
1032 3 : http=HTTP_new();
1033 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "", HTTPVERSION_HTTP11);
1034 3 : ck_assert(request);
1035 3 : ck_assert(0==strcmp(request,"GET HTTP/1.1\r\n\r\n"));
1036 3 : free(request);
1037 3 : HTTP_del(http);
1038 3 : }
1039 : END_TEST
1040 :
1041 3 : START_TEST(libhttp_buildrequest_noheader) {
1042 : HTTP_t* http;
1043 : char* request;
1044 :
1045 3 : http=HTTP_new();
1046 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "/v1", HTTPVERSION_HTTP11);
1047 3 : ck_assert(request);
1048 3 : ck_assert(0==strcmp(request,"GET /v1 HTTP/1.1\r\n\r\n"));
1049 3 : free(request);
1050 3 : HTTP_del(http);
1051 3 : }
1052 : END_TEST
1053 :
1054 3 : START_TEST(libhttp_buildrequest_singleheader) {
1055 : HTTP_t* http;
1056 : char* request;
1057 :
1058 3 : http=HTTP_new();
1059 3 : HTTP_addheader(http,"name1","value1");
1060 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "/v1", HTTPVERSION_HTTP11);
1061 3 : ck_assert(request);
1062 3 : ck_assert(0==strcmp(request,"GET /v1 HTTP/1.1\r\nname1: value1\r\n\r\n"));
1063 3 : free(request);
1064 3 : HTTP_del(http);
1065 3 : }
1066 : END_TEST
1067 :
1068 3 : START_TEST(libhttp_buildrequest_multiheader) {
1069 : HTTP_t* http;
1070 : char* request;
1071 :
1072 3 : http=HTTP_new();
1073 3 : HTTP_addheader(http,"name1","value1");
1074 3 : HTTP_addheader(http,"name2","value2");
1075 3 : request=HTTP_buildrequest(http, HTTPMETHOD_GET, "/v1", HTTPVERSION_HTTP11);
1076 3 : ck_assert(request);
1077 3 : ck_assert(0==strcmp(request,"GET /v1 HTTP/1.1\r\nname1: value1\r\nname2: value2\r\n\r\n"));
1078 3 : free(request);
1079 3 : HTTP_del(http);
1080 3 : }
1081 : END_TEST
1082 :
1083 3 : START_TEST(libhttp_buildreply_nullhttp) {
1084 : /* SIG6 in debug builds, SIG11 in release builds */
1085 3 : forktest_only;
1086 :
1087 2 : HTTP_buildreply(NULL, HTTPVERSION_HTTP11, SUCCESS_OK);
1088 : }
1089 : END_TEST
1090 :
1091 3 : START_TEST(libhttp_buildreply_emptyhttp) {
1092 : HTTP_t* http;
1093 : char* reply;
1094 :
1095 3 : http=HTTP_new();
1096 3 : reply=HTTP_buildreply(http, HTTPVERSION_HTTP11, SUCCESS_OK);
1097 3 : ck_assert(reply);
1098 3 : ck_assert(0==strcmp(reply,"HTTP/1.1 200 Dummy Reason\r\n\r\n"));
1099 3 : free(reply);
1100 3 : HTTP_del(http);
1101 3 : }
1102 : END_TEST
1103 :
1104 3 : START_TEST(libhttp_buildreply_invalidversion) {
1105 : HTTP_t* http;
1106 : char* reply;
1107 :
1108 3 : http=HTTP_new();
1109 3 : reply=HTTP_buildreply(http, HTTPVERSION_INVALID+1, SUCCESS_OK);
1110 3 : ck_assert(NULL==reply);
1111 3 : HTTP_del(http);
1112 3 : }
1113 : END_TEST
1114 :
1115 3 : START_TEST(libhttp_buildreply_singleheader) {
1116 : HTTP_t* http;
1117 : char* reply;
1118 :
1119 3 : http=HTTP_new();
1120 3 : HTTP_addheader(http,"name1","value1");
1121 3 : reply=HTTP_buildreply(http, HTTPVERSION_HTTP11, SUCCESS_OK);
1122 3 : ck_assert(reply);
1123 3 : ck_assert(0==strcmp(reply,"HTTP/1.1 200 Dummy Reason\r\nname1: value1\r\n\r\n"));
1124 3 : free(reply);
1125 3 : HTTP_del(http);
1126 3 : }
1127 : END_TEST
1128 :
1129 :
1130 3 : START_TEST(libhttp_buildreply_multiheader) {
1131 : HTTP_t* http;
1132 : char* reply;
1133 :
1134 3 : http=HTTP_new();
1135 3 : HTTP_addheader(http,"name1","value1");
1136 3 : HTTP_addheader(http,"name2","value2");
1137 3 : reply=HTTP_buildreply(http, HTTPVERSION_HTTP11, SUCCESS_OK);
1138 3 : ck_assert(reply);
1139 3 : ck_assert(0==strcmp(reply,"HTTP/1.1 200 Dummy Reason\r\nname1: value1\r\nname2: value2\r\n\r\n"));
1140 3 : free(reply);
1141 3 : HTTP_del(http);
1142 3 : }
1143 : END_TEST
1144 :
1145 :
1146 3 : START_TEST(libhttp_buildreply_withbody) {
1147 : HTTP_t* http;
1148 : char* reply;
1149 :
1150 3 : http=HTTP_new();
1151 3 : HTTP_addheader(http,"name1","value1");
1152 3 : HTTP_addheader(http,"name2","value2");
1153 3 : HTTP_setbody(http,"<html></html>");
1154 3 : reply=HTTP_buildreply(http, HTTPVERSION_HTTP11, SUCCESS_OK);
1155 3 : ck_assert(reply);
1156 3 : ck_assert(0==strcmp(reply,"HTTP/1.1 200 Dummy Reason\r\nname1: value1\r\nname2: value2\r\n\r\n<html></html>"));
1157 3 : free(reply);
1158 3 : HTTP_del(http);
1159 3 : }
1160 : END_TEST
1161 :
1162 : /************************************************************************/
1163 : /* Begining of test (potentially in child) */
1164 231 : void libhttp_checked_common_setup() {
1165 231 : signals_catch();
1166 231 : forktest_gprofdir();
1167 231 : }
1168 :
1169 : /* End of test (potentially in child) */
1170 175 : void libhttp_checked_common_teardown() {
1171 175 : signals_release();
1172 175 : }
1173 : /************************************************************************/
1174 157 : void libhttp_unchecked_common_setup() {
1175 157 : forktest_init();
1176 157 : }
1177 3 : void libhttp_unchecked_common_teardown() {
1178 3 : }
1179 : /************************************************************************/
1180 158 : Suite* libhttp_suite() {
1181 : Suite *s;
1182 : TCase *tc;
1183 :
1184 158 : s = suite_create("LibHTTP");
1185 :
1186 158 : tc = tcase_create("LibHTTPUninitialized");
1187 158 : tcase_set_tags(tc,"LibHTTPTag LibHTTPTag2");
1188 : /* tcase_set_timeout(tc,5); */ /* seconds */
1189 158 : tcase_add_checked_fixture(tc, libhttp_checked_common_setup, libhttp_checked_common_teardown);
1190 158 : tcase_add_unchecked_fixture(tc, libhttp_unchecked_common_setup, libhttp_unchecked_common_teardown);
1191 158 : suite_add_tcase(s, tc);
1192 158 : tcase_add_test_raise_signal(tc, libhttp_test,6);
1193 158 : tcase_add_test(tc, libhttp_new);
1194 158 : tcase_add_test_raise_signal(tc, libhttp_del_null,SIG_ABRTSEGV);
1195 158 : tcase_add_test(tc, libhttp_del_empty);
1196 158 : tcase_add_test(tc, libhttp_del_populated);
1197 158 : tcase_add_test_raise_signal(tc, libhttp_setbody_nullhttp,SIG_ABRTSEGV);
1198 158 : tcase_add_test_raise_signal(tc, libhttp_setbody_nullbody,SIG_ABRTSEGV);
1199 158 : tcase_add_test(tc, libhttp_setbody_empty);
1200 158 : tcase_add_test(tc, libhttp_setbody_valid);
1201 158 : tcase_add_test_raise_signal(tc, libhttp_getbody_null,SIG_ABRTSEGV);
1202 158 : tcase_add_test(tc, libhttp_getbody_populated);
1203 158 : tcase_add_test_raise_signal(tc, libhttp_addheader_nullhttp,SIG_ABRTSEGV);
1204 158 : tcase_add_test_raise_signal(tc, libhttp_addheader_nullname,SIG_ABRTSEGV);
1205 158 : tcase_add_test_raise_signal(tc, libhttp_addheader_nullvalue,SIG_ABRTSEGV);
1206 158 : tcase_add_test(tc, libhttp_addheader_emptyname);
1207 158 : tcase_add_test(tc, libhttp_addheader_emptyvalue);
1208 158 : tcase_add_test(tc, libhttp_addheader_valid);
1209 158 : tcase_add_test_raise_signal(tc, libhttp_addbasicauth_nullhttp,SIG_ABRTSEGV);
1210 158 : tcase_add_test_raise_signal(tc, libhttp_addbasicauth_nulllogin,SIG_ABRTSEGV);
1211 158 : tcase_add_test_raise_signal(tc, libhttp_addbasicauth_nullpass,SIG_ABRTSEGV);
1212 158 : tcase_add_test(tc, libhttp_addbasicauth_emptylogin);
1213 158 : tcase_add_test(tc, libhttp_addbasicauth_emptypass);
1214 158 : tcase_add_test(tc, libhttp_addbasicauth_valid);
1215 158 : tcase_add_test_raise_signal(tc, libhttp_setname_nullheader,SIG_ABRTSEGV);
1216 158 : tcase_add_test_raise_signal(tc, libhttp_setname_nullname,SIG_ABRTSEGV);
1217 158 : tcase_add_test(tc, libhttp_setname_emptyname);
1218 158 : tcase_add_test(tc, libhttp_setname_valid);
1219 158 : tcase_add_test_raise_signal(tc, libhttp_getname_nullheader,SIG_ABRTSEGV);
1220 158 : tcase_add_test(tc, libhttp_getname_valid);
1221 158 : tcase_add_test_raise_signal(tc, libhttp_setvalue_nullheader,SIG_ABRTSEGV);
1222 158 : tcase_add_test_raise_signal(tc, libhttp_setvalue_nullvalue,SIG_ABRTSEGV);
1223 158 : tcase_add_test(tc, libhttp_setvalue_emptyvalue);
1224 158 : tcase_add_test(tc, libhttp_setvalue_valid);
1225 158 : tcase_add_test_raise_signal(tc, libhttp_getvalue_nullheader,SIG_ABRTSEGV);
1226 158 : tcase_add_test(tc, libhttp_getvalue_valid);
1227 158 : tcase_add_test_raise_signal(tc, libhttp_firstheader_nullhttp,SIG_ABRTSEGV);
1228 158 : tcase_add_test(tc, libhttp_firstheader_empty);
1229 158 : tcase_add_test(tc, libhttp_firstheader_single);
1230 158 : tcase_add_test(tc, libhttp_firstheader_multi);
1231 158 : tcase_add_test_raise_signal(tc, libhttp_nextheader_nullheader,SIG_ABRTSEGV);
1232 158 : tcase_add_test_raise_signal(tc, libhttp_nextheader_empty,SIG_ABRTSEGV);
1233 158 : tcase_add_test(tc, libhttp_nextheader_single);
1234 158 : tcase_add_test(tc, libhttp_nextheader_multi);
1235 158 : tcase_add_test_raise_signal(tc, libhttp_findheader_nullheader,SIG_ABRTSEGV);
1236 158 : tcase_add_test_raise_signal(tc, libhttp_findheader_nullname,SIG_ABRTSEGV);
1237 158 : tcase_add_test(tc, libhttp_findheader_emptyname);
1238 158 : tcase_add_test(tc, libhttp_findheader_missingname);
1239 158 : tcase_add_test(tc, libhttp_findheader_firstname);
1240 158 : tcase_add_test(tc, libhttp_findheader_middlename);
1241 158 : tcase_add_test(tc, libhttp_findheader_lastname);
1242 158 : tcase_add_test(tc, libhttp_findheader_secondmiddle);
1243 158 : tcase_add_test(tc, libhttp_findheader_secondlast);
1244 158 : tcase_add_test_raise_signal(tc, libhttp_remheader_nullhttp,SIG_ABRTSEGV);
1245 158 : tcase_add_test_raise_signal(tc, libhttp_remheader_nullheader,SIG_ABRTSEGV);
1246 158 : tcase_add_test(tc, libhttp_remheader_missingheader);
1247 158 : tcase_add_test(tc, libhttp_remheader_firstheader);
1248 158 : tcase_add_test(tc, libhttp_remheader_middleheader);
1249 158 : tcase_add_test(tc, libhttp_remheader_lastheader);
1250 158 : tcase_add_test(tc, libhttp_remheader_onlyheader);
1251 158 : tcase_add_test_raise_signal(tc, libhttp_buildheaders_null,SIG_ABRTSEGV);
1252 158 : tcase_add_test(tc, libhttp_buildheaders_empty);
1253 158 : tcase_add_test(tc, libhttp_buildheaders_single);
1254 158 : tcase_add_test(tc, libhttp_buildheaders_multi);
1255 : #if 0
1256 : tcase_add_test_raise_signal(tc, libhttp_parseheaders_null,SIG_ABRTSEGV);
1257 : tcase_add_test(tc, libhttp_parseheaders_empty);
1258 : tcase_add_test(tc, libhttp_parseheaders_single);
1259 : tcase_add_test(tc, libhttp_parseheaders_multi);
1260 : tcase_add_test(tc, libhttp_parseheaders_split);
1261 : tcase_add_test(tc, libhttp_parseheaders_invalid_nocolon);
1262 : tcase_add_test(tc, libhttp_parseheaders_invalid_novalue);
1263 : tcase_add_test(tc, libhttp_parseheaders_invalid_noname);
1264 : #endif
1265 158 : tcase_add_test_raise_signal(tc, libhttp_buildrequest_nullhttp,SIG_ABRTSEGV);
1266 158 : tcase_add_test_raise_signal(tc, libhttp_buildrequest_nulluri,SIG_ABRTSEGV);
1267 158 : tcase_add_test(tc, libhttp_buildrequest_badmethod);
1268 158 : tcase_add_test(tc, libhttp_buildrequest_badversion);
1269 158 : tcase_add_test(tc, libhttp_buildrequest_emptyuri);
1270 158 : tcase_add_test(tc, libhttp_buildrequest_noheader);
1271 158 : tcase_add_test(tc, libhttp_buildrequest_singleheader);
1272 158 : tcase_add_test(tc, libhttp_buildrequest_multiheader);
1273 : #if 0
1274 : tcase_add_test_raise_signal(tc, libhttp_parserequest_nullrequest,SIG_ABRTSEGV);
1275 : #endif
1276 158 : tcase_add_test_raise_signal(tc, libhttp_buildreply_nullhttp,SIG_ABRTSEGV);
1277 158 : tcase_add_test(tc, libhttp_buildreply_emptyhttp);
1278 158 : tcase_add_test(tc, libhttp_buildreply_invalidversion);
1279 158 : tcase_add_test(tc, libhttp_buildreply_singleheader);
1280 158 : tcase_add_test(tc, libhttp_buildreply_multiheader);
1281 158 : tcase_add_test(tc, libhttp_buildreply_withbody);
1282 : #if 0
1283 : tcase_add_test_raise_signal(tc, libhttp_parsereply_nullreply,SIG_ABRTSEGV);
1284 : #endif
1285 :
1286 158 : return s;
1287 : }
1288 : /* vim: set tw=80: */
|