Skip to content

Commit

Permalink
Make ServerTrust API tests more tolerant of multiple connections
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=266995
rdar://119839895

Reviewed by Ryosuke Niwa.

Bots indicate that sometimes these tests will make 2 TCP connections to the server,
which is ok and expected.  The tests only need to verify that more than 0 TLS handshakes
happened successfully.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
(-[ServerTrustDelegate webView:didReceiveAuthenticationChallenge:completionHandler:]):
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/272617@main
  • Loading branch information
achristensen07 committed Jan 3, 2024
1 parent bb9af3d commit d0deb6d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ - (size_t)authenticationChallengeCount

- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodServerTrust);
_authenticationChallengeCount++;
SecTrustRef trust = challenge.protectionSpace.serverTrust;
verifyCertificateAndPublicKey(trust);
Expand All @@ -608,7 +609,7 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
[delegate waitForDidFinishNavigation];

verifyCertificateAndPublicKey([webView serverTrust]);
EXPECT_EQ([delegate authenticationChallengeCount], 1u);
EXPECT_GT([delegate authenticationChallengeCount], 0u);
}

TEST(WebKit, FastServerTrust)
Expand All @@ -623,7 +624,7 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
[webView setNavigationDelegate:delegate.get()];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://localhost:%d/", server.port()]]]];
[delegate waitForDidFinishNavigation];
EXPECT_EQ([delegate authenticationChallengeCount], 1ull);
EXPECT_GT([delegate authenticationChallengeCount], 0u);
}

TEST(WebKit, ErrorSecureCoding)
Expand Down

0 comments on commit d0deb6d

Please sign in to comment.