![]() |
Bitcoin Core 32.1.0
P2P Digital Currency
|
#include <httpserver.h>#include <rpc/protocol.h>#include <test/util/common.h>#include <test/util/logging.h>#include <test/util/setup_common.h>#include <util/string.h>#include <util/threadpool.h>#include <boost/test/unit_test.hpp>Go to the source code of this file.
Functions | |
| BOOST_FIXTURE_TEST_SUITE (httpserver_tests, SocketTestingSetup) BOOST_AUTO_TEST_CASE(test_query_parameters) | |
| BOOST_AUTO_TEST_CASE (http_headers_tests) | |
| BOOST_AUTO_TEST_CASE (http_response_tests) | |
| BOOST_AUTO_TEST_CASE (http_request_tests) | |
| BOOST_CHECK (req.LoadControlData(reader)) | |
| BOOST_CHECK (!req.LoadHeaders(reader)) | |
| LineReader | reader ("GET / HTTP/1.0\r\n\r\n" R"({"method":"getblockcount"})", MAX_HEADERS_SIZE) |
| BOOST_CHECK_EQUAL (req.ReadBody(), "") | |
| LineReader | reader ("GET / HTTP/1.0\r\nContent-Length: eleven\r\n\r\n" R"({"method":"getblockcount"})", MAX_HEADERS_SIZE) |
| BOOST_CHECK_EXCEPTION (req.LoadBody(reader), std::runtime_error, HasReason{"Cannot parse Content-Length value"}) | |
| LineReader | reader ("GET / HTTP/1.0\r\nContent-Length: -8\r\n\r\n" R"({"method":"getblockcount"})", MAX_HEADERS_SIZE) |
| std::string | huge_body (excessive_size, 'x') |
| LineReader | reader (request, MAX_HEADERS_SIZE) |
| BOOST_CHECK_EXCEPTION (req.LoadBody(reader), ContentTooLargeError, HasReason{"Max body size exceeded"}) | |
| LineReader | reader ("GET / HTTP/1.0\r\nContent-Length: 1024\r\n\r\n" R"({"method":"getblockcount"})", MAX_HEADERS_SIZE) |
| LineReader | reader (ok_chunked, MAX_HEADERS_SIZE) |
| BOOST_CHECK_EQUAL (req.ReadBody(), R"({"method":"getblockcount"})") | |
| LineReader | reader (excessive_chunk_size, MAX_HEADERS_SIZE) |
| BOOST_CHECK_EXCEPTION (req.LoadBody(reader), ContentTooLargeError, HasReason{"Chunk will exceed max body size"}) | |
| BOOST_CHECK_EQUAL (reader.Remaining(), 0) | |
| BOOST_CHECK (!req.GetHeader("Expires")) | |
| LineReader | reader (invalid_chunked, MAX_HEADERS_SIZE) |
| BOOST_CHECK_EXCEPTION (req.LoadBody(reader), std::runtime_error, HasReason{"Cannot parse chunk length value"}) | |
| BOOST_CHECK_EXCEPTION (req.LoadBody(reader), std::runtime_error, HasReason{"Improperly terminated chunk"}) | |
| BOOST_AUTO_TEST_CASE (http_request_state_tests) | |
| BOOST_AUTO_TEST_CASE (http_server_socket_tests) | |
Variables | |
| constexpr std::string_view | full_request |
| LineReader | reader ("GET / HTTP/1.0\r\nHost: ", MAX_HEADERS_SIZE) |
| const std::string | request {"GET / HTTP/1.0\r\nContent-Length: " + util::ToString(excessive_size) + "\r\n\r\n" + std::move(huge_body)} |
| HTTPRequest | req |
| std::string_view | ok_chunked |
| std::string_view | excessive_chunk_size |
| std::string_view | invalid_chunked |
| BOOST_AUTO_TEST_CASE | ( | http_headers_tests | ) |
Definition at line 76 of file httpserver_tests.cpp.
| BOOST_AUTO_TEST_CASE | ( | http_request_state_tests | ) |
Definition at line 371 of file httpserver_tests.cpp.
| BOOST_AUTO_TEST_CASE | ( | http_request_tests | ) |
| BOOST_AUTO_TEST_CASE | ( | http_response_tests | ) |
| BOOST_AUTO_TEST_CASE | ( | http_server_socket_tests | ) |
| BOOST_CHECK | ( | !req. | GetHeader"Expires" | ) |
| BOOST_CHECK | ( | !req. | LoadHeadersreader | ) |
| BOOST_CHECK | ( | req. | LoadControlDatareader | ) |
| BOOST_CHECK_EQUAL | ( | reader. | Remaining(), |
| 0 | ) |
| BOOST_CHECK_EQUAL | ( | req. | ReadBody(), |
| "" | ) |
| BOOST_CHECK_EQUAL | ( | req. | ReadBody(), |
| R"({"method":"getblockcount"})" | ) |
| BOOST_CHECK_EXCEPTION | ( | req. | LoadBodyreader, |
| ContentTooLargeError | , | ||
| HasReason{"Chunk will exceed max body size"} | ) |
| BOOST_CHECK_EXCEPTION | ( | req. | LoadBodyreader, |
| ContentTooLargeError | , | ||
| HasReason{"Max body size exceeded"} | ) |
| BOOST_CHECK_EXCEPTION | ( | req. | LoadBodyreader, |
| std::runtime_error | , | ||
| HasReason{"Cannot parse chunk length value"} | ) |
| BOOST_CHECK_EXCEPTION | ( | req. | LoadBodyreader, |
| std::runtime_error | , | ||
| HasReason{"Cannot parse Content-Length value"} | ) |
| BOOST_CHECK_EXCEPTION | ( | req. | LoadBodyreader, |
| std::runtime_error | , | ||
| HasReason{"Improperly terminated chunk"} | ) |
| BOOST_FIXTURE_TEST_SUITE | ( | httpserver_tests | , |
| SocketTestingSetup | ) |
Definition at line 28 of file httpserver_tests.cpp.
| std::string huge_body | ( | excessive_size | , |
| 'x' | ) |
| LineReader reader | ( | "GET / HTTP/1.0\r\n\r\n" R"({"method":"getblockcount"})" | , |
| MAX_HEADERS_SIZE | ) |
| LineReader reader | ( | "GET / HTTP/1.0\r\nContent-Length: -8\r\n\r\n" R"({"method":"getblockcount"})" | , |
| MAX_HEADERS_SIZE | ) |
| LineReader reader | ( | "GET / HTTP/1.0\r\nContent-Length: 1024\r\n\r\n" R"({"method":"getblockcount"})" | , |
| MAX_HEADERS_SIZE | ) |
| LineReader reader | ( | "GET / HTTP/1.0\r\nContent-Length: eleven\r\n\r\n" R"({"method":"getblockcount"})" | , |
| MAX_HEADERS_SIZE | ) |
| LineReader reader | ( | excessive_chunk_size | , |
| MAX_HEADERS_SIZE | ) |
| LineReader reader | ( | invalid_chunked | , |
| MAX_HEADERS_SIZE | ) |
| LineReader reader | ( | ok_chunked | , |
| MAX_HEADERS_SIZE | ) |
| LineReader reader | ( | request | , |
| MAX_HEADERS_SIZE | ) |
| std::string_view excessive_chunk_size |
Definition at line 299 of file httpserver_tests.cpp.
|
constexpr |
Definition at line 19 of file httpserver_tests.cpp.
| std::string_view invalid_chunked |
Definition at line 338 of file httpserver_tests.cpp.
| std::string_view ok_chunked |
Definition at line 281 of file httpserver_tests.cpp.
| LineReader reader | ( | "GET / HTTP/1.0\r\nHost: " | , |
| MAX_HEADERS_SIZE | ) |
| HTTPRequest req |
Definition at line 253 of file httpserver_tests.cpp.
| const std::string request {"GET / HTTP/1.0\r\nContent-Length: " + util::ToString(excessive_size) + "\r\n\r\n" + std::move(huge_body)} |
Definition at line 252 of file httpserver_tests.cpp.