Make TLSVersion.DefaultBehavior more robust
https://bugs.webkit.org/show_bug.cgi?id=215791
Patch by Alex Christensen <achristensen@webkit.org> on 2020-08-24
Reviewed by Darin Adler.
After r265573 sometimes it would assert, which is not a problem because it was failing the first connection
then succeeding the second connection as intended and as happens in the real internet.
Use HTTPServer which accepts a variable number of connections to keep the test coverage.
* TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/cocoa/HTTPServer.h:
* TestWebKitAPI/cocoa/HTTPServer.mm:
(TestWebKitAPI::HTTPServer::respondWithChallengeThenOK):
(TestWebKitAPI::HTTPServer::respondWithOK):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@266100 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index aa5f47f..53c13a8 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,21 @@
+2020-08-24 Alex Christensen <achristensen@webkit.org>
+
+ Make TLSVersion.DefaultBehavior more robust
+ https://bugs.webkit.org/show_bug.cgi?id=215791
+
+ Reviewed by Darin Adler.
+
+ After r265573 sometimes it would assert, which is not a problem because it was failing the first connection
+ then succeeding the second connection as intended and as happens in the real internet.
+ Use HTTPServer which accepts a variable number of connections to keep the test coverage.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/cocoa/HTTPServer.h:
+ * TestWebKitAPI/cocoa/HTTPServer.mm:
+ (TestWebKitAPI::HTTPServer::respondWithChallengeThenOK):
+ (TestWebKitAPI::HTTPServer::respondWithOK):
+
2020-08-24 Wenson Hsieh <wenson_hsieh@apple.com>
Unreviewed, fix the internal iOS 13.4 build
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm
index 2c94055..a816fe2 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm
+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm
@@ -144,9 +144,11 @@
const uint16_t tls1_1 = 0x0302;
static NSString *defaultsKey = @"WebKitEnableLegacyTLS";
+#if HAVE(NETWORK_FRAMEWORK)
+
TEST(TLSVersion, DefaultBehavior)
{
- TCPServer server(TCPServer::Protocol::HTTPS, TCPServer::respondWithOK, tls1_1);
+ HTTPServer server(HTTPServer::respondWithOK, HTTPServer::Protocol::HttpsWithLegacyTLS);
auto delegate = adoptNS([TestNavigationDelegate new]);
auto webView = adoptNS([WKWebView new]);
[webView setNavigationDelegate:delegate.get()];
@@ -158,6 +160,8 @@
[delegate waitForDidFinishNavigation];
}
+#endif // HAVE(NETWORK_FRAMEWORK)
+
#if HAVE(TLS_VERSION_DURING_CHALLENGE)
TEST(TLSVersion, NetworkSession)
diff --git a/Tools/TestWebKitAPI/cocoa/HTTPServer.h b/Tools/TestWebKitAPI/cocoa/HTTPServer.h
index f0c48b3..4d6ab7c 100644
--- a/Tools/TestWebKitAPI/cocoa/HTTPServer.h
+++ b/Tools/TestWebKitAPI/cocoa/HTTPServer.h
@@ -54,8 +54,9 @@
size_t totalRequests() const;
void cancel();
+ static void respondWithOK(Connection);
static void respondWithChallengeThenOK(Connection);
-
+
private:
static RetainPtr<nw_parameters_t> listenerParameters(Protocol, CertificateVerifier&&, RetainPtr<SecIdentityRef>&&, Optional<uint16_t> port);
static void respondToRequests(Connection, Ref<RequestData>);
diff --git a/Tools/TestWebKitAPI/cocoa/HTTPServer.mm b/Tools/TestWebKitAPI/cocoa/HTTPServer.mm
index e49dd0e..44dd8ca 100644
--- a/Tools/TestWebKitAPI/cocoa/HTTPServer.mm
+++ b/Tools/TestWebKitAPI/cocoa/HTTPServer.mm
@@ -150,17 +150,22 @@
"Content-Length: 0\r\n"
"WWW-Authenticate: Basic realm=\"testrealm\"\r\n\r\n";
connection.send(challengeHeader, [connection] {
- connection.receiveHTTPRequest([connection] (Vector<char>&&) {
- connection.send(
- "HTTP/1.1 200 OK\r\n"
- "Content-Length: 13\r\n\r\n"
- "Hello, World!"
- );
- });
+ respondWithOK(connection);
});
});
}
+void HTTPServer::respondWithOK(Connection connection)
+{
+ connection.receiveHTTPRequest([connection] (Vector<char>&&) {
+ connection.send(
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Length: 13\r\n\r\n"
+ "Hello, World!"
+ );
+ });
+}
+
size_t HTTPServer::totalRequests() const
{
return m_requestData->requestCount;