transport_security_state_test_util.h 1.5 KB

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