From 465d46c66542ca96eceb4e1765518ec6b934afec Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Mon, 24 Aug 2020 06:52:22 +0430 Subject: [PATCH] Meta+Userland: Run the TLS test too While this _does_ add a point of failure, it'll be a pretty bad day when google goes down. And this is unlikely to put a (positive) dent in their incoming requests, so let's just roll with it until we have our own TLS server. --- Meta/Lagom/CMakeLists.txt | 2 +- Userland/test-crypto.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index ce9e26a3bc..e02dd4ecdf 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -94,7 +94,7 @@ if (BUILD_LAGOM) target_link_libraries(test-crypto_lagom stdc++) add_test( NAME Crypto - COMMAND test-crypto_lagom test -tc + COMMAND test-crypto_lagom test -t -s google.com WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/Userland/test-crypto.cpp b/Userland/test-crypto.cpp index 646c3684c3..47a573abf9 100644 --- a/Userland/test-crypto.cpp +++ b/Userland/test-crypto.cpp @@ -1730,8 +1730,17 @@ static void tls_test_client_hello() if (sent_request) return; sent_request = true; - if (!tls.write("GET / HTTP/1.1\r\nHost: github.com\r\nConnection: close\r\n\r\n"_b)) { - FAIL(write() failed); + if (!tls.write("GET / HTTP/1.1\r\nHost: "_b)) { + FAIL(write(0) failed); + loop.quit(0); + } + auto* the_server = (const u8*)(server ?: DEFAULT_SERVER); + if (!tls.write(ByteBuffer::wrap(const_cast(the_server), strlen((const char*)the_server)))) { + FAIL(write(1) failed); + loop.quit(0); + } + if (!tls.write("\r\nConnection : close\r\n\r\n"_b)) { + FAIL(write(2) failed); loop.quit(0); } }; @@ -1761,7 +1770,7 @@ static void tls_test_client_hello() FAIL(Connection failure); loop.quit(1); }; - if (!tls->connect("github.com", 443)) { + if (!tls->connect(server ?: DEFAULT_SERVER, port)) { FAIL(connect() failed); return; }