REGRESSION(r230681) Do not use stored credentials if WKBundlePageResourceLoadClient...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Apr 2019 23:05:48 +0000 (23:05 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Apr 2019 23:05:48 +0000 (23:05 +0000)
commitc05606d54390c3c8184902aef2cd19693309ac4b
tree673c262472b6f6dc53324c2efb8e07d381acf39b
parent4f51050b729c780be5406ddb8defaa371dc4cf9e
REGRESSION(r230681) Do not use stored credentials if WKBundlePageResourceLoadClient.shouldUseCredentialStorage returns false
https://bugs.webkit.org/show_bug.cgi?id=197093
<rdar://problem/49708268>

Reviewed by Chris Dumez.

Source/WebKit:

Only get the StoredCredentialsPolicy from the NetworkLoadChecker if we haven't already been told not to use credentials.
Also add some test infrastructure for clearing persistent credentials added by the test.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::removeCredential):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::startNetworkLoad):
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::removeCredential):
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _removeCredential:forProtectionSpace:completionHandler:]):
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::removeCredential):
* UIProcess/WebProcessPool.h:

Tools:

Add a test that does two loads.  The first load shouldUseCredentialStorage returns true and we provide a persistent credential.
The second load shouldUseCredentialStorage returns false and we verify that a challenge is received with no suggested credential.
We also need to make the TCPServer able to handle more than one connection because we need these two loads to come from the same protection space,
and our current Cocoa implementation of NetworkSession uses two NSURLSessions that don't share a connection cache, one for loads with credentials
and one for loads without credentials, so there are two TCP connections to the same server in this test.

* TestWebKitAPI/TCPServer.cpp:
(TestWebKitAPI::TCPServer::TCPServer):
(TestWebKitAPI::TCPServer::~TCPServer):
(TestWebKitAPI::TCPServer::socketBindListen):
(TestWebKitAPI::TCPServer::waitForAndReplyToRequests): Deleted.
* TestWebKitAPI/TCPServer.h:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/BasicProposedCredentialPlugIn.mm: Added.
(-[BasicProposedCredentialPlugIn webProcessPlugIn:didCreateBrowserContextController:]):
* TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
(respondWithChallengeThenOK):
(TestWebKitAPI::TEST):
(-[ProposedCredentialDelegate webView:didFinishNavigation:]):
(-[ProposedCredentialDelegate webView:didReceiveAuthenticationChallenge:completionHandler:]):
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244521 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Tools/ChangeLog
Tools/TestWebKitAPI/TCPServer.cpp
Tools/TestWebKitAPI/TCPServer.h
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/BasicProposedCredentialPlugIn.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm