summaryrefslogtreecommitdiff
path: root/chromium/net/http/transport_security_state_test_util.h
blob: 7e743eb3efebbfcea23a72b5b81ad8cd142e0653 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_HTTP_TRANSPORT_SECURITY_STATE_TEST_UTIL_H_
#define NET_HTTP_TRANSPORT_SECURITY_STATE_TEST_UTIL_H_

#include <memory>
#include <string>
#include <vector>

#include "net/http/transport_security_state_source.h"

namespace net {

class ScopedTransportSecurityStateSource {
 public:
  // Set the global transport security state preloaded static data source to
  // the transport_security_state_static_unittest_default source.
  ScopedTransportSecurityStateSource();

  // As above, but modifies the reporting URIs in the test source to have a
  // port number of |reporting_port|.
  explicit ScopedTransportSecurityStateSource(uint16_t reporting_port);

  ScopedTransportSecurityStateSource(
      const ScopedTransportSecurityStateSource&) = delete;
  ScopedTransportSecurityStateSource& operator=(
      const ScopedTransportSecurityStateSource&) = delete;

  ~ScopedTransportSecurityStateSource();

 private:
  std::unique_ptr<TransportSecurityStateSource> source_;

  // This data backs the members of |source_|, if they had to be modified to
  // use a different reporting port number.
  std::string pkp_report_uri_;
  std::vector<TransportSecurityStateSource::Pinset> pinsets_;
  std::vector<std::string> expect_ct_report_uri_strings_;
  std::vector<const char*> expect_ct_report_uris_;
};

}  // namespace net

#endif  // NET_HTTP_TRANSPORT_SECURITY_STATE_TEST_UTIL_H_