#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/http/transport_security_state.h"
#include <stdint.h>
#include <algorithm>
#include <iterator>
#include <memory>
#include <string>
#include <vector>
#include "base/base64.h"
#include "base/files/file_path.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_param_associator.h"
#include "base/rand_util.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_entropy_provider.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "crypto/sha2.h"
#include "net/base/features.h"
#include "net/base/hash_value.h"
#include "net/base/host_port_pair.h"
#include "net/base/net_errors.h"
#include "net/base/schemeful_site.h"
#include "net/base/test_completion_callback.h"
#include "net/cert/asn1_util.h"
#include "net/cert/cert_verifier.h"
#include "net/cert/cert_verify_result.h"
#include "net/cert/ct_policy_status.h"
#include "net/cert/test_root_certs.h"
#include "net/cert/x509_certificate.h"
#include "net/extras/preload_data/decoder.h"
#include "net/http/http_status_code.h"
#include "net/http/http_util.h"
#include "net/http/transport_security_state_source.h"
#include "net/net_buildflags.h"
#include "net/ssl/ssl_info.h"
#include "net/test/cert_test_util.h"
#include "net/test/test_data_directory.h"
#include "net/test/test_with_task_environment.h"
#include "net/tools/huffman_trie/bit_writer.h"
#include "net/tools/huffman_trie/trie/trie_bit_buffer.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/origin.h"
namespace net {
namespace {
namespace test_default {
#include "net/http/transport_security_state_static_unittest_default.h"
}
namespace test1 {
#include "net/http/transport_security_state_static_unittest1.h"
}
namespace test2 {
#include "net/http/transport_security_state_static_unittest2.h"
}
namespace test3 {
#include "net/http/transport_security_state_static_unittest3.h"
}
const char kHost[] = …;
const uint16_t kPort = …;
const char* const kGoodPath[] = …;
const char* const kBadPath[] = …;
class MockRequireCTDelegate : public TransportSecurityState::RequireCTDelegate { … };
bool operator==(const TransportSecurityState::STSState& lhs,
const TransportSecurityState::STSState& rhs) { … }
bool operator==(const TransportSecurityState::PKPState& lhs,
const TransportSecurityState::PKPState& rhs) { … }
}
class TransportSecurityStateTest : public ::testing::Test,
public WithTaskEnvironment { … };
TEST_F(TransportSecurityStateTest, DomainNameOddities) { … }
TEST_F(TransportSecurityStateTest, SimpleMatches) { … }
TEST_F(TransportSecurityStateTest, MatchesCase1) { … }
TEST_F(TransportSecurityStateTest, MatchesCase2) { … }
TEST_F(TransportSecurityStateTest, SubdomainMatches) { … }
TEST_F(TransportSecurityStateTest, STSSubdomainNoOverride) { … }
TEST_F(TransportSecurityStateTest, PKPSubdomainCarveout) { … }
TEST_F(TransportSecurityStateTest, FatalSSLErrors) { … }
TEST_F(TransportSecurityStateTest, Expiration) { … }
TEST_F(TransportSecurityStateTest, IndependentSubdomain) { … }
TEST_F(TransportSecurityStateTest, IndependentInsertion) { … }
TEST_F(TransportSecurityStateTest, DynamicDomainState) { … }
TEST_F(TransportSecurityStateTest, StaticOrDynamicSource) { … }
TEST_F(TransportSecurityStateTest, NewPinsOverride) { … }
TEST_F(TransportSecurityStateTest, DeleteAllDynamicDataBetween) { … }
TEST_F(TransportSecurityStateTest, DeleteDynamicDataForHost) { … }
TEST_F(TransportSecurityStateTest, LongNames) { … }
static bool AddHash(const std::string& type_and_base64, HashValueVector* out) { … }
TEST_F(TransportSecurityStateTest, PinValidationWithoutRejectedCerts) { … }
TEST_F(TransportSecurityStateTest, DecodePreloadedSingle) { … }
TEST_F(TransportSecurityStateTest, DecodePreloadedMultiplePrefix) { … }
TEST_F(TransportSecurityStateTest, DecodePreloadedMultipleMix) { … }
TEST_F(TransportSecurityStateTest, HstsHostBypassList) { … }
TEST_F(TransportSecurityStateTest, RequireCTConsultsDelegate) { … }
TEST(CTEmergencyDisableTest, CTEmergencyDisable) { … }
#if BUILDFLAG(INCLUDE_TRANSPORT_SECURITY_STATE_PRELOAD_LIST)
class TransportSecurityStateStaticTest : public TransportSecurityStateTest { … };
static bool StaticShouldRedirect(const char* hostname) { … }
static bool HasStaticState(const char* hostname) { … }
static bool HasStaticPublicKeyPins(const char* hostname) { … }
static bool OnlyPinningInStaticState(const char* hostname) { … }
TEST_F(TransportSecurityStateStaticTest, EnableStaticPins) { … }
TEST_F(TransportSecurityStateStaticTest, DisableStaticPins) { … }
TEST_F(TransportSecurityStateStaticTest, IsPreloaded) { … }
TEST_F(TransportSecurityStateStaticTest, PreloadedDomainSet) { … }
TEST_F(TransportSecurityStateStaticTest, Preloaded) { … }
TEST_F(TransportSecurityStateStaticTest, PreloadedPins) { … }
TEST_F(TransportSecurityStateStaticTest, BuiltinCertPins) { … }
TEST_F(TransportSecurityStateStaticTest, OptionalHSTSCertPins) { … }
TEST_F(TransportSecurityStateStaticTest, OverrideBuiltins) { … }
TEST_F(TransportSecurityStateTest, WriteSizeDecodeSize) { … }
TEST_F(TransportSecurityStateTest, DecodeSizeFour) { … }
#endif
TEST_F(TransportSecurityStateTest, UpdateKeyPinsListValidPin) { … }
TEST_F(TransportSecurityStateTest, UpdateKeyPinsListNotValidPin) { … }
TEST_F(TransportSecurityStateTest, UpdateKeyPinsEmptyList) { … }
TEST_F(TransportSecurityStateTest, UpdateKeyPinsIncludeSubdomains) { … }
TEST_F(TransportSecurityStateTest, UpdateKeyPinsIncludeSubdomainsTLD) { … }
TEST_F(TransportSecurityStateTest, UpdateKeyPinsDontIncludeSubdomains) { … }
TEST_F(TransportSecurityStateTest, UpdateKeyPinsListTimestamp) { … }
class TransportSecurityStatePinningKillswitchTest
: public TransportSecurityStateTest { … };
TEST_F(TransportSecurityStatePinningKillswitchTest, PinningKillswitchSet) { … }
}