Skip to content

Commit

Permalink
Fixes for Debian, Ruby, and Envoy upgrades.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
GUI committed Aug 17, 2023
1 parent f1475b5 commit 28cc929
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tasks/install-system-build-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/proxy/logging/test_basics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 17 additions & 14 deletions test/proxy/logging/test_special_chars.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -67,18 +67,19 @@ 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/",
"1/127.0.0.1:9080/api/",
"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"))
Expand All @@ -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"])
Expand Down Expand Up @@ -127,22 +128,24 @@ 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/",
"1/127.0.0.1:9080/api/",
"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"))
Expand All @@ -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"])
Expand Down
16 changes: 14 additions & 2 deletions test/proxy/test_url_special_characters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 28cc929

Please sign in to comment.