Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow doesn't match when url is https and includes path, because Addressable::URI#to_s includes port in the string #977

Open
henrahmagix opened this issue Jun 1, 2022 · 0 comments · May be fixed by #978

Comments

@henrahmagix
Copy link

When WebMock.disallow_net_connect! is called with:

WebMock.disallow_net_connect!(allow: ['https://github.com/mozilla/geckodriver/releases/latest'])

it fails to allow requests to that url because the uri that comes into net_connect_explicit_allowed? is an Addressable::URI, who's #to_s method returns a string with the port in.

For example:

require 'webmock'
allowed = "https://github.com/mozilla/geckodriver/releases/latest"
uri = WebMock::Util::URI.normalize_uri(allowed)
puts uri.class
# Addressable::URI
puts uri.to_s
# https://github.com:443/mozilla/geckodriver/releases/latest

puts allowed == uri.to_s ||
      allowed == uri.host ||
      allowed == "#{uri.host}:#{uri.port}" ||
      allowed == "#{uri.scheme}://#{uri.host}:#{uri.port}" ||
      allowed == "#{uri.scheme}://#{uri.host}" && uri.port == uri.default_port
# false

FYI such requests happen automatically in capybara/selenium-webdriver/webdrivers when using firefox driver.

henrahmagix added a commit to henrahmagix/webmock that referenced this issue Jun 1, 2022
@henrahmagix henrahmagix linked a pull request Jun 1, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant