xref: /aosp_15_r20/external/cronet/net/http/transport_security_state_test_util.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_HTTP_TRANSPORT_SECURITY_STATE_TEST_UTIL_H_
6 #define NET_HTTP_TRANSPORT_SECURITY_STATE_TEST_UTIL_H_
7 
8 #include <memory>
9 #include <string>
10 #include <vector>
11 
12 #include "net/http/transport_security_state_source.h"
13 
14 namespace net {
15 
16 class ScopedTransportSecurityStateSource {
17  public:
18   // Set the global transport security state preloaded static data source to
19   // the transport_security_state_static_unittest_default source.
20   ScopedTransportSecurityStateSource();
21 
22   // As above, but modifies the reporting URIs in the test source to have a
23   // port number of |reporting_port|.
24   explicit ScopedTransportSecurityStateSource(uint16_t reporting_port);
25 
26   ScopedTransportSecurityStateSource(
27       const ScopedTransportSecurityStateSource&) = delete;
28   ScopedTransportSecurityStateSource& operator=(
29       const ScopedTransportSecurityStateSource&) = delete;
30 
31   ~ScopedTransportSecurityStateSource();
32 
33  private:
34   std::unique_ptr<TransportSecurityStateSource> source_;
35 
36   // This data backs the members of |source_|, if they had to be modified to
37   // use a different reporting port number.
38   std::string pkp_report_uri_;
39   std::vector<TransportSecurityStateSource::Pinset> pinsets_;
40 };
41 
42 }  // namespace net
43 
44 #endif  // NET_HTTP_TRANSPORT_SECURITY_STATE_TEST_UTIL_H_
45