Skip to content

Commit f7c3f8d

Browse files
committed
add clear auth handlers
1 parent cb1ef98 commit f7c3f8d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

rb/lib/selenium/webdriver/common/network.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def remove_auth_handler(id)
4141
@network.remove_intercept(intercept['intercept'])
4242
AUTH_CALLBACKS.delete(id)
4343
end
44+
45+
def clear_auth_handlers
46+
AUTH_CALLBACKS.each_key { |id| remove_auth_handler(id) }
47+
end
4448
end # Network
4549
end # WebDriver
4650
end # Selenium

rb/sig/lib/selenium/webdriver/common/network.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module Selenium
99

1010
def add_auth_handler: (String username, String password) -> String
1111

12+
def clear_auth_handlers: -> Hash[nil, nil]
13+
1214
def remove_auth_handler: (String id) -> nil
1315
end
1416
end

rb/spec/integration/selenium/webdriver/network_spec.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
module Selenium
2525
module WebDriver
26-
describe Network, only: { browser: %i[chrome edge firefox] } do
26+
describe Network, only: {browser: %i[chrome edge firefox]} do
2727
let(:username) { SpecSupport::RackServer::TestApp::BASIC_AUTH_CREDENTIALS.first }
2828
let(:password) { SpecSupport::RackServer::TestApp::BASIC_AUTH_CREDENTIALS.last }
2929

@@ -43,6 +43,16 @@ module WebDriver
4343
expect(described_class::AUTH_CALLBACKS.count).to be 0
4444
end
4545
end
46+
47+
it 'clears all auth handlers' do
48+
reset_driver!(web_socket_url: true) do |driver|
49+
network = described_class.new(driver)
50+
network.add_auth_handler(username, password)
51+
network.add_auth_handler(username, password)
52+
network.clear_auth_handlers
53+
expect(described_class::AUTH_CALLBACKS.count).to be 0
54+
end
55+
end
4656
end
4757
end
4858
end

0 commit comments

Comments
 (0)