chromium/net/dns/dns_response_result_extractor_unittest.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/dns/dns_response_result_extractor.h"

#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/ranges/algorithm.h"
#include "base/test/simple_test_clock.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/time/time.h"
#include "net/base/connection_endpoint_metadata_test_util.h"
#include "net/base/host_port_pair.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/dns/dns_query.h"
#include "net/dns/dns_response.h"
#include "net/dns/dns_test_util.h"
#include "net/dns/host_cache.h"
#include "net/dns/host_resolver_internal_result.h"
#include "net/dns/host_resolver_internal_result_test_util.h"
#include "net/dns/host_resolver_results_test_util.h"
#include "net/dns/public/dns_protocol.h"
#include "net/dns/public/dns_query_type.h"
#include "net/test/gtest_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace net {
namespace {

AllOf;
ElementsAre;
ElementsAreArray;
Eq;
IsEmpty;
Ne;
Optional;
Pair;
Pointee;
ResultOf;
SizeIs;
UnorderedElementsAre;

ExtractionError;
ResultsOrError;

constexpr HostResolverInternalResult::Source kDnsSource =;

class DnsResponseResultExtractorTest : public ::testing::Test {};

TEST_F(DnsResponseResultExtractorTest, ExtractsSingleARecord) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsSingleAAAARecord) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsSingleARecordWithCname) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsARecordsWithCname) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNxdomainAResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNodataAResponses) {}

TEST_F(DnsResponseResultExtractorTest, RejectsMalformedARecord) {}

TEST_F(DnsResponseResultExtractorTest, RejectsWrongNameARecord) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresWrongTypeRecordsInAResponse) {}

TEST_F(DnsResponseResultExtractorTest,
       IgnoresWrongTypeRecordsMixedWithARecords) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsMinATtl) {}

MATCHER_P(ContainsContiguousElements, elements, "") {}

TEST_F(DnsResponseResultExtractorTest, ExtractsTxtResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNxdomainTxtResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNodataTxtResponses) {}

TEST_F(DnsResponseResultExtractorTest, RejectsMalformedTxtRecord) {}

TEST_F(DnsResponseResultExtractorTest, RejectsWrongNameTxtRecord) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresWrongTypeTxtResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsMinTxtTtl) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsPtrResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNxdomainPtrResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNodataPtrResponses) {}

TEST_F(DnsResponseResultExtractorTest, RejectsMalformedPtrRecord) {}

TEST_F(DnsResponseResultExtractorTest, RejectsWrongNamePtrRecord) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresWrongTypePtrResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsSrvResponses) {}

// 0-weight services are allowed. Ensure that we can handle such records,
// especially the case where all entries have weight 0.
TEST_F(DnsResponseResultExtractorTest, ExtractsZeroWeightSrvResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNxdomainSrvResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNodataSrvResponses) {}

TEST_F(DnsResponseResultExtractorTest, RejectsMalformedSrvRecord) {}

TEST_F(DnsResponseResultExtractorTest, RejectsWrongNameSrvRecord) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresWrongTypeSrvResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsBasicHttpsResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsComprehensiveHttpsResponses) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresHttpsResponseWithJustAlias) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresHttpsResponseWithAlias) {}

// Expect the entire response to be ignored if all HTTPS records have the
// "no-default-alpn" param.
TEST_F(DnsResponseResultExtractorTest, IgnoresHttpsResponseWithNoDefaultAlpn) {}

// Unsupported/unknown HTTPS params are simply ignored if not marked mandatory.
TEST_F(DnsResponseResultExtractorTest, IgnoresUnsupportedParamsInHttpsRecord) {}

// Entire record is dropped if an unsupported/unknown HTTPS param is marked
// mandatory.
TEST_F(DnsResponseResultExtractorTest,
       IgnoresHttpsRecordWithUnsupportedMandatoryParam) {}

TEST_F(DnsResponseResultExtractorTest,
       ExtractsHttpsRecordWithMatchingServiceName) {}

TEST_F(DnsResponseResultExtractorTest,
       ExtractsHttpsRecordWithMatchingDefaultServiceName) {}

TEST_F(DnsResponseResultExtractorTest,
       ExtractsHttpsRecordWithPrefixedNameAndMatchingServiceName) {}

TEST_F(DnsResponseResultExtractorTest,
       ExtractsHttpsRecordWithAliasingAndMatchingServiceName) {}

TEST_F(DnsResponseResultExtractorTest,
       IgnoreHttpsRecordWithNonMatchingServiceName) {}

TEST_F(DnsResponseResultExtractorTest,
       ExtractsHttpsRecordWithPrefixedNameAndDefaultServiceName) {}

TEST_F(DnsResponseResultExtractorTest,
       ExtractsHttpsRecordWithAliasingAndDefaultServiceName) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsHttpsRecordWithMatchingPort) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresHttpsRecordWithMismatchingPort) {}

// HTTPS records with "no-default-alpn" but also no "alpn" are not
// "self-consistent" and should be ignored.
TEST_F(DnsResponseResultExtractorTest, IgnoresHttpsRecordWithNoAlpn) {}

// Expect the entire response to be ignored if all HTTPS records have the
// "no-default-alpn" param.
TEST_F(DnsResponseResultExtractorTest,
       IgnoresHttpsResponseWithNoCompatibleDefaultAlpn) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNxdomainHttpsResponses) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsNodataHttpsResponses) {}

TEST_F(DnsResponseResultExtractorTest, RejectsMalformedHttpsRecord) {}

TEST_F(DnsResponseResultExtractorTest, RejectsWrongNameHttpsRecord) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresWrongTypeHttpsResponses) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresAdditionalHttpsRecords) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresUnsolicitedHttpsRecords) {}

TEST_F(DnsResponseResultExtractorTest, HandlesInOrderCnameChain) {}

TEST_F(DnsResponseResultExtractorTest, HandlesInOrderCnameChainTypeA) {}

TEST_F(DnsResponseResultExtractorTest, HandlesReverseOrderCnameChain) {}

TEST_F(DnsResponseResultExtractorTest, HandlesReverseOrderCnameChainTypeA) {}

TEST_F(DnsResponseResultExtractorTest, HandlesArbitraryOrderCnameChain) {}

TEST_F(DnsResponseResultExtractorTest, HandlesArbitraryOrderCnameChainTypeA) {}

TEST_F(DnsResponseResultExtractorTest,
       IgnoresNonResultTypesMixedWithCnameChain) {}

TEST_F(DnsResponseResultExtractorTest,
       IgnoresNonResultTypesMixedWithCnameChainTypeA) {}

TEST_F(DnsResponseResultExtractorTest, HandlesCnameChainWithoutResult) {}

TEST_F(DnsResponseResultExtractorTest, HandlesCnameChainWithoutResultTypeA) {}

TEST_F(DnsResponseResultExtractorTest, RejectsCnameChainWithLoop) {}

TEST_F(DnsResponseResultExtractorTest, RejectsCnameChainWithLoopToBeginning) {}

TEST_F(DnsResponseResultExtractorTest,
       RejectsCnameChainWithLoopToBeginningWithoutResult) {}

TEST_F(DnsResponseResultExtractorTest, RejectsCnameChainWithWrongStart) {}

TEST_F(DnsResponseResultExtractorTest, RejectsCnameChainWithWrongResultName) {}

TEST_F(DnsResponseResultExtractorTest, RejectsCnameSharedWithResult) {}

TEST_F(DnsResponseResultExtractorTest, RejectsDisjointCnameChain) {}

TEST_F(DnsResponseResultExtractorTest, RejectsDoubledCnames) {}

TEST_F(DnsResponseResultExtractorTest, IgnoresTtlFromNonResultType) {}

TEST_F(DnsResponseResultExtractorTest, ExtractsTtlFromCname) {}

TEST_F(DnsResponseResultExtractorTest, ValidatesAliasNames) {}

TEST_F(DnsResponseResultExtractorTest, CanonicalizesAliasNames) {}

}  // namespace
}  // namespace net