From dc62dec5858946b20a23fc5f26f2aadbadf7d6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20B=C3=A9ky?= Date: Wed, 18 Jan 2023 14:48:55 -0500 Subject: [PATCH] Fix universal header validation case. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When universal header validation is enabled, HTTP_PARSER_STRICT is defined to be 0, and http-parser gives different error messages. Signed-off-by: Bence Béky --- test/common/http/http1/codec_impl_test.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/common/http/http1/codec_impl_test.cc b/test/common/http/http1/codec_impl_test.cc index 411ff103c425..4553284ce25d 100644 --- a/test/common/http/http1/codec_impl_test.cc +++ b/test/common/http/http1/codec_impl_test.cc @@ -908,6 +908,7 @@ TEST_P(Http1ServerConnectionImplTest, Http10MultipleResponses) { } } +// SPELLCHECKER(off) struct { const absl::string_view http_version; const absl::optional balsa_parser_expected_error; @@ -915,13 +916,17 @@ struct { } kRequestHTTPStringTestCases[] = {{"", {}, {}}, // HTTP/0.9 has no HTTP-version. {"HTTP/9.1", {}, {}}, {"aHTTP/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_CONSTANT"}, - // SPELLCHECKER(off) +#ifdef ENVOY_ENABLE_UHV + {"HHTTP/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}, + {"HTTPS/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}, +#else {"HHTTP/1.1", "HPE_INVALID_VERSION", "HPE_STRICT"}, - // SPELLCHECKER(on) {"HTTPS/1.1", "HPE_INVALID_VERSION", "HPE_STRICT"}, +#endif {"FTP/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_CONSTANT"}, {"HTTP/1.01", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}, {"HTTP/A.0", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}}; +// SPELLCHECKER(on) TEST_P(Http1ServerConnectionImplTest, HttpVersion) { for (const auto& test_case : kRequestHTTPStringTestCases) { @@ -3837,19 +3842,24 @@ TEST_P(Http1ClientConnectionImplTest, ResponseHttpVersion) { } } +// SPELLCHECKER(off) struct { const absl::string_view http_version; const absl::optional balsa_parser_expected_error; const absl::optional http_parser_expected_error; } kResponseHTTPStringTestCases[] = {{"HTTP/9.1", {}, {}}, {"aHTTP/1.1", "HPE_INVALID_CONSTANT", "HPE_INVALID_CONSTANT"}, - // SPELLCHECKER(off) +#ifdef ENVOY_ENABLE_UHV + {"HHTTP/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}, + {"HTTPS/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}, +#else {"HHTTP/1.1", "HPE_INVALID_VERSION", "HPE_STRICT"}, - // SPELLCHECKER(on) {"HTTPS/1.1", "HPE_INVALID_VERSION", "HPE_STRICT"}, +#endif {"FTP/1.1", "HPE_INVALID_CONSTANT", "HPE_INVALID_CONSTANT"}, {"HTTP/1.01", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}, {"HTTP/A.0", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}}; +// SPELLCHECKER(on) TEST_P(Http1ClientConnectionImplTest, HttpVersion) { for (const auto& test_case : kResponseHTTPStringTestCases) {