Modified: trunk/Tools/ChangeLog (267447 => 267448)
--- trunk/Tools/ChangeLog 2020-09-23 00:04:52 UTC (rev 267447)
+++ trunk/Tools/ChangeLog 2020-09-23 00:11:00 UTC (rev 267448)
@@ -1,3 +1,17 @@
+2020-09-22 Alex Christensen <[email protected]>
+
+ Make TLSVersion API tests more robust.
+ https://bugs.webkit.org/show_bug.cgi?id=216704
+
+ Like I did in r267278, the TLSVersion.ShouldAllowDeprecatedTLS API test was also asserting with TCPServer,
+ so use HTTPServer which gracefully handles a variable number of connection attempts.
+ The NetworkSession tests that use NSUserDefaults need to be split into a separate test for bug 216041,
+ so may as well do that here, too.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
+ (TestWebKitAPI::makeWebViewWith):
+ (TestWebKitAPI::TEST):
+
2020-09-22 Aakash Jain <[email protected]>
Limit number of emails to send for flaky and pre-existing JSC test failures
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm (267447 => 267448)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm 2020-09-23 00:04:52 UTC (rev 267447)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm 2020-09-23 00:11:00 UTC (rev 267448)
@@ -140,7 +140,6 @@
namespace TestWebKitAPI {
const uint16_t tls1_1 = 0x0302;
-static NSString *defaultsKey = @"WebKitEnableLegacyTLS";
#if HAVE(TLS_PROTOCOL_VERSION_T)
@@ -162,28 +161,30 @@
#if HAVE(TLS_VERSION_DURING_CHALLENGE)
+RetainPtr<WKWebView> makeWebViewWith(WKWebsiteDataStore *store, RetainPtr<TestNavigationDelegate> delegate)
+{
+ WKWebViewConfiguration *configuration = [[[WKWebViewConfiguration alloc] init] autorelease];
+ configuration.websiteDataStore = store;
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
+ [webView setNavigationDelegate:delegate.get()];
+ [delegate setDidReceiveAuthenticationChallenge:^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^callback)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) {
+ EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodServerTrust);
+ callback(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
+ }];
+ return webView;
+};
+
TEST(TLSVersion, NetworkSession)
{
HTTPServer server(HTTPServer::respondWithOK, HTTPServer::Protocol::HttpsWithLegacyTLS);
- static auto delegate = adoptNS([TestNavigationDelegate new]);
- auto makeWebViewWith = [&] (WKWebsiteDataStore *store) {
- WKWebViewConfiguration *configuration = [[[WKWebViewConfiguration alloc] init] autorelease];
- configuration.websiteDataStore = store;
- auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
- [webView setNavigationDelegate:delegate.get()];
- [delegate setDidReceiveAuthenticationChallenge:^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^callback)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) {
- EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodServerTrust);
- callback(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
- }];
- return webView;
- };
+ auto delegate = adoptNS([TestNavigationDelegate new]);
{
- auto webView = makeWebViewWith([WKWebsiteDataStore defaultDataStore]);
+ auto webView = makeWebViewWith([WKWebsiteDataStore defaultDataStore], delegate);
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];
[delegate waitForDidFinishNavigation];
}
{
- auto webView = makeWebViewWith([WKWebsiteDataStore nonPersistentDataStore]);
+ auto webView = makeWebViewWith([WKWebsiteDataStore nonPersistentDataStore], delegate);
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];
[delegate waitForDidFinishNavigation];
}
@@ -191,18 +192,26 @@
auto configuration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration]);
[configuration setLegacyTLSEnabled:NO];
auto dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:configuration.get()]);
- auto webView = makeWebViewWith(dataStore.get());
+ auto webView = makeWebViewWith(dataStore.get(), delegate);
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];
[delegate waitForDidFailProvisionalNavigation];
}
+}
+
+TEST(TLSVersion, NetworkSessionNSUserDefaults)
+{
+ NSString *defaultsKey = @"WebKitEnableLegacyTLS";
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:defaultsKey];
+
+ HTTPServer server(HTTPServer::respondWithOK, HTTPServer::Protocol::HttpsWithLegacyTLS);
+ auto delegate = adoptNS([TestNavigationDelegate new]);
{
- auto webView = makeWebViewWith([WKWebsiteDataStore defaultDataStore]);
+ auto webView = makeWebViewWith([WKWebsiteDataStore defaultDataStore], delegate);
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];
[delegate waitForDidFailProvisionalNavigation];
}
{
- auto webView = makeWebViewWith([WKWebsiteDataStore nonPersistentDataStore]);
+ auto webView = makeWebViewWith([WKWebsiteDataStore nonPersistentDataStore], delegate);
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];
[delegate waitForDidFailProvisionalNavigation];
}
@@ -211,14 +220,12 @@
TEST(TLSVersion, ShouldAllowDeprecatedTLS)
{
+ HTTPServer server(HTTPServer::respondWithOK, HTTPServer::Protocol::HttpsWithLegacyTLS);
{
auto delegate = adoptNS([TLSNavigationDelegate new]);
- TCPServer server(TCPServer::Protocol::HTTPS, [](SSL *ssl) {
- EXPECT_FALSE(ssl);
- }, tls1_1);
auto webView = adoptNS([WKWebView new]);
[webView setNavigationDelegate:delegate.get()];
- [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];
+ [webView loadRequest:server.request()];
[delegate waitForDidFailProvisionalNavigation];
EXPECT_TRUE([delegate receivedShouldAllowDeprecatedTLS]);
}
@@ -225,10 +232,9 @@
{
auto delegate = adoptNS([TLSNavigationDelegate new]);
delegate.get().shouldAllowDeprecatedTLS = YES;
- TCPServer server(TCPServer::Protocol::HTTPS, TCPServer::respondWithOK, tls1_1);
auto webView = adoptNS([WKWebView new]);
[webView setNavigationDelegate:delegate.get()];
- [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];
+ [webView loadRequest:server.request()];
[delegate waitForDidFinishNavigation];
EXPECT_TRUE([delegate receivedShouldAllowDeprecatedTLS]);
}