#include "net/proxy_resolution/configured_proxy_resolution_service.h"
#include <cstdarg>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/time/time.h"
#include "net/base/mock_network_change_notifier.h"
#include "net/base/net_errors.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/network_change_notifier.h"
#include "net/base/network_isolation_key.h"
#include "net/base/proxy_chain.h"
#include "net/base/proxy_delegate.h"
#include "net/base/proxy_server.h"
#include "net/base/proxy_string_util.h"
#include "net/base/schemeful_site.h"
#include "net/base/test_completion_callback.h"
#include "net/log/net_log.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_with_source.h"
#include "net/log/test_net_log.h"
#include "net/log/test_net_log_util.h"
#include "net/proxy_resolution/dhcp_pac_file_fetcher.h"
#include "net/proxy_resolution/mock_pac_file_fetcher.h"
#include "net/proxy_resolution/mock_proxy_resolver.h"
#include "net/proxy_resolution/pac_file_fetcher.h"
#include "net/proxy_resolution/proxy_config_service.h"
#include "net/proxy_resolution/proxy_resolution_request.h"
#include "net/proxy_resolution/proxy_resolver.h"
#include "net/test/gtest_util.h"
#include "net/test/test_with_task_environment.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
ElementsAre;
Key;
IsError;
IsOk;
namespace net {
namespace {
class ImmediatePollPolicy
: public ConfiguredProxyResolutionService::PacPollPolicy { … };
class NeverPollPolicy : public ConfiguredProxyResolutionService::PacPollPolicy { … };
class ImmediateAfterActivityPollPolicy
: public ConfiguredProxyResolutionService::PacPollPolicy { … };
class ConfiguredProxyResolutionServiceTest : public ::testing::Test,
public WithTaskEnvironment { … };
const char kValidPacScript1[] = …;
const char16_t kValidPacScript116[] = …;
const char kValidPacScript2[] = …;
const char16_t kValidPacScript216[] = …;
class MockProxyConfigService : public ProxyConfigService { … };
class TestResolveProxyDelegate : public ProxyDelegate { … };
class TestProxyFallbackProxyDelegate : public ProxyDelegate { … };
JobMap;
JobMap GetJobsForURLs(const JobMap& map, const std::vector<GURL>& urls) { … }
JobMap GetPendingJobsForURLs(const MockAsyncProxyResolver& resolver,
const GURL& url1 = GURL(),
const GURL& url2 = GURL(),
const GURL& url3 = GURL()) { … }
JobMap GetCancelledJobsForURLs(const MockAsyncProxyResolver& resolver,
const GURL& url1 = GURL(),
const GURL& url2 = GURL(),
const GURL& url3 = GURL()) { … }
}
TEST_F(ConfiguredProxyResolutionServiceTest, Direct) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, OnResolveProxyCallbackAddProxy) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
OnResolveProxyCallbackRemoveProxy) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, OnResolveProxyHasNak) { … }
template <typename T>
class DeletingCallback : public TestCompletionCallbackBase { … };
template <typename T>
DeletingCallback<T>::DeletingCallback(std::unique_ptr<T>* deletee)
: … { … }
template <typename T>
DeletingCallback<T>::~DeletingCallback() = default;
TEST_F(ConfiguredProxyResolutionServiceTest, CallbackDeletesRequest) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
CallbackDeletesRequestDuringDestructor) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, CallbackDeletesSelf) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
CallbackDeletesSelfDuringDestructor) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, ProxyServiceDeletedBeforeRequest) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, CallbackDeletesService) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PAC) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PAC_NoIdentityOrHash) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PAC_FailoverWithoutDirect) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PAC_RuntimeError) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PAC_FailoverAfterDirect) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PAC_ConfigSourcePropagates) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, ProxyResolverFails) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
ProxyResolverTerminatedDuringRequest) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
ProxyResolverTerminatedDuringRequestWithConcurrentRequest) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
PacFileFetcherFailsDownloadingMandatoryPac) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
ProxyResolverFailsParsingJavaScriptMandatoryPac) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
ProxyResolverFailsInJavaScriptMandatoryPac) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallbackToDirect) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback_BadConfig) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback_BadConfigMandatory) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, ProxyBypassList) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PerProtocolProxyTests) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
ProxyConfigTrafficAnnotationPropagates) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, DefaultProxyFallbackToSOCKS) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, CancelInProgressRequest) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, InitialPACScriptDownload) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
ChangeScriptFetcherWhilePACDownloadInProgress) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, CancelWhilePACFetching) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
FallbackFromAutodetectToCustomPac) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
FallbackFromAutodetectToCustomPac2) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
FallbackFromAutodetectToCustomToManual) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, BypassDoesntApplyToPac) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
DeleteWhileInitProxyResolverHasOutstandingFetch) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
DeleteWhileInitProxyResolverHasOutstandingSet) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, UpdateConfigFromPACToDirect) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, NetworkChangeTriggersPacRefetch) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PACScriptRefetchAfterFailure) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
PACScriptRefetchAfterContentChange) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
PACScriptRefetchAfterContentUnchanged) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PACScriptRefetchAfterSuccess) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PACScriptPollingPolicy) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, PACScriptRefetchAfterActivity) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, IpAddressChangeResetsProxy) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, DnsChangeTriggersPoll) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, DnsChangeNoopWithoutResolver) { … }
class SanitizeUrlHelper { … };
TEST_F(ConfiguredProxyResolutionServiceTest, SanitizeUrlForPacScript) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, OnShutdownWithLiveRequest) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, OnShutdownFollowedByRequest) { … }
const char* kImplicityBypassedHosts[] = …;
const char* kUrlSchemes[] = …;
TEST_F(ConfiguredProxyResolutionServiceTest,
ImplicitlyBypassWithManualSettings) { … }
TEST_F(ConfiguredProxyResolutionServiceTest, ImplicitlyBypassWithPac) { … }
TEST_F(ConfiguredProxyResolutionServiceTest,
CastToConfiguredProxyResolutionService) { … }
}