Allow multiple basic auths in one session

This commit is contained in:
nritholtz 2015-04-11 21:08:28 -04:00 committed by Joe Ferris
parent c0c9d701ef
commit e49176beac
3 changed files with 20 additions and 1 deletions

View File

@ -2566,6 +2566,16 @@ CACHE MANIFEST
lambda { visit("/") }.should_not raise_error
driver.status_code.should eq 401
end
it "can be reset with subsequent authenticate call", skip_on_qt4: true do
driver.browser.authenticate('user', 'password')
visit("/")
driver.html.should include("Basic "+Base64.encode64("user:password").strip)
driver.browser.authenticate('user1', 'password1')
driver.browser.timeout = 2
lambda { visit("/") }.should_not raise_error
driver.status_code.should eq 401
end
end
describe "url blacklisting", skip_if_offline: true do

View File

@ -29,7 +29,7 @@ def has_internet?
begin
dns_resolver.getaddress("example.com")
true
rescue Resolv::ResolvError => e
rescue Resolv::ResolvError
false
end
end
@ -42,6 +42,11 @@ RSpec.configure do |c|
c.filter_run_excluding :selenium_compatibility => (Capybara::VERSION =~ /^2\.4\./).nil?
c.filter_run_excluding :skip_if_offline => !has_internet?
#Check for QT version is 4 to skip QT5 required specs
#This should be removed once support for QT4 is dropped
require 'capybara_webkit_builder'
c.filter_run_excluding :skip_on_qt4 => !(%x(#{CapybaraWebkitBuilder.qmake_bin} -v).match(/Using Qt version 4/)).nil?
# We can't support outerWidth and outerHeight without a visible window.
# We focus the next window instead of failing when closing windows.
c.filter_run_excluding :full_description =>

View File

@ -11,6 +11,10 @@ void Authenticate::start() {
QString password = arguments()[1];
NetworkAccessManager* networkAccessManager = manager()->networkAccessManager();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
//Reset Authentication cache
networkAccessManager->clearAccessCache();
#endif
networkAccessManager->setUserName(username);
networkAccessManager->setPassword(password);