Skip to content

Commit

Permalink
Add socks_version to Proxy - Issue SeleniumHQ#6938
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Feb 21, 2019
1 parent e69e2fa commit 6a717f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions rb/lib/selenium/webdriver/common/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class Proxy
auto_detect: 'autodetect',
socks: 'socksProxy',
socks_username: 'socksUsername',
socks_password: 'socksPassword'}.freeze
socks_password: 'socksPassword',
socks_version: 'socksVersion'}.freeze

ALLOWED.each_key { |t| attr_reader t }

Expand Down Expand Up @@ -117,6 +118,11 @@ def socks_password=(value)
@socks_password = value
end

def socks_version=(value)
self.type = :manual
@socks_version = value
end

def type=(type)
unless TYPES.key? type
raise ArgumentError, "invalid proxy type: #{type.inspect}, expected one of #{TYPES.keys.inspect}"
Expand All @@ -140,7 +146,8 @@ def as_json(*)
'autodetect' => auto_detect,
'socksProxy' => socks,
'socksUsername' => socks_username,
'socksPassword' => socks_password
'socksPassword' => socks_password,
'socksVersion' => socks_version
}.delete_if { |_k, v| v.nil? }

json_result if json_result.length > 1
Expand Down
5 changes: 4 additions & 1 deletion rb/spec/unit/selenium/webdriver/proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ module WebDriver
ssl: 'mythicalsslproxy',
socks: 'mythicalsocksproxy:65555',
socks_username: 'test',
socks_password: 'test'
socks_password: 'test',
socks_version: 5
}
end

Expand Down Expand Up @@ -61,6 +62,7 @@ module WebDriver
expect(proxy.socks).to eq(proxy_settings[:socks])
expect(proxy.socks_username).to eq(proxy_settings[:socks_username])
expect(proxy.socks_password).to eq(proxy_settings[:socks_password])
expect(proxy.socks_version).to eq(proxy_settings[:socks_version])
end

it 'should return a hash of the json properties to serialize' do
Expand All @@ -74,6 +76,7 @@ module WebDriver
expect(proxy_json['socksProxy']).to eq(proxy_settings[:socks])
expect(proxy_json['socksUsername']).to eq(proxy_settings[:socks_username])
expect(proxy_json['socksPassword']).to eq(proxy_settings[:socks_password])
expect(proxy_json['socksVersion']).to eq(proxy_settings[:socks_version])
end

it 'should configure a PAC proxy' do
Expand Down

0 comments on commit 6a717f2

Please sign in to comment.