handle http auth (#138)

abort brozzling on insterstial (auth dialog)

because we have no other recourse at this point. waiting on Network.requestIntercepted auth challenge support. (didn't work in our latest testing)
https://chromedevtools.github.io/devtools-protocol/tot/Network#type-AuthChallengeResponse
This commit is contained in:
Barbara Miller 2018-11-16 15:10:30 -08:00 committed by Noah Levitt
parent 15610fa990
commit e2b2542d4a
5 changed files with 30 additions and 6 deletions

View file

@ -62,6 +62,13 @@ def httpd(request):
self.send_header('Content-Length', len(payload))
self.end_headers()
self.wfile.write(payload)
elif self.path == '/401':
self.send_response(401)
self.send_header('WWW-Authenticate', 'Basic realm=\"Test\"')
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(self.headers.getheader('Authorization'))
self.wfile.write('not authenticated')
else:
super().do_GET()
@ -111,6 +118,13 @@ def test_aw_snap_hes_dead_jim():
with pytest.raises(brozzler.BrowsingException):
browser.browse_page('chrome://crash')
def test_page_interstitial_exception(httpd):
chrome_exe = brozzler.suggest_default_chrome_exe()
url = 'http://localhost:%s/401' % httpd.server_port
with brozzler.Browser(chrome_exe=chrome_exe) as browser:
with pytest.raises(brozzler.PageInterstitialShown):
browser.browse_page(url)
def test_on_response(httpd):
response_urls = []
def on_response(msg):