Coverage Report

Created: 2023-11-12 09:30

/proc/self/cwd/test/common/quic/test_proof_source.h
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include <memory>
4
5
#include "source/common/quic/envoy_quic_proof_source_base.h"
6
7
#include "test/mocks/network/mocks.h"
8
9
#include "quiche/quic/test_tools/test_certificates.h"
10
11
namespace Envoy {
12
namespace Quic {
13
14
// A test ProofSource which always provide a hard-coded test certificate in
15
// QUICHE and a fake signature.
16
class TestProofSource : public EnvoyQuicProofSourceBase {
17
public:
18
  quiche::QuicheReferenceCountedPointer<quic::ProofSource::Chain>
19
  GetCertChain(const quic::QuicSocketAddress& /*server_address*/,
20
               const quic::QuicSocketAddress& /*client_address*/, const std::string& /*hostname*/,
21
0
               bool* cert_matched_sni) override {
22
0
    *cert_matched_sni = true;
23
0
    return cert_chain_;
24
0
  }
25
26
0
  const Network::MockFilterChain& filterChain() const { return filter_chain_; }
27
28
protected:
29
  void signPayload(const quic::QuicSocketAddress& /*server_address*/,
30
                   const quic::QuicSocketAddress& /*client_address*/,
31
                   const std::string& /*hostname*/, uint16_t /*signature_algorithm*/,
32
                   absl::string_view in,
33
0
                   std::unique_ptr<quic::ProofSource::SignatureCallback> callback) override {
34
0
    callback->Run(true, absl::StrCat("Fake signature for { ", in, " }"),
35
0
                  std::make_unique<EnvoyQuicProofSourceDetails>(filter_chain_));
36
0
  }
37
38
private:
39
  quiche::QuicheReferenceCountedPointer<quic::ProofSource::Chain> cert_chain_{
40
      new quic::ProofSource::Chain(
41
          std::vector<std::string>{std::string(quic::test::kTestCertificate)})};
42
43
  Network::MockFilterChain filter_chain_;
44
};
45
46
} // namespace Quic
47
} // namespace Envoy