From 201591e9fed6fc724e0047e3cd185cae1084c7f8 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Tue, 1 Dec 2020 01:57:52 +0000 Subject: [PATCH] added test for the socks5 non-happy path --- sig/plugins/proxy.rbs | 2 +- test/support/requests/plugins/proxy.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sig/plugins/proxy.rbs b/sig/plugins/proxy.rbs index 913c1f93..cdbc7bd7 100644 --- a/sig/plugins/proxy.rbs +++ b/sig/plugins/proxy.rbs @@ -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 diff --git a/test/support/requests/plugins/proxy.rb b/test/support/requests/plugins/proxy.rb index d4ee3374..49fa6e6d 100644 --- a/test/support/requests/plugins/proxy.rb +++ b/test/support/requests/plugins/proxy.rb @@ -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,