Skip to content

Commit

Permalink
Meta+Userland: Run the TLS test too
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alimpfard authored and awesomekling committed Aug 24, 2020
1 parent c9f902d commit 465d46c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Meta/Lagom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)

Expand Down
15 changes: 12 additions & 3 deletions Userland/test-crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8*>(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);
}
};
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 465d46c

Please sign in to comment.