Cask::Audit: Align user agents with livecheck

The `#page_headers` and `#page_content` methods in
`Livecheck::Strategy` will fetch a URL using our default user agent
but if the request fails it will retry with the `:browser` user agent.
[For context, it was added as an interim measure to make URLs work
that require a different user agent but I aim to remove it in the
future in favor of specifying the user agent in a `livecheck` block
(so we don't make unnecessary requests that we know will fail).]

`Cask::Audit#audit_livecheck_https_availability` checks the
`livecheck` block URL but it only does so using our default user
agent (i.e., it calls `#validate_url_for_https_availability` which
calls `Utils::Curl#curl_check_http_content` which has a `user_agents:
[:default]` parameter). Due to this behavioral mismatch, it's possible
for a `livecheck` block to work but for this cask audit to fail.

This addresses the issue by adding `user_agents: [:default, :browser]`
to the arguments the audit uses, which aligns its behavior with
livecheck's.
This commit is contained in:
Sam Ford 2024-06-08 10:33:48 -04:00
parent 214359316f
commit fcc87c901d
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -839,7 +839,8 @@ module Cask
validate_url_for_https_availability(
url, "livecheck URL",
check_content: true
check_content: true,
user_agents: [:default, :browser]
)
end