From 28cc9296f50cbcc805adc936d20c873d13ef2c4f Mon Sep 17 00:00:00 2001 From: Nick Muerdter <12112+GUI@users.noreply.github.com> Date: Thu, 17 Aug 2023 15:12:34 -0600 Subject: [PATCH] Fixes for Debian, Ruby, and Envoy upgrades. - Fix version of chromedriver for arm64 and chromium. - Fix error messages in tests for new Envoy version. - Fix for new libcurl in Debian Bookworm url-encoding some values in the path differently. - Fix for new libcurl no longer allowing invalid URLs for testing purposes with unescaped spaces. - Fix for new Ruby version in how capybara arguments are passed along. --- tasks/install-system-build-dependencies | 2 +- test/proxy/logging/test_basics.rb | 4 +-- test/proxy/logging/test_special_chars.rb | 31 ++++++++++--------- test/proxy/test_url_special_characters.rb | 16 ++++++++-- .../capybara_custom_bootstrap_inputs.rb | 2 +- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/tasks/install-system-build-dependencies b/tasks/install-system-build-dependencies index b242a110b..e17a0f0bf 100755 --- a/tasks/install-system-build-dependencies +++ b/tasks/install-system-build-dependencies @@ -65,7 +65,7 @@ if [ "${INSTALL_TEST_DEPENDENCIES:-}" == "true" ]; then # instead. chromedriver also doesn't exist, so use Electron's ARM builds # instead. CHROMIUM_VERSION="115.*" - CHROMEDRIVER_VERSION="26.0.0" + CHROMEDRIVER_VERSION="25.6.0" printf "Package: chromium*\nPin: version %s\nPin-Priority: 999\n" "$CHROMIUM_VERSION" > /etc/apt/preferences.d/chromium apt-get update apt-get -y --no-install-recommends install chromium curl unzip diff --git a/test/proxy/logging/test_basics.rb b/test/proxy/logging/test_basics.rb index 826801c4d..e2f730ade 100644 --- a/test/proxy/logging/test_basics.rb +++ b/test/proxy/logging/test_basics.rb @@ -412,13 +412,13 @@ def test_logs_requests_when_backend_is_down ]) do response = Typhoeus.get("http://127.0.0.1:9080/#{unique_test_id}/down", log_http_options) assert_response_code(503, response) - assert_match("upstream connect error or disconnect/reset before headers. retried and the latest reset reason: connection failure, transport failure reason: delayed connect error: 111", response.body) + assert_match("upstream connect error or disconnect/reset before headers. retried and the latest reset reason: remote connection failure, transport failure reason: delayed connect error: 111", response.body) record = wait_for_log(response)[:hit_source] assert_equal(503, record["response_status"]) assert_logs_base_fields(record, api_user) assert_equal("127.0.0.1:9450", record["api_backend_resolved_host"]) - assert_equal("upstream_reset_before_response_started{connection_failure,delayed_connect_error:_111}", record["api_backend_response_code_details"]) + assert_equal("upstream_reset_before_response_started{remote_connection_failure,delayed_connect_error:_111}", record["api_backend_response_code_details"]) assert_equal("UF,URX", record["api_backend_response_flags"]) assert_equal("cMsSf ", record["response_cache_flags"]) end diff --git a/test/proxy/logging/test_special_chars.rb b/test/proxy/logging/test_special_chars.rb index ce3ab7c02..2dd7241f7 100644 --- a/test/proxy/logging/test_special_chars.rb +++ b/test/proxy/logging/test_special_chars.rb @@ -45,7 +45,7 @@ def test_logs_utf8_urls assert_response_code(200, response) record = wait_for_log(response)[:hit_source] - assert_equal("/api/hello/utf8/%E2%9C%93/encoded_utf8/%E2%9C%93/", record["request_path"]) + assert_equal("/api/hello/utf8/%e2%9c%93/encoded_utf8/%E2%9C%93/", record["request_path"]) assert_equal("utf8=%E2%9C%93&utf8_url_encoded=%E2%9C%93&more_utf8=%C2%AC%C2%B6%C2%AA%C3%BE%C2%A4l&more_utf8_hex=%C2%AC%C2%B6%C2%AA%C3%BE%C2%A4l&more_utf8_hex_lowercase=%C2%AC%C2%B6%C2%AA%C3%BE%C2%A4l&actual_backslash_x=\\xC2\\xAC\\xC2\\xB6\\xC2\\xAA\\xC3\\xBE\\xC2\\xA4l", record["request_url_query"]) end @@ -67,10 +67,11 @@ def test_valid_utf8_encoding_in_url_path_url_params_headers # When in the URL path or query string, we expect the raw £ symbol to be # logged as the url encoded version. - expected_raw_in_url = url_encoded + expected_raw_in_url_path = url_encoded.downcase + expected_raw_in_url_query = url_encoded # URL - assert_equal("/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url}/", record["request_path"]) + assert_equal("/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url_path}/", record["request_path"]) if $config["elasticsearch"]["template_version"] < 2 assert_equal([ "0/127.0.0.1:9080/", @@ -78,7 +79,7 @@ def test_valid_utf8_encoding_in_url_path_url_params_headers "2/127.0.0.1:9080/api/hello/", "3/127.0.0.1:9080/api/hello/#{url_encoded}/", "4/127.0.0.1:9080/api/hello/#{url_encoded}/#{base64ed}/", - "5/127.0.0.1:9080/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url}", + "5/127.0.0.1:9080/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url_path}", ], record["request_hierarchy"]) refute(record.key?("request_url_hierarchy_level0")) refute(record.key?("request_url_hierarchy_level1")) @@ -93,11 +94,11 @@ def test_valid_utf8_encoding_in_url_path_url_params_headers assert_equal("hello/", record.fetch("request_url_hierarchy_level2")) assert_equal("#{url_encoded}/", record.fetch("request_url_hierarchy_level3")) assert_equal("#{base64ed}/", record.fetch("request_url_hierarchy_level4")) - assert_equal(expected_raw_in_url, record.fetch("request_url_hierarchy_level5")) + assert_equal(expected_raw_in_url_path, record.fetch("request_url_hierarchy_level5")) refute(record.key?("request_url_hierarchy_level6")) refute(record.key?("request_hierarchy")) end - assert_equal("url_encoded=#{url_encoded}&base64ed=#{base64ed}&raw=#{expected_raw_in_url}", record["request_url_query"]) + assert_equal("url_encoded=#{url_encoded}&base64ed=#{base64ed}&raw=#{expected_raw_in_url_query}", record["request_url_query"]) # HTTP headers assert_equal(url_encoded, record["request_content_type"]) @@ -127,13 +128,15 @@ def test_invalid_utf8_encoding_in_url_path_url_params_headers # Since the encoding of this string wasn't actually a valid UTF-8 string, # we test situations where it's sent as the raw ISO-8859-1 value, as well # as the UTF-8 replacement character. - expected_raw_in_url = url_encoded + expected_raw_in_url_path = url_encoded.downcase + expected_raw_in_url_query = url_encoded expected_raw_in_header = " " - expected_raw_utf8_in_url = "%EF%BF%BD" + expected_raw_utf8_in_url_path = "%ef%bf%bd" + expected_raw_utf8_in_url_query = "%EF%BF%BD" expected_raw_utf8_in_header = Base64.decode64("77+9").force_encoding("utf-8") # URL - assert_equal("/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url}/#{expected_raw_utf8_in_url}/", record["request_path"]) + assert_equal("/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url_path}/#{expected_raw_utf8_in_url_path}/", record["request_path"]) if $config["elasticsearch"]["template_version"] < 2 assert_equal([ "0/127.0.0.1:9080/", @@ -141,8 +144,8 @@ def test_invalid_utf8_encoding_in_url_path_url_params_headers "2/127.0.0.1:9080/api/hello/", "3/127.0.0.1:9080/api/hello/#{url_encoded}/", "4/127.0.0.1:9080/api/hello/#{url_encoded}/#{base64ed}/", - "5/127.0.0.1:9080/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url}/", - "6/127.0.0.1:9080/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url}/#{expected_raw_utf8_in_url}", + "5/127.0.0.1:9080/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url_path}/", + "6/127.0.0.1:9080/api/hello/#{url_encoded}/#{base64ed}/#{expected_raw_in_url_path}/#{expected_raw_utf8_in_url_path}", ], record["request_hierarchy"]) refute(record.key?("request_url_hierarchy_level0")) refute(record.key?("request_url_hierarchy_level1")) @@ -157,11 +160,11 @@ def test_invalid_utf8_encoding_in_url_path_url_params_headers assert_equal("hello/", record.fetch("request_url_hierarchy_level2")) assert_equal("#{url_encoded}/", record.fetch("request_url_hierarchy_level3")) assert_equal("#{base64ed}/", record.fetch("request_url_hierarchy_level4")) - assert_equal("#{expected_raw_in_url}/", record.fetch("request_url_hierarchy_level5")) - assert_equal(expected_raw_utf8_in_url, record.fetch("request_url_hierarchy_level6")) + assert_equal("#{expected_raw_in_url_path}/", record.fetch("request_url_hierarchy_level5")) + assert_equal(expected_raw_utf8_in_url_path, record.fetch("request_url_hierarchy_level6")) refute(record.key?("request_hierarchy")) end - assert_equal("url_encoded=#{url_encoded}&base64ed=#{base64ed}&raw=#{expected_raw_in_url}&raw_utf8=#{expected_raw_utf8_in_url}", record["request_url_query"]) + assert_equal("url_encoded=#{url_encoded}&base64ed=#{base64ed}&raw=#{expected_raw_in_url_query}&raw_utf8=#{expected_raw_utf8_in_url_query}", record["request_url_query"]) # HTTP headers assert_equal(url_encoded, record["request_content_type"]) diff --git a/test/proxy/test_url_special_characters.rb b/test/proxy/test_url_special_characters.rb index 80d807a09..ae7a95d6b 100644 --- a/test/proxy/test_url_special_characters.rb +++ b/test/proxy/test_url_special_characters.rb @@ -36,13 +36,25 @@ def test_slashes_urls end def test_unescaped_spaces_path_url + # Newer versions of libcurl no longer allow even making a request with an + # unescaped space, so validate curl/Typhoeus's behavior, but then do the + # actual test with Net/HTTP which allows for this. response = Typhoeus.get("http://127.0.0.1:9080/api/info/space/ /", http_options) - assert_response_code(400, response) + assert_equal(:url_malformat, response.return_code) + + response = Net::HTTP.get_response("127.0.0.1", "/api/info/space/ /", 9080) + assert_equal("400", response.code) end def test_unescaped_spaces_query_url + # Newer versions of libcurl no longer allow even making a request with an + # unescaped space, so validate curl/Typhoeus's behavior, but then do the + # actual test with Net/HTTP which allows for this. response = Typhoeus.get("http://127.0.0.1:9080/api/info/space/?space= &foo", http_options) - assert_response_code(400, response) + assert_equal(:url_malformat, response.return_code) + + response = Net::HTTP.get_response("127.0.0.1", "/api/info/space/?space= &foo", 9080) + assert_equal("400", response.code) end def test_escaped_spaces_urls diff --git a/test/support/api_umbrella_test_helpers/capybara_custom_bootstrap_inputs.rb b/test/support/api_umbrella_test_helpers/capybara_custom_bootstrap_inputs.rb index dae95ef9b..7b757e0e8 100644 --- a/test/support/api_umbrella_test_helpers/capybara_custom_bootstrap_inputs.rb +++ b/test/support/api_umbrella_test_helpers/capybara_custom_bootstrap_inputs.rb @@ -29,7 +29,7 @@ def _custom_check_with_label(selector, checked, locator, **options) options[:allow_self] = true if locator.nil? click_options = options.delete(:click) || { :x => 1, :y => 1 } - el = find(selector, locator, options.merge(:visible => :all)) + el = find(selector, locator, **options.merge(:visible => :all)) el.session.find(:label, :for => el, :visible => true).click(**click_options) unless el.checked? == checked ensure Capybara.w3c_click_offset = original_w3c_click_offset