Coverage Report

Created: 2026-10-28 07:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/curl_fuzzer/proto_fuzzer/mqtts_mock_server.cc
Line
Count
Source
1
/*
2
 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3
 *
4
 * SPDX-License-Identifier: curl
5
 */
6
7
/// @file
8
/// @brief Implementation of the implicit-TLS MQTT peer.
9
10
#include "proto_fuzzer/mqtts_mock_server.h"
11
12
#include <cstddef>
13
#include <memory>
14
#include <string>
15
16
#include "proto_fuzzer/mock_server.h"
17
18
namespace proto_fuzzer {
19
20
/// Construct the OpenSSL server carrier used by every MQTTS scenario. MQTT
21
/// sends no ALPN extension, so the closed HTTP/1.1 default is never selected
22
/// and the handshake completes without an application protocol.
23
3.02k
MqttsMockServer::MqttsMockServer() : transport_(TlsApplicationProtocol::kHttp11) {}
24
25
/// Release the TLS connection before the carrier-owned server context. The
26
/// inherited packet parser holds no transport state of its own.
27
3.02k
MqttsMockServer::~MqttsMockServer() { connection_.reset(); }
28
29
/// Install the shared socket callbacks and a stable local trust anchor. Curl
30
/// copies the blob descriptor during setopt and borrows the inline certificate
31
/// bytes, whose program lifetime safely exceeds every easy handle. Scenario
32
/// options run afterwards and can still disable verification.
33
/// @param easy Easy handle that will initiate the MQTTS exchange.
34
3.01k
void MqttsMockServer::Install(CURL* easy) {
35
3.01k
  MqttMockServer::Install(easy);
36
3.01k
  transport_.Install(easy);
37
3.01k
}
38
39
/// Wrap one socketpair endpoint in an OpenSSL acceptor. The inherited MQTT
40
/// loop advances the handshake and then parses only decrypted packets.
41
/// @return Newly allocated nonblocking TLS connection.
42
2.69k
std::unique_ptr<MockConnection> MqttsMockServer::CreateConnection() { return transport_.CreateConnection(); }
43
44
/// @return Protocol version selected by the most recent handshake, or zero.
45
3.01k
int MqttsMockServer::negotiated_tls_version() const { return transport_.negotiated_tls_version(); }
46
47
/// @return Number of connections that completed TLS negotiation.
48
3.01k
std::size_t MqttsMockServer::completed_handshake_count() const { return transport_.completed_handshake_count(); }
49
50
/// @return ALPN protocol selected by curl, or an empty string when absent.
51
3.01k
std::string MqttsMockServer::negotiated_alpn() const { return transport_.negotiated_alpn(); }
52
53
}  // namespace proto_fuzzer