added test for the socks5 non-happy path

This commit is contained in:
HoneyryderChuck 2020-12-01 01:57:52 +00:00
parent b83d52a284
commit 201591e9fe
2 changed files with 13 additions and 2 deletions

View File

@ -18,7 +18,7 @@ module HTTPX
private
def initialize: (uri: uri, ?username: string, ?password: string) -> untyped
def initialize: (uri: uri | URI::Generic, ?username: string, ?password: string) -> untyped
end
# def self.configure: (singleton(Session)) -> void

View File

@ -30,7 +30,7 @@ module Requests
end
def test_plugin_http_proxy_auth_error
no_auth_proxy = URI.parse(http_proxy.first)
no_auth_proxy = URI(http_proxy.first)
return unless no_auth_proxy.user
no_auth_proxy.user = nil
@ -66,6 +66,17 @@ module Requests
verify_body_length(response)
end
def test_plugin_socks5_proxy_error
proxy = URI(socks5_proxy.first)
proxy.password = nil
session = HTTPX.plugin(:proxy).with_proxy(uri: [proxy])
uri = build_uri("/get")
response = session.get(uri)
assert response.is_a?(HTTPX::ErrorResponse), "should be a response error"
assert response.error.is_a?(HTTPX::Socks5Error), "should be a socks 5 error"
end
def test_plugin_ssh_proxy
skip if RUBY_ENGINE == "jruby"
session = HTTPX.plugin(:"proxy/ssh").with_proxy(uri: ssh_proxy,