Commit 3be9e7c
authored
Add tests for untested HTTP methods and request/response getters (#362)
* Add tests for untested HTTP methods and request/response getters
- Add HEAD, OPTIONS, TRACE method handlers to complete_test_resource
- Add integration tests for HEAD, OPTIONS, TRACE HTTP methods
- Add request_info_resource and test for get_requestor(), get_requestor_port(), get_version()
- Add content_limit_suite to test content_too_large() with content_size_limit
- Add unregister_then_404 test for webserver::unregister_resource()
- Create http_response unit test file with tests for response code, headers, footers, and cookies
These tests increase coverage for previously untested code paths in
webserver.cpp, http_request.cpp, and http_response.cpp.
* Add additional coverage tests for networking and TLS features
- Add IPv6 and dual-stack webserver tests
- Add HTTPS webserver and TLS session getter tests with graceful failure handling
- Add bind_address_ipv4 test with runtime URL building
- Add shoutcast response test for MHD_ICY_FLAG verification
- Add string_response constructor tests
- Remove CONNECT method test (incompatible with curl's tunneling semantics)
Coverage improved from ~90% to 91.8% lines, 93.3% functions.
* Add print-summary to gcovr for coverage debugging
Add --print-summary flag to gcovr command in CI to help diagnose
the discrepancy between local coverage (91.8%) and Codecov (64.53%).
* Filter gcovr to src/ directory only
The coverage report was including 15,781 lines from system headers and
dependencies instead of just the ~1,500 lines of libhttpserver source.
Use --filter to restrict coverage to src/ directory only.
* Add coverage tests for footers, PSK handlers, and ban/allow weights
- Add footer/trailer tests for http_request and http_response
- Add PSK handler configuration tests (setup, empty handler, no handler)
- Add ban/allow IP weight comparison tests for specific-then-wildcard case
- Add auth skip path tests for root path and wildcards
- Add IPv6 parsing edge case tests (too many parts, wildcards, nested)
- Add http_endpoint invalid regex pattern test
- Add custom error handler tests (not_found, method_not_allowed)
- Add request info caching tests
Branch coverage: 60.4% -> 64.2% (+65 branches)
Line coverage: 91.8% -> 94.9%
* Add Phase 2 branch coverage tests for http_request and http_endpoint
- Add null value query parameter test covering nullptr branches in
build_request_args and build_request_querystring (lines 234, 248)
- Add digested user caching tests for cache hit and nullptr branches
(lines 293-295, 300) in http_request.cpp
- Add caret prefix URL pattern tests covering line 85 in http_endpoint.cpp
- Add consecutive slashes URL test covering empty parts handling (line 83)
Branch coverage improvements:
- http_endpoint.cpp: 66.9% -> 68.7%
- http_request.cpp: 58.5% -> 59.7%
* Add Phase 3 branch coverage tests for render methods and error handling
- Add tests for all HTTP methods falling through to base render()
- Add custom internal error resource handler test
- Add get_arg_flat fallback test
- Add large multipart form field test (100KB)
- Add file upload with explicit content-type header test
- Add http_endpoint tests for regex validation and error paths
- Add tests for invalid URL parameter formats
* Fix cpplint issues in test files
- Replace static global strings with function-static pattern
- Change 'long' to 'int64_t' for http_code variables
- Add missing #include <utility> for std::move
* Added PSK tests
* Fix Windows test failure and add hex utility coverage
- Fix file_upload tests to use subdirectory instead of /tmp for
cross-platform compatibility
- Extract hex validation functions (is_valid_hex, hex_char_to_val)
from webserver.cpp to string_utilities for testability
- Add unit tests for hex utility functions to improve coverage
* Fix Windows mkdir compatibility issue
On Windows/MinGW, mkdir() only takes one argument (path), while
POSIX mkdir() takes two (path and mode). Add a MKDIR macro that
uses the appropriate signature for each platform.1 parent 77b089a commit 3be9e7c
File tree
17 files changed
+4735
-22
lines changed- .github/workflows
- src
- httpserver
- test
- integ
- unit
17 files changed
+4735
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
473 | | - | |
| 473 | + | |
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| |||
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
671 | | - | |
| 671 | + | |
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
45 | 59 | | |
46 | 60 | | |
47 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
231 | 233 | | |
232 | | - | |
| 234 | + | |
| 235 | + | |
233 | 236 | | |
234 | 237 | | |
235 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
58 | 75 | | |
59 | 76 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| |||
425 | 430 | | |
426 | 431 | | |
427 | 432 | | |
428 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
429 | 439 | | |
430 | | - | |
431 | | - | |
432 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
433 | 449 | | |
434 | 450 | | |
435 | 451 | | |
| |||
440 | 456 | | |
441 | 457 | | |
442 | 458 | | |
443 | | - | |
| 459 | + | |
444 | 460 | | |
445 | | - | |
446 | | - | |
| 461 | + | |
| 462 | + | |
447 | 463 | | |
448 | 464 | | |
449 | 465 | | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
456 | 469 | | |
457 | 470 | | |
458 | 471 | | |
459 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
460 | 481 | | |
461 | 482 | | |
462 | 483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
0 commit comments