#include "net/dns/host_cache.h"
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/connection_endpoint_metadata.h"
#include "net/base/host_port_pair.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/schemeful_site.h"
#include "net/dns/host_resolver_internal_result.h"
#include "net/dns/host_resolver_results_test_util.h"
#include "net/dns/https_record_rdata.h"
#include "net/dns/public/host_resolver_results.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
#include "url/url_constants.h"
_;
ElementsAre;
ElementsAreArray;
IsEmpty;
Optional;
Pair;
Pointee;
Property;
UnorderedElementsAre;
namespace net {
namespace {
const int kMaxCacheEntries = …;
HostCache::Key Key(const std::string& hostname) { … }
bool FoobarIndexIsOdd(const std::string& foobarx_com) { … }
class MockPersistenceDelegate : public HostCache::PersistenceDelegate { … };
MATCHER_P(EntryContentsEqual,
entry,
base::StrCat({ … }
IPAddress MakeIP(std::string_view literal) { … }
std::vector<IPEndPoint> MakeEndpoints(std::vector<std::string> my_addresses) { … }
}
TEST(HostCacheTest, Basic) { … }
TEST(HostCacheTest, GetEndpoints) { … }
TEST(HostCacheTest, GetEmptyEndpoints) { … }
TEST(HostCacheTest, GetEmptyEndpointsWithMetadata) { … }
TEST(HostCacheTest, GetMissingEndpoints) { … }
TEST(HostCacheTest, GetMissingEndpointsWithMetadata) { … }
TEST(HostCacheTest, HandlesKeysWithoutScheme) { … }
TEST(HostCacheTest, NetworkAnonymizationKey) { … }
TEST(HostCacheTest, NoCacheZeroTTL) { … }
TEST(HostCacheTest, CacheNegativeEntry) { … }
TEST(HostCacheTest, DnsQueryTypeIsPartOfKey) { … }
TEST(HostCacheTest, HostResolverFlagsArePartOfKey) { … }
TEST(HostCacheTest, HostResolverSourceIsPartOfKey) { … }
TEST(HostCacheTest, SecureIsPartOfKey) { … }
TEST(HostCacheTest, PreferLessStaleMoreSecure) { … }
TEST(HostCacheTest, NoCache) { … }
TEST(HostCacheTest, Clear) { … }
TEST(HostCacheTest, ClearForHosts) { … }
TEST(HostCacheTest, Evict) { … }
TEST(HostCacheTest, Stale) { … }
TEST(HostCacheTest, EvictStale) { … }
TEST(HostCacheTest, NoEvictPinned) { … }
TEST(HostCacheTest, EvictObsoletePinned) { … }
TEST(HostCacheTest, PreserveActivePin) { … }
TEST(HostCacheTest, DontPreserveObsoletePin) { … }
TEST(HostCacheTest, Unpin) { … }
TEST(HostCacheTest, KeyComparators) { … }
TEST(HostCacheTest, SerializeAndDeserializeWithExpirations) { … }
TEST(HostCacheTest, SerializeAndDeserializeWithChanges) { … }
TEST(HostCacheTest, SerializeAndDeserializeAddresses) { … }
TEST(HostCacheTest, SerializeAndDeserializeEntryWithoutScheme) { … }
TEST(HostCacheTest, SerializeAndDeserializeWithNetworkAnonymizationKey) { … }
TEST(HostCacheTest, SerializeForDebugging) { … }
TEST(HostCacheTest, SerializeAndDeserialize_Text) { … }
TEST(HostCacheTest, SerializeAndDeserialize_Hostname) { … }
TEST(HostCacheTest, SerializeAndDeserializeEndpointResult) { … }
TEST(HostCacheTest, DeserializeNoEndpointNoAliase) { … }
TEST(HostCacheTest, DeserializeLegacyAddresses) { … }
TEST(HostCacheTest, DeserializeInvalidQueryTypeIntegrity) { … }
TEST(HostCacheTest, DeserializeInvalidQueryTypeHttpsExperimental) { … }
TEST(HostCacheTest, PersistenceDelegate) { … }
TEST(HostCacheTest, MergeEndpointsWithAliases) { … }
TEST(HostCacheTest, MergeEndpointsKeepEndpointsOrder) { … }
TEST(HostCacheTest, MergeMetadatas) { … }
TEST(HostCacheTest, MergeMetadatasWithIpEndpointsDifferentCanonicalName) { … }
TEST(HostCacheTest, MergeMetadatasWithIpEndpointsMatchingCanonicalName) { … }
TEST(HostCacheTest, MergeMultipleMetadatasWithIpEndpoints) { … }
TEST(HostCacheTest, MergeAliases) { … }
TEST(HostCacheTest, MergeEntries_frontEmpty) { … }
TEST(HostCacheTest, MergeEntries_backEmpty) { … }
TEST(HostCacheTest, MergeEntries_bothEmpty) { … }
TEST(HostCacheTest, MergeEntries_frontWithAliasesNoAddressesBackWithBoth) { … }
TEST(HostCacheTest, MergeEntries_backWithAliasesNoAddressesFrontWithBoth) { … }
TEST(HostCacheTest, MergeEntries_frontWithAddressesNoAliasesBackWithBoth) { … }
TEST(HostCacheTest, MergeEntries_backWithAddressesNoAliasesFrontWithBoth) { … }
TEST(HostCacheTest, MergeEntries_differentTtl) { … }
TEST(HostCacheTest, MergeEntries_FrontCannonnamePreserved) { … }
TEST(HostCacheTest, MergeEntries_BackCannonnameUsable) { … }
TEST(HostCacheTest, ConvertFromInternalAddressResult) { … }
TEST(HostCacheTest, ConvertFromInternalMetadataResult) { … }
TEST(HostCacheTest, ConvertFromCompatibleOnlyInternalMetadataResult) { … }
TEST(HostCacheTest, ConvertFromInternalErrorResult) { … }
TEST(HostCacheTest, ConvertFromNonCachableInternalErrorResult) { … }
TEST(HostCacheTest, ConvertFromInternalAliasOnlyResult) { … }
TEST(HostCacheTest, ConvertFromEmptyInternalResult) { … }
}