#include "services/network/ip_protection/ip_protection_proxy_delegate.h"
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/ip_protection/common/ip_protection_data_types.h"
#include "components/ip_protection/common/ip_protection_telemetry.h"
#include "components/ip_protection/common/masked_domain_list_manager.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/proxy_chain.h"
#include "net/base/proxy_string_util.h"
#include "net/proxy_resolution/proxy_info.h"
#include "net/test/gtest_util.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_test_util.h"
#include "services/network/ip_protection/ip_protection_config_cache_impl.h"
#include "services/network/ip_protection/ip_protection_proxy_list_manager.h"
#include "services/network/ip_protection/ip_protection_token_cache_manager.h"
#include "services/network/public/cpp/features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
IsError;
IsOk;
namespace network {
namespace {
MaskedDomainListManager;
ProtectionEligibility;
constexpr char kHttpsUrl[] = …;
constexpr char kHttpUrl[] = …;
constexpr char kLocalhost[] = …;
constexpr char kEligibilityHistogram[] = …;
constexpr char kAreAuthTokensAvailableHistogram[] = …;
constexpr char kIsProxyListAvailableHistogram[] = …;
constexpr char kAvailabilityHistogram[] = …;
class MockIpProtectionConfigCache : public IpProtectionConfigCache { … };
}
MATCHER_P2(Contain,
expected_name,
expected_value,
std::string("headers ") + (negation ? "don't " : "") + "contain '" +
expected_name + ": " + expected_value + "'") { … }
struct HeadersReceived { … };
class TestCustomProxyConnectionObserver
: public mojom::CustomProxyConnectionObserver { … };
class IpProtectionProxyDelegateTest : public testing::Test { … };
TEST_F(IpProtectionProxyDelegateTest, AddsTokenToTunnelRequest) { … }
TEST_F(IpProtectionProxyDelegateTest, ErrorIfConnectionWithNoTokens) { … }
TEST_F(IpProtectionProxyDelegateTest, AddsDebugExperimentArm) { … }
TEST_F(IpProtectionProxyDelegateTest, OnResolveProxyDeprioritizesBadProxies) { … }
TEST_F(IpProtectionProxyDelegateTest, OnResolveProxyAllProxiesBad) { … }
TEST_F(IpProtectionProxyDelegateTest,
OnResolveProxyMaskedDomainListManagerMatch) { … }
TEST_F(IpProtectionProxyDelegateTest,
OnResolveProxyMaskedDomainListManagerMatch_DirectOnly) { … }
TEST_F(IpProtectionProxyDelegateTest,
OnResolveProxyMaskedDomainListManagerDoesNotMatch_FirstPartyException) { … }
TEST_F(IpProtectionProxyDelegateTest, OnResolveProxy_NoAuthToken) { … }
TEST_F(IpProtectionProxyDelegateTest, OnResolveProxy_NoProxyList) { … }
TEST_F(IpProtectionProxyDelegateTest, OnResolveProxy_IpProtectionDisabled) { … }
TEST_F(IpProtectionProxyDelegateTest, OnResolveProxyIpProtectionNoMatch) { … }
TEST_F(IpProtectionProxyDelegateTest,
OnResolveProxyIpProtectionNoMatch_UnpopulatedAllowList) { … }
TEST_F(IpProtectionProxyDelegateTest,
OnResolveProxyIpProtectionMultiProxyHttpSuccess) { … }
TEST_F(IpProtectionProxyDelegateTest, OnResolveProxyIpProtectionSuccess) { … }
TEST_F(IpProtectionProxyDelegateTest, OnSuccessfulRequestAfterFailures) { … }
TEST_F(IpProtectionProxyDelegateTest, OnFallback) { … }
TEST_F(IpProtectionProxyDelegateTest, MergeProxyRules) { … }
TEST_F(IpProtectionProxyDelegateTest, InvalidateTryAgainAfterTime) { … }
}