#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/dns/dns_config_service_linux.h"
#include <arpa/inet.h>
#include <resolv.h>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/cancelable_callback.h"
#include "base/check.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/sys_byteorder.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/test/test_waitable_event.h"
#include "net/base/ip_address.h"
#include "net/base/test_completion_callback.h"
#include "net/dns/dns_config.h"
#include "net/dns/dns_config_service.h"
#include "net/dns/nsswitch_reader.h"
#include "net/dns/public/dns_protocol.h"
#include "net/test/test_with_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace {
const char* const kNameserversIPv4[] = …;
const char* const kNameserversIPv6[] = …;
const std::vector<NsswitchReader::ServiceSpecification> kBasicNsswitchConfig = …;
void DummyConfigCallback(const DnsConfig& config) { … }
void InitializeResState(res_state res) { … }
void InitializeExpectedConfig(DnsConfig* config) { … }
class CallbackHelper { … };
class BlockingHelper { … };
class TestScopedResState : public ScopedResState { … };
class TestResolvReader : public ResolvReader { … };
class TestNsswitchReader : public NsswitchReader { … };
class DnsConfigServiceLinuxTest : public ::testing::Test,
public WithTaskEnvironment { … };
TEST_F(DnsConfigServiceLinuxTest, CreateAndDestroy) { … }
TEST_F(DnsConfigServiceLinuxTest, ConvertResStateToDnsConfig) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectEmptyNameserver) { … }
TEST_F(DnsConfigServiceLinuxTest, AcceptNonEmptyNameserver) { … }
TEST_F(DnsConfigServiceLinuxTest, DestroyWhileJobsWorking) { … }
TEST_F(DnsConfigServiceLinuxTest, DestroyOnDifferentThread) { … }
TEST_F(DnsConfigServiceLinuxTest, AcceptsBasicNsswitchConfig) { … }
TEST_F(DnsConfigServiceLinuxTest,
IgnoresBasicNsswitchConfigIfResolvConfigUnhandled) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchWithoutFiles) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsWithExtraFiles) { … }
TEST_F(DnsConfigServiceLinuxTest, IgnoresRedundantActions) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsInconsistentActions) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadFilesSuccessAction) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadFilesNotFoundAction) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchWithoutDns) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadDnsSuccessAction) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchWithMisorderedServices) { … }
TEST_F(DnsConfigServiceLinuxTest, AcceptsIncompatibleNsswitchServicesAfterDns) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchMdns) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchMdns4) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchMdns6) { … }
TEST_F(DnsConfigServiceLinuxTest, AcceptsNsswitchMdnsMinimal) { … }
TEST_F(DnsConfigServiceLinuxTest, AcceptsNsswitchMdnsMinimalWithCommonActions) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadMdnsMinimalUnavailableAction) { … }
TEST_F(DnsConfigServiceLinuxTest, AcceptsNsswitchMyHostname) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadMyHostnameNotFoundAction) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchResolve) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchNis) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadNisNotFoundAction) { … }
TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchUnknown) { … }
TEST_F(DnsConfigServiceLinuxTest, FreshReadsAfterAdditionalTriggers) { … }
}
}