test(https): give the TLS tests ports of their own
The new tests reused ports the existing suite already binds — 8095 with ShouldSurviveAbuseHTTP1, and 8097/8098 with ShouldFallbackUnknownRoutes' plaintext and HTTP/3 listeners. SO_REUSEADDR does not let two live listeners share a port, so under the parallel runner whichever bound second failed, and which test that was came down to scheduling. Move the TLS tests to 8110-8114, which nothing else uses. That collision also showed up as a SIGABRT rather than a reported error, so harden the path it took: ~ListenerHTTP1 calls Stop(), which joins threads and touches sockets and can therefore throw. A second listener failing to bind unwinds past a live first one, and a throw out of its destructor mid-unwind terminates the process — turning a diagnosable bind failure into a crash. Swallow it there, where there is nothing left to report it to. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
331cf0c66c
commit
14e0a6bab1
4 changed files with 34 additions and 23 deletions
|
|
@ -84,13 +84,13 @@ namespace {
|
|||
// The :TLS layer without any HTTP on top — the case for anything else that
|
||||
// owns a connected socket and wants a record layer over it.
|
||||
void RawStreamAgainstListener() {
|
||||
ListenerAsyncHTTP1 listener(8099, Routes(), TLSServerCredentials{ .selfSigned = true });
|
||||
ListenerAsyncHTTP1 listener(8113, Routes(), TLSServerCredentials{ .selfSigned = true });
|
||||
|
||||
TLSClientCredentials credentials;
|
||||
credentials.caPem = GetSelfSignedCertificatePem().certificate;
|
||||
auto context = TLSContext::Client(credentials);
|
||||
|
||||
ClientTCP socket("localhost", 8099);
|
||||
ClientTCP socket("localhost", 8113);
|
||||
std::unique_ptr<TLSStream> stream =
|
||||
TLSStream::Connect(socket.socketid, context, "localhost",
|
||||
std::chrono::seconds(5));
|
||||
|
|
@ -143,7 +143,7 @@ namespace {
|
|||
server.selfSigned = true;
|
||||
server.requireClientCertificate = true;
|
||||
server.clientCaPath = identity.authority.string();
|
||||
ListenerAsyncHTTP1 listener(8100, Routes(), server);
|
||||
ListenerAsyncHTTP1 listener(8114, Routes(), server);
|
||||
|
||||
// A client with a certificate the listener's CA vouches for.
|
||||
{
|
||||
|
|
@ -151,7 +151,7 @@ namespace {
|
|||
credentials.caPem = GetSelfSignedCertificatePem().certificate;
|
||||
credentials.certPath = identity.certificate.string();
|
||||
credentials.keyPath = identity.privateKey.string();
|
||||
ClientHTTP1 client("localhost", 8100, credentials);
|
||||
ClientHTTP1 client("localhost", 8114, credentials);
|
||||
|
||||
HTTPResponse response = client.Send(CreateRequestHTTP("GET", "/", "localhost"));
|
||||
Check(response.status == "200", "a client with a trusted certificate is served");
|
||||
|
|
@ -167,7 +167,7 @@ namespace {
|
|||
{
|
||||
TLSClientCredentials credentials;
|
||||
credentials.caPem = GetSelfSignedCertificatePem().certificate;
|
||||
ClientHTTP1 anonymous("localhost", 8100, credentials);
|
||||
ClientHTTP1 anonymous("localhost", 8114, credentials);
|
||||
bool refused = false;
|
||||
try {
|
||||
anonymous.Send(CreateRequestHTTP("GET", "/", "localhost"));
|
||||
|
|
|
|||
Loading…
Reference in a new issue