0

[IP Protection] Remove test usage of ProxyInfo::proxy_server()

This removes the remaining uses of ProxyInfo::proxy_server() and the
method along with it.

Bug: 1491092
Change-Id: Ibfbc86c72a7f70aac3c193a055b797d5056fdc20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5027581
Reviewed-by: Matt Menke <mmenke@chromium.org>
Commit-Queue: Andrew Williams <awillia@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1225517}
This commit is contained in:
Andrew Williams
2023-11-16 15:55:18 +00:00
committed by Chromium LUCI CQ
parent 9b18f3ea82
commit 7ec3aa55e3
4 changed files with 145 additions and 149 deletions

@@ -25,6 +25,7 @@
#include "net/base/network_anonymization_key.h" #include "net/base/network_anonymization_key.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
#include "net/base/network_isolation_key.h" #include "net/base/network_isolation_key.h"
#include "net/base/proxy_chain.h"
#include "net/base/proxy_delegate.h" #include "net/base/proxy_delegate.h"
#include "net/base/proxy_server.h" #include "net/base/proxy_server.h"
#include "net/base/proxy_string_util.h" #include "net/base/proxy_string_util.h"
@@ -436,10 +437,10 @@ TEST_F(ConfiguredProxyResolutionServiceTest, OnResolveProxyCallbackAddProxy) {
service.ResolveProxy(url, std::string(), NetworkAnonymizationKey(), &info, service.ResolveProxy(url, std::string(), NetworkAnonymizationKey(), &info,
callback.callback(), &request, net_log_with_source); callback.callback(), &request, net_log_with_source);
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_EQ("badproxy:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[badproxy:8080]", info.proxy_chain().ToDebugString());
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
service.ReportSuccess(info); service.ReportSuccess(info);
@@ -463,14 +464,14 @@ TEST_F(ConfiguredProxyResolutionServiceTest, OnResolveProxyCallbackAddProxy) {
rv = service.ResolveProxy(url, "GET", NetworkAnonymizationKey(), &info, rv = service.ResolveProxy(url, "GET", NetworkAnonymizationKey(), &info,
callback.callback(), &request, net_log_with_source); callback.callback(), &request, net_log_with_source);
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ(info.proxy_server().host_port_pair().host(), "delegate_proxy.com"); EXPECT_EQ("[delegate_proxy.com:80]", info.proxy_chain().ToDebugString());
delegate.set_add_proxy(false); delegate.set_add_proxy(false);
// Check non-bypassed URL: // Check non-bypassed URL:
rv = service.ResolveProxy(url, "GET", NetworkAnonymizationKey(), &info, rv = service.ResolveProxy(url, "GET", NetworkAnonymizationKey(), &info,
callback.callback(), &request, net_log_with_source); callback.callback(), &request, net_log_with_source);
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1"); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
// Check bypassed URL: // Check bypassed URL:
rv = service.ResolveProxy(bypass_url, "GET", NetworkAnonymizationKey(), &info, rv = service.ResolveProxy(bypass_url, "GET", NetworkAnonymizationKey(), &info,
@@ -521,7 +522,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
rv = service.ResolveProxy(url, "GET", NetworkAnonymizationKey(), &info, rv = service.ResolveProxy(url, "GET", NetworkAnonymizationKey(), &info,
callback.callback(), &request, net_log_with_source); callback.callback(), &request, net_log_with_source);
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1"); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
// Check bypassed URL: // Check bypassed URL:
rv = service.ResolveProxy(bypass_url, "GET", NetworkAnonymizationKey(), &info, rv = service.ResolveProxy(bypass_url, "GET", NetworkAnonymizationKey(), &info,
@@ -950,7 +951,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PAC) {
EXPECT_THAT(callback.WaitForResult(), IsOk()); EXPECT_THAT(callback.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy:80", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy:80]", info.proxy_chain().ToDebugString());
EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
@@ -1043,7 +1044,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PAC_FailoverWithoutDirect) {
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy:8080]", info.proxy_chain().ToDebugString());
EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
@@ -1156,7 +1157,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PAC_FailoverAfterDirect) {
// Fallback 1. // Fallback 1.
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foobar:10", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foobar:10]", info.proxy_chain().ToDebugString());
// Fallback 2. // Fallback 2.
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
@@ -1165,7 +1166,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PAC_FailoverAfterDirect) {
// Fallback 3. // Fallback 3.
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foobar:20", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foobar:20]", info.proxy_chain().ToDebugString());
// Fallback 4 -- Nothing to fall back to! // Fallback 4 -- Nothing to fall back to!
EXPECT_FALSE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_FALSE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
@@ -1275,7 +1276,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyResolverFails) {
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy_valid:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy_valid:8080]", info.proxy_chain().ToDebugString());
} }
TEST_F(ConfiguredProxyResolutionServiceTest, TEST_F(ConfiguredProxyResolutionServiceTest,
@@ -1349,7 +1350,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy_valid:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy_valid:8080]", info.proxy_chain().ToDebugString());
} }
TEST_F(ConfiguredProxyResolutionServiceTest, TEST_F(ConfiguredProxyResolutionServiceTest,
@@ -1422,7 +1423,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy_valid:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy_valid:8080]", info.proxy_chain().ToDebugString());
} }
TEST_F(ConfiguredProxyResolutionServiceTest, TEST_F(ConfiguredProxyResolutionServiceTest,
@@ -1594,7 +1595,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy_valid:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy_valid:8080]", info.proxy_chain().ToDebugString());
} }
TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback) { TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback) {
@@ -1638,7 +1639,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback) {
// The first item is valid. // The first item is valid.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
@@ -1654,7 +1655,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback) {
EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time()); EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time());
// The second proxy should be specified. // The second proxy should be specified.
EXPECT_EQ("foopy2:9090", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy2:9090]", info.proxy_chain().ToDebugString());
// Report back that the second proxy worked. This will globally mark the // Report back that the second proxy worked. This will globally mark the
// first proxy as bad. // first proxy as bad.
TestProxyFallbackProxyDelegate test_delegate; TestProxyFallbackProxyDelegate test_delegate;
@@ -1682,7 +1683,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback) {
EXPECT_THAT(callback3.WaitForResult(), IsOk()); EXPECT_THAT(callback3.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy3:7070", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy3:7070]", info.proxy_chain().ToDebugString());
// Proxy times should have been updated, so get them again. // Proxy times should have been updated, so get them again.
EXPECT_LE(proxy_resolve_end_time, info.proxy_resolve_start_time()); EXPECT_LE(proxy_resolve_end_time, info.proxy_resolve_start_time());
@@ -1694,13 +1695,13 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback) {
// We fake another error. It should now try the third one. // We fake another error. It should now try the third one.
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
EXPECT_EQ("foopy2:9090", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy2:9090]", info.proxy_chain().ToDebugString());
// We fake another error. At this point we have tried all of the // We fake another error. At this point we have tried all of the
// proxy servers we thought were valid; next we try the proxy server // proxy servers we thought were valid; next we try the proxy server
// that was in our bad proxies map (foopy1:8080). // that was in our bad proxies map (foopy1:8080).
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
// Fake another error, the last proxy is gone, the list should now be empty, // Fake another error, the last proxy is gone, the list should now be empty,
// so there is nothing left to try. // so there is nothing left to try.
@@ -1731,7 +1732,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback) {
// ... therefore, we should see the second proxy first. // ... therefore, we should see the second proxy first.
EXPECT_THAT(callback7.WaitForResult(), IsOk()); EXPECT_THAT(callback7.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy3:7070", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy3:7070]", info.proxy_chain().ToDebugString());
EXPECT_LE(proxy_resolve_end_time, info.proxy_resolve_start_time()); EXPECT_LE(proxy_resolve_end_time, info.proxy_resolve_start_time());
EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
@@ -1779,13 +1780,13 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallbackToDirect) {
// Get the first result. // Get the first result.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
// Fake an error on the proxy. // Fake an error on the proxy.
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
// Now we get back the second proxy. // Now we get back the second proxy.
EXPECT_EQ("foopy2:9090", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy2:9090]", info.proxy_chain().ToDebugString());
// Fake an error on this proxy as well. // Fake an error on this proxy as well.
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
@@ -1843,14 +1844,14 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback_BadConfig) {
// The first item is valid. // The first item is valid.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
// Fake a proxy error. // Fake a proxy error.
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
// The first proxy is ignored, and the second one is selected. // The first proxy is ignored, and the second one is selected.
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy2:9090", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy2:9090]", info.proxy_chain().ToDebugString());
// Persist foopy1's failure to |service|'s cache of bad proxies, so it will // Persist foopy1's failure to |service|'s cache of bad proxies, so it will
// be considered by subsequent calls to ResolveProxy(). // be considered by subsequent calls to ResolveProxy().
@@ -1898,7 +1899,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback_BadConfig) {
// list by the earlier ReportSuccess(). // list by the earlier ReportSuccess().
EXPECT_THAT(callback3.WaitForResult(), IsOk()); EXPECT_THAT(callback3.WaitForResult(), IsOk());
EXPECT_FALSE(info3.is_direct()); EXPECT_FALSE(info3.is_direct());
EXPECT_EQ("foopy2:9090", ProxyServerToProxyUri(info3.proxy_server())); EXPECT_EQ("[foopy2:9090]", info3.proxy_chain().ToDebugString());
EXPECT_EQ(2u, info3.proxy_list().size()); EXPECT_EQ(2u, info3.proxy_list().size());
EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
@@ -1949,14 +1950,14 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback_BadConfigMandatory) {
// The first item is valid. // The first item is valid.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
// Fake a proxy error. // Fake a proxy error.
EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource())); EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, NetLogWithSource()));
// The first proxy is ignored, and the second one is selected. // The first proxy is ignored, and the second one is selected.
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy2:9090", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy2:9090]", info.proxy_chain().ToDebugString());
// Persist foopy1's failure to |service|'s cache of bad proxies, so it will // Persist foopy1's failure to |service|'s cache of bad proxies, so it will
// be considered by subsequent calls to ResolveProxy(). // be considered by subsequent calls to ResolveProxy().
@@ -2006,7 +2007,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyFallback_BadConfigMandatory) {
// list by the earlier ReportSuccess(). // list by the earlier ReportSuccess().
EXPECT_THAT(callback4.WaitForResult(), IsOk()); EXPECT_THAT(callback4.WaitForResult(), IsOk());
EXPECT_FALSE(info3.is_direct()); EXPECT_FALSE(info3.is_direct());
EXPECT_EQ("foopy2:9090", ProxyServerToProxyUri(info3.proxy_server())); EXPECT_EQ("[foopy2:9090]", info3.proxy_chain().ToDebugString());
EXPECT_EQ(2u, info3.proxy_list().size()); EXPECT_EQ(2u, info3.proxy_list().size());
} }
@@ -2042,7 +2043,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ProxyBypassList) {
&info[1], callback[1].callback(), &request2, &info[1], callback[1].callback(), &request2,
NetLogWithSource()); NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info[1].proxy_server())); EXPECT_EQ("[foopy1:8080]", info[1].proxy_chain().ToDebugString());
} }
TEST_F(ConfiguredProxyResolutionServiceTest, MarkProxiesAsBadTests) { TEST_F(ConfiguredProxyResolutionServiceTest, MarkProxiesAsBadTests) {
@@ -2053,13 +2054,14 @@ TEST_F(ConfiguredProxyResolutionServiceTest, MarkProxiesAsBadTests) {
ProxyList proxy_list; ProxyList proxy_list;
std::vector<ProxyChain> additional_bad_proxies; std::vector<ProxyChain> additional_bad_proxies;
for (const ProxyServer& proxy_server : for (const ProxyChain& proxy_chain :
config.proxy_rules().proxies_for_http.GetAll()) { config.proxy_rules().proxies_for_http.AllChains()) {
proxy_list.AddProxyServer(proxy_server); proxy_list.AddProxyChain(proxy_chain);
if (proxy_server == config.proxy_rules().proxies_for_http.Get()) if (proxy_chain == config.proxy_rules().proxies_for_http.First()) {
continue; continue;
}
additional_bad_proxies.emplace_back(ProxyChain(proxy_server)); additional_bad_proxies.emplace_back(proxy_chain);
} }
EXPECT_EQ(3u, additional_bad_proxies.size()); EXPECT_EQ(3u, additional_bad_proxies.size());
@@ -2073,9 +2075,9 @@ TEST_F(ConfiguredProxyResolutionServiceTest, MarkProxiesAsBadTests) {
service.MarkProxiesAsBadUntil(proxy_info, base::Seconds(1), service.MarkProxiesAsBadUntil(proxy_info, base::Seconds(1),
additional_bad_proxies, NetLogWithSource()); additional_bad_proxies, NetLogWithSource());
ASSERT_EQ(4u, retry_info.size()); ASSERT_EQ(4u, retry_info.size());
for (const ProxyServer& proxy_server : for (const ProxyChain& proxy_chain :
config.proxy_rules().proxies_for_http.GetAll()) { config.proxy_rules().proxies_for_http.AllChains()) {
auto i = retry_info.find(ProxyChain(proxy_server)); auto i = retry_info.find(proxy_chain);
ASSERT_TRUE(i != retry_info.end()); ASSERT_TRUE(i != retry_info.end());
} }
} }
@@ -2097,7 +2099,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PerProtocolProxyTests) {
callback.callback(), &request, NetLogWithSource()); callback.callback(), &request, NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
} }
{ {
ConfiguredProxyResolutionService service( ConfiguredProxyResolutionService service(
@@ -2111,7 +2113,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PerProtocolProxyTests) {
callback.callback(), &request, NetLogWithSource()); callback.callback(), &request, NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(info.is_direct()); EXPECT_TRUE(info.is_direct());
EXPECT_EQ("direct://", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[direct://]", info.proxy_chain().ToDebugString());
} }
{ {
ConfiguredProxyResolutionService service( ConfiguredProxyResolutionService service(
@@ -2125,7 +2127,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PerProtocolProxyTests) {
callback.callback(), &request, NetLogWithSource()); callback.callback(), &request, NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy2:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy2:8080]", info.proxy_chain().ToDebugString());
} }
{ {
config.proxy_rules().ParseFromString("foopy1:8080"); config.proxy_rules().ParseFromString("foopy1:8080");
@@ -2140,7 +2142,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PerProtocolProxyTests) {
callback.callback(), &request, NetLogWithSource()); callback.callback(), &request, NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
} }
} }
@@ -2224,7 +2226,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, DefaultProxyFallbackToSOCKS) {
callback.callback(), &request, NetLogWithSource()); callback.callback(), &request, NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info.proxy_server())); EXPECT_EQ("[foopy1:8080]", info.proxy_chain().ToDebugString());
} }
{ {
ConfiguredProxyResolutionService service( ConfiguredProxyResolutionService service(
@@ -2238,8 +2240,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, DefaultProxyFallbackToSOCKS) {
callback.callback(), &request, NetLogWithSource()); callback.callback(), &request, NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("socks4://foopy2:1080", EXPECT_EQ("[socks4://foopy2:1080]", info.proxy_chain().ToDebugString());
ProxyServerToProxyUri(info.proxy_server()));
} }
{ {
ConfiguredProxyResolutionService service( ConfiguredProxyResolutionService service(
@@ -2253,8 +2254,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, DefaultProxyFallbackToSOCKS) {
callback.callback(), &request, NetLogWithSource()); callback.callback(), &request, NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("socks4://foopy2:1080", EXPECT_EQ("[socks4://foopy2:1080]", info.proxy_chain().ToDebugString());
ProxyServerToProxyUri(info.proxy_server()));
} }
{ {
ConfiguredProxyResolutionService service( ConfiguredProxyResolutionService service(
@@ -2268,8 +2268,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, DefaultProxyFallbackToSOCKS) {
callback.callback(), &request, NetLogWithSource()); callback.callback(), &request, NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct()); EXPECT_FALSE(info.is_direct());
EXPECT_EQ("socks4://foopy2:1080", EXPECT_EQ("[socks4://foopy2:1080]", info.proxy_chain().ToDebugString());
ProxyServerToProxyUri(info.proxy_server()));
} }
} }
@@ -2339,13 +2338,13 @@ TEST_F(ConfiguredProxyResolutionServiceTest, CancelInProgressRequest) {
jobs[url1]->CompleteNow(OK); jobs[url1]->CompleteNow(OK);
EXPECT_EQ(OK, callback1.WaitForResult()); EXPECT_EQ(OK, callback1.WaitForResult());
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
EXPECT_FALSE(callback2.have_result()); // Cancelled. EXPECT_FALSE(callback2.have_result()); // Cancelled.
GetCancelledJobsForURLs(resolver, url2); GetCancelledJobsForURLs(resolver, url2);
EXPECT_THAT(callback3.WaitForResult(), IsOk()); EXPECT_THAT(callback3.WaitForResult(), IsOk());
EXPECT_EQ("request3:80", ProxyServerToProxyUri(info3.proxy_server())); EXPECT_EQ("[request3:80]", info3.proxy_chain().ToDebugString());
} }
// Test the initial PAC download for resolver that expects bytes. // Test the initial PAC download for resolver that expects bytes.
@@ -2439,19 +2438,19 @@ TEST_F(ConfiguredProxyResolutionServiceTest, InitialPACScriptDownload) {
// ProxyResolver::GetProxyForURL() to take a std::unique_ptr<Request>* rather // ProxyResolver::GetProxyForURL() to take a std::unique_ptr<Request>* rather
// than a RequestHandle* (patchset #11 id:200001 of // than a RequestHandle* (patchset #11 id:200001 of
// https://codereview.chromium.org/1439053002/ ) // https://codereview.chromium.org/1439053002/ )
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
EXPECT_FALSE(info1.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info1.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info1.proxy_resolve_end_time().is_null()); EXPECT_FALSE(info1.proxy_resolve_end_time().is_null());
EXPECT_LE(info1.proxy_resolve_start_time(), info1.proxy_resolve_end_time()); EXPECT_LE(info1.proxy_resolve_start_time(), info1.proxy_resolve_end_time());
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("request2:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[request2:80]", info2.proxy_chain().ToDebugString());
EXPECT_FALSE(info2.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info2.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info2.proxy_resolve_end_time().is_null()); EXPECT_FALSE(info2.proxy_resolve_end_time().is_null());
EXPECT_LE(info2.proxy_resolve_start_time(), info2.proxy_resolve_end_time()); EXPECT_LE(info2.proxy_resolve_start_time(), info2.proxy_resolve_end_time());
EXPECT_THAT(callback3.WaitForResult(), IsOk()); EXPECT_THAT(callback3.WaitForResult(), IsOk());
EXPECT_EQ("request3:80", ProxyServerToProxyUri(info3.proxy_server())); EXPECT_EQ("[request3:80]", info3.proxy_chain().ToDebugString());
EXPECT_FALSE(info3.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info3.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info3.proxy_resolve_end_time().is_null()); EXPECT_FALSE(info3.proxy_resolve_end_time().is_null());
EXPECT_LE(info3.proxy_resolve_start_time(), info3.proxy_resolve_end_time()); EXPECT_LE(info3.proxy_resolve_start_time(), info3.proxy_resolve_end_time());
@@ -2602,7 +2601,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, CancelWhilePACFetching) {
resolver.pending_jobs()[0]->CompleteNow(OK); resolver.pending_jobs()[0]->CompleteNow(OK);
EXPECT_THAT(callback3.WaitForResult(), IsOk()); EXPECT_THAT(callback3.WaitForResult(), IsOk());
EXPECT_EQ("request3:80", ProxyServerToProxyUri(info3.proxy_server())); EXPECT_EQ("[request3:80]", info3.proxy_chain().ToDebugString());
EXPECT_TRUE(resolver.cancelled_jobs().empty()); EXPECT_TRUE(resolver.cancelled_jobs().empty());
@@ -2701,13 +2700,13 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
// ProxyResolver::GetProxyForURL() to take a std::unique_ptr<Request>* rather // ProxyResolver::GetProxyForURL() to take a std::unique_ptr<Request>* rather
// than a RequestHandle* (patchset #11 id:200001 of // than a RequestHandle* (patchset #11 id:200001 of
// https://codereview.chromium.org/1439053002/ ) // https://codereview.chromium.org/1439053002/ )
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
EXPECT_FALSE(info1.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info1.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info1.proxy_resolve_end_time().is_null()); EXPECT_FALSE(info1.proxy_resolve_end_time().is_null());
EXPECT_LE(info1.proxy_resolve_start_time(), info1.proxy_resolve_end_time()); EXPECT_LE(info1.proxy_resolve_start_time(), info1.proxy_resolve_end_time());
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("request2:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[request2:80]", info2.proxy_chain().ToDebugString());
EXPECT_FALSE(info2.proxy_resolve_start_time().is_null()); EXPECT_FALSE(info2.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info2.proxy_resolve_end_time().is_null()); EXPECT_FALSE(info2.proxy_resolve_end_time().is_null());
EXPECT_LE(info2.proxy_resolve_start_time(), info2.proxy_resolve_end_time()); EXPECT_LE(info2.proxy_resolve_start_time(), info2.proxy_resolve_end_time());
@@ -2791,10 +2790,10 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
// ProxyResolver::GetProxyForURL() to take a std::unique_ptr<Request>* rather // ProxyResolver::GetProxyForURL() to take a std::unique_ptr<Request>* rather
// than a RequestHandle* (patchset #11 id:200001 of // than a RequestHandle* (patchset #11 id:200001 of
// https://codereview.chromium.org/1439053002/ ) // https://codereview.chromium.org/1439053002/ )
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("request2:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[request2:80]", info2.proxy_chain().ToDebugString());
} }
// Test that if all of auto-detect, a custom PAC script, and manual settings // Test that if all of auto-detect, a custom PAC script, and manual settings
@@ -2856,10 +2855,10 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
// Verify that jobs ran as expected -- they should have fallen back to // Verify that jobs ran as expected -- they should have fallen back to
// the manual proxy configuration for HTTP urls. // the manual proxy configuration for HTTP urls.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("foopy:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[foopy:80]", info1.proxy_chain().ToDebugString());
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("foopy:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[foopy:80]", info2.proxy_chain().ToDebugString());
} }
// Test that the bypass rules are NOT applied when using autodetect. // Test that the bypass rules are NOT applied when using autodetect.
@@ -2914,7 +2913,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, BypassDoesntApplyToPac) {
// Verify that request ran as expected. // Verify that request ran as expected.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
// Start another request, it should pickup the bypass item. // Start another request, it should pickup the bypass item.
ProxyInfo info2; ProxyInfo info2;
@@ -2933,7 +2932,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, BypassDoesntApplyToPac) {
resolver.pending_jobs()[0]->CompleteNow(OK); resolver.pending_jobs()[0]->CompleteNow(OK);
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("request2:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[request2:80]", info2.proxy_chain().ToDebugString());
} }
// Delete the ConfiguredProxyResolutionService while InitProxyResolver has an // Delete the ConfiguredProxyResolutionService while InitProxyResolver has an
@@ -3042,7 +3041,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, UpdateConfigFromPACToDirect) {
// Verify that request ran as expected. // Verify that request ran as expected.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
// Force the ConfiguredProxyResolutionService to pull down a new proxy // Force the ConfiguredProxyResolutionService to pull down a new proxy
// configuration. (Even though the configuration isn't old/bad). // configuration. (Even though the configuration isn't old/bad).
@@ -3123,7 +3122,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, NetworkChangeTriggersPacRefetch) {
// Wait for completion callback, and verify that the request ran as expected. // Wait for completion callback, and verify that the request ran as expected.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
// Now simluate a change in the network. The ProxyConfigService is still // Now simluate a change in the network. The ProxyConfigService is still
// going to return the same PAC URL as before, but this URL needs to be // going to return the same PAC URL as before, but this URL needs to be
@@ -3167,7 +3166,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, NetworkChangeTriggersPacRefetch) {
// Wait for completion callback, and verify that the request ran as expected. // Wait for completion callback, and verify that the request ran as expected.
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("request2:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[request2:80]", info2.proxy_chain().ToDebugString());
// Check that the expected events were output to the log stream. In particular // Check that the expected events were output to the log stream. In particular
// PROXY_CONFIG_CHANGED should have only been emitted once (for the initial // PROXY_CONFIG_CHANGED should have only been emitted once (for the initial
@@ -3289,7 +3288,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PACScriptRefetchAfterFailure) {
// Wait for completion callback, and verify that the request ran as expected. // Wait for completion callback, and verify that the request ran as expected.
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("request2:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[request2:80]", info2.proxy_chain().ToDebugString());
} }
// This test verifies that the PAC script specified by the settings is // This test verifies that the PAC script specified by the settings is
@@ -3356,7 +3355,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
// Wait for completion callback, and verify that the request ran as expected. // Wait for completion callback, and verify that the request ran as expected.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
// At this point we have initialized the proxy service using a PAC script. // At this point we have initialized the proxy service using a PAC script.
// //
@@ -3407,7 +3406,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
// Wait for completion callback, and verify that the request ran as expected. // Wait for completion callback, and verify that the request ran as expected.
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("request2:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[request2:80]", info2.proxy_chain().ToDebugString());
} }
// This test verifies that the PAC script specified by the settings is // This test verifies that the PAC script specified by the settings is
@@ -3474,7 +3473,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
// Wait for completion callback, and verify that the request ran as expected. // Wait for completion callback, and verify that the request ran as expected.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
// At this point we have initialized the proxy service using a PAC script. // At this point we have initialized the proxy service using a PAC script.
// //
@@ -3522,7 +3521,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
// Wait for completion callback, and verify that the request ran as expected. // Wait for completion callback, and verify that the request ran as expected.
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("request2:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[request2:80]", info2.proxy_chain().ToDebugString());
} }
// This test verifies that the PAC script specified by the settings is // This test verifies that the PAC script specified by the settings is
@@ -3588,7 +3587,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PACScriptRefetchAfterSuccess) {
// Wait for completion callback, and verify that the request ran as expected. // Wait for completion callback, and verify that the request ran as expected.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
// At this point we have initialized the proxy service using a PAC script. // At this point we have initialized the proxy service using a PAC script.
// //
@@ -3764,7 +3763,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PACScriptRefetchAfterActivity) {
// Wait for completion callback, and verify that the request ran as expected. // Wait for completion callback, and verify that the request ran as expected.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
// At this point we have initialized the proxy service using a PAC script. // At this point we have initialized the proxy service using a PAC script.
// Our PAC poller is set to update ONLY in response to network activity, // Our PAC poller is set to update ONLY in response to network activity,
@@ -3790,7 +3789,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, PACScriptRefetchAfterActivity) {
resolver.pending_jobs()[0]->CompleteNow(OK); resolver.pending_jobs()[0]->CompleteNow(OK);
EXPECT_THAT(callback2.WaitForResult(), IsOk()); EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("request2:80", ProxyServerToProxyUri(info2.proxy_server())); EXPECT_EQ("[request2:80]", info2.proxy_chain().ToDebugString());
// In response to getting that resolve request, the poller should have // In response to getting that resolve request, the poller should have
// started the next poll, and made it as far as to request the download. // started the next poll, and made it as far as to request the download.
@@ -4247,7 +4246,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest,
GURL("http://www.example.com"), std::string(), NetworkAnonymizationKey(), GURL("http://www.example.com"), std::string(), NetworkAnonymizationKey(),
&info1, callback1.callback(), &request1, NetLogWithSource()); &info1, callback1.callback(), &request1, NetLogWithSource());
EXPECT_THAT(rv, IsOk()); EXPECT_THAT(rv, IsOk());
EXPECT_EQ("foopy1:8080", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[foopy1:8080]", info1.proxy_chain().ToDebugString());
// Test that localhost and link-local URLs bypass the proxy (independent of // Test that localhost and link-local URLs bypass the proxy (independent of
// the URL scheme). // the URL scheme).
@@ -4315,7 +4314,7 @@ TEST_F(ConfiguredProxyResolutionServiceTest, ImplicitlyBypassWithPac) {
// Verify that request ran as expected. // Verify that request ran as expected.
EXPECT_THAT(callback1.WaitForResult(), IsOk()); EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("request1:80", ProxyServerToProxyUri(info1.proxy_server())); EXPECT_EQ("[request1:80]", info1.proxy_chain().ToDebugString());
// Test that localhost and link-local URLs bypass the use of PAC script // Test that localhost and link-local URLs bypass the use of PAC script
// (independent of the URL scheme). // (independent of the URL scheme).

@@ -181,13 +181,6 @@ class NET_EXPORT ProxyInfo {
// Returns true if this proxy info is for IP Protection. // Returns true if this proxy info is for IP Protection.
bool is_for_ip_protection() const { return is_for_ip_protection_; } bool is_for_ip_protection() const { return is_for_ip_protection_; }
#ifdef UNIT_TEST
// Returns the first valid proxy server. `is_empty()` must be false to be able
// to call this function, and the first chain must not be multi-proxy.
// TODO(crbug.com/1491092): Remove this method.
const ProxyServer& proxy_server() const { return proxy_list_.Get(); }
#endif
// Returns the first valid proxy chain. is_empty() must be false to be able // Returns the first valid proxy chain. is_empty() must be false to be able
// to call this function. // to call this function.
const ProxyChain& proxy_chain() const { return proxy_list_.First(); } const ProxyChain& proxy_chain() const { return proxy_list_.First(); }

@@ -181,7 +181,7 @@ TEST_F(ProxyResolverV8TracingTest, Simple) {
EXPECT_THAT(callback.WaitForResult(), IsOk()); EXPECT_THAT(callback.WaitForResult(), IsOk());
EXPECT_EQ("foo:99", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[foo:99]", proxy_info.proxy_chain().ToDebugString());
EXPECT_EQ(0u, host_resolver.num_resolve()); EXPECT_EQ(0u, host_resolver.num_resolve());
@@ -239,7 +239,7 @@ TEST_F(ProxyResolverV8TracingTest, TooManyAlerts) {
// Iteration1 does a DNS resolve // Iteration1 does a DNS resolve
// Iteration2 exceeds the alert buffer // Iteration2 exceeds the alert buffer
// Iteration3 runs in blocking mode and completes // Iteration3 runs in blocking mode and completes
EXPECT_EQ("foo:3", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[foo:3]", proxy_info.proxy_chain().ToDebugString());
EXPECT_EQ(1u, host_resolver.num_resolve()); EXPECT_EQ(1u, host_resolver.num_resolve());
@@ -273,7 +273,7 @@ TEST_F(ProxyResolverV8TracingTest, TooManyEmptyAlerts) {
EXPECT_THAT(callback.WaitForResult(), IsOk()); EXPECT_THAT(callback.WaitForResult(), IsOk());
EXPECT_EQ("foo:3", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[foo:3]", proxy_info.proxy_chain().ToDebugString());
EXPECT_EQ(1u, host_resolver.num_resolve()); EXPECT_EQ(1u, host_resolver.num_resolve());
@@ -337,22 +337,22 @@ TEST_F(ProxyResolverV8TracingTest, Dns) {
EXPECT_EQ(7u, host_resolver.num_resolve()); EXPECT_EQ(7u, host_resolver.num_resolve());
const char* kExpectedResult = const char* kExpectedResult =
"122.133.144.155-" // myIpAddress() "[122.133.144.155-" // myIpAddress()
"null-" // dnsResolve('') "null-" // dnsResolve('')
"__1_192.168.1.1-" // dnsResolveEx('host1') "__1_192.168.1.1-" // dnsResolveEx('host1')
"null-" // dnsResolve('host2') "null-" // dnsResolve('host2')
"166.155.144.33-" // dnsResolve('host3') "166.155.144.33-" // dnsResolve('host3')
"122.133.144.155-" // myIpAddress() "122.133.144.155-" // myIpAddress()
"166.155.144.33-" // dnsResolve('host3') "166.155.144.33-" // dnsResolve('host3')
"__1_192.168.1.1-" // dnsResolveEx('host1') "__1_192.168.1.1-" // dnsResolveEx('host1')
"122.133.144.155-" // myIpAddress() "122.133.144.155-" // myIpAddress()
"null-" // dnsResolve('host2') "null-" // dnsResolve('host2')
"-" // dnsResolveEx('host6') "-" // dnsResolveEx('host6')
"133.122.100.200-" // myIpAddressEx() "133.122.100.200-" // myIpAddressEx()
"166.155.144.44" // dnsResolve('host1') "166.155.144.44" // dnsResolve('host1')
".test:99"; ".test:99]";
EXPECT_EQ(kExpectedResult, ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ(kExpectedResult, proxy_info.proxy_chain().ToDebugString());
// No errors. // No errors.
EXPECT_TRUE(mock_bindings.GetErrors().empty()); EXPECT_TRUE(mock_bindings.GetErrors().empty());
@@ -393,8 +393,8 @@ TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous1) {
// invocation. // invocation.
EXPECT_EQ(3u, host_resolver.num_resolve()); EXPECT_EQ(3u, host_resolver.num_resolve());
EXPECT_EQ("166.155.144.11-133.199.111.4.test:100", EXPECT_EQ("[166.155.144.11-133.199.111.4.test:100]",
ProxyServerToProxyUri(proxy_info.proxy_server())); proxy_info.proxy_chain().ToDebugString());
// No errors. // No errors.
EXPECT_TRUE(mock_bindings.GetErrors().empty()); EXPECT_TRUE(mock_bindings.GetErrors().empty());
@@ -437,8 +437,8 @@ TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous2) {
EXPECT_EQ(3u, host_resolver.num_resolve()); EXPECT_EQ(3u, host_resolver.num_resolve());
EXPECT_EQ("166.155.144.44.test:100", EXPECT_EQ("[166.155.144.44.test:100]",
ProxyServerToProxyUri(proxy_info.proxy_server())); proxy_info.proxy_chain().ToDebugString());
// There were no alerts or errors. // There were no alerts or errors.
EXPECT_TRUE(mock_bindings.GetAlerts().empty()); EXPECT_TRUE(mock_bindings.GetAlerts().empty());
@@ -475,13 +475,13 @@ TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence) {
EXPECT_EQ(20u, host_resolver.num_resolve()); EXPECT_EQ(20u, host_resolver.num_resolve());
EXPECT_EQ( EXPECT_EQ(
"[166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
"166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
"166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
"166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
"166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
"166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" "null:21]",
"null:21", proxy_info.proxy_chain().ToDebugString());
ProxyServerToProxyUri(proxy_info.proxy_server()));
// No errors. // No errors.
EXPECT_TRUE(mock_bindings.GetErrors().empty()); EXPECT_TRUE(mock_bindings.GetErrors().empty());
@@ -523,7 +523,7 @@ TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence2) {
EXPECT_EQ(20u, host_resolver.num_resolve()); EXPECT_EQ(20u, host_resolver.num_resolve());
EXPECT_EQ("null21:34", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[null21:34]", proxy_info.proxy_chain().ToDebugString());
// No errors. // No errors.
EXPECT_TRUE(mock_bindings.GetErrors().empty()); EXPECT_TRUE(mock_bindings.GetErrors().empty());
@@ -570,8 +570,8 @@ void DnsDuringInitHelper(bool synchronous_host_resolver) {
// should not have been cached. // should not have been cached.
EXPECT_EQ(4u, host_resolver.num_resolve()); EXPECT_EQ(4u, host_resolver.num_resolve());
EXPECT_EQ("91.13.12.1-91.13.12.2-145.88.13.3-137.89.8.45.test:99", EXPECT_EQ("[91.13.12.1-91.13.12.2-145.88.13.3-137.89.8.45.test:99]",
ProxyServerToProxyUri(proxy_info.proxy_server())); proxy_info.proxy_chain().ToDebugString());
// 2 alerts. // 2 alerts.
ASSERT_EQ(2u, mock_bindings.GetAlerts().size()); ASSERT_EQ(2u, mock_bindings.GetAlerts().size());
@@ -688,8 +688,8 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhilePendingCompletionTask) {
EXPECT_THAT(callback.WaitForResult(), IsOk()); EXPECT_THAT(callback.WaitForResult(), IsOk());
EXPECT_EQ("i-approve-this-message:42", EXPECT_EQ("[i-approve-this-message:42]",
ProxyServerToProxyUri(proxy_info2.proxy_server())); proxy_info2.proxy_chain().ToDebugString());
} }
// This cancellation test exercises a more predictable cancellation codepath -- // This cancellation test exercises a more predictable cancellation codepath --
@@ -879,7 +879,7 @@ TEST_F(ProxyResolverV8TracingTest, Terminate) {
// The test does 2 DNS resolutions. // The test does 2 DNS resolutions.
EXPECT_EQ(2u, host_resolver.num_resolve()); EXPECT_EQ(2u, host_resolver.num_resolve());
EXPECT_EQ("foopy:3", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[foopy:3]", proxy_info.proxy_chain().ToDebugString());
// No errors or alerts. // No errors or alerts.
EXPECT_TRUE(mock_bindings.GetErrors().empty()); EXPECT_TRUE(mock_bindings.GetErrors().empty());
@@ -979,33 +979,33 @@ TEST_F(ProxyResolverV8TracingTest, MultipleResolvers) {
// ------------------------ // ------------------------
const char* kExpectedForDnsJs = const char* kExpectedForDnsJs =
"122.133.144.155-" // myIpAddress() "[122.133.144.155-" // myIpAddress()
"null-" // dnsResolve('') "null-" // dnsResolve('')
"__1_192.168.1.1-" // dnsResolveEx('host1') "__1_192.168.1.1-" // dnsResolveEx('host1')
"null-" // dnsResolve('host2') "null-" // dnsResolve('host2')
"166.155.144.33-" // dnsResolve('host3') "166.155.144.33-" // dnsResolve('host3')
"122.133.144.155-" // myIpAddress() "122.133.144.155-" // myIpAddress()
"166.155.144.33-" // dnsResolve('host3') "166.155.144.33-" // dnsResolve('host3')
"__1_192.168.1.1-" // dnsResolveEx('host1') "__1_192.168.1.1-" // dnsResolveEx('host1')
"122.133.144.155-" // myIpAddress() "122.133.144.155-" // myIpAddress()
"null-" // dnsResolve('host2') "null-" // dnsResolve('host2')
"-" // dnsResolveEx('host6') "-" // dnsResolveEx('host6')
"133.122.100.200-" // myIpAddressEx() "133.122.100.200-" // myIpAddressEx()
"166.155.144.44" // dnsResolve('host1') "166.155.144.44" // dnsResolve('host1')
".test:99"; ".test:99]";
for (size_t i = 0; i < kNumResults; ++i) { for (size_t i = 0; i < kNumResults; ++i) {
size_t resolver_i = i % kNumResolvers; size_t resolver_i = i % kNumResolvers;
EXPECT_THAT(callback[i].WaitForResult(), IsOk()); EXPECT_THAT(callback[i].WaitForResult(), IsOk());
std::string proxy_uri = ProxyServerToProxyUri(proxy_info[i].proxy_server()); std::string proxy_uri = proxy_info[i].proxy_chain().ToDebugString();
if (resolver_i == 0 || resolver_i == 1) { if (resolver_i == 0 || resolver_i == 1) {
EXPECT_EQ(kExpectedForDnsJs, proxy_uri); EXPECT_EQ(kExpectedForDnsJs, proxy_uri);
} else if (resolver_i == 2) { } else if (resolver_i == 2) {
EXPECT_EQ("foo:99", proxy_uri); EXPECT_EQ("[foo:99]", proxy_uri);
} else if (resolver_i == 3) { } else if (resolver_i == 3) {
EXPECT_EQ("166.155.144.33.test:", EXPECT_EQ("[166.155.144.33.test:",
proxy_uri.substr(0, proxy_uri.find(':') + 1)); proxy_uri.substr(0, proxy_uri.find(':') + 1));
} else { } else {
NOTREACHED(); NOTREACHED();
@@ -1053,8 +1053,10 @@ TEST_F(ProxyResolverV8TracingTest, NetworkAnonymizationKey) {
callback.callback(), &req, mock_bindings.CreateBindings()); callback.callback(), &req, mock_bindings.CreateBindings());
EXPECT_THAT(callback.WaitForResult(), IsOk()); EXPECT_THAT(callback.WaitForResult(), IsOk());
EXPECT_EQ(2u, host_resolver.num_resolve()); EXPECT_EQ(2u, host_resolver.num_resolve());
EXPECT_EQ(kIPAddress1.ToString() + ".test", // Note: simple_dns.js sets the proxy port to the number of times its
proxy_info1.proxy_server().host_port_pair().host()); // `FindProxyForURL()` function has been called.
EXPECT_EQ("[" + kIPAddress1.ToString() + ".test:3]",
proxy_info1.proxy_chain().ToDebugString());
net::ProxyInfo proxy_info2; net::ProxyInfo proxy_info2;
resolver->GetProxyForURL( resolver->GetProxyForURL(
@@ -1062,8 +1064,8 @@ TEST_F(ProxyResolverV8TracingTest, NetworkAnonymizationKey) {
callback.callback(), &req, mock_bindings.CreateBindings()); callback.callback(), &req, mock_bindings.CreateBindings());
EXPECT_THAT(callback.WaitForResult(), IsOk()); EXPECT_THAT(callback.WaitForResult(), IsOk());
EXPECT_EQ(4u, host_resolver.num_resolve()); EXPECT_EQ(4u, host_resolver.num_resolve());
EXPECT_EQ(kIPAddress2.ToString() + ".test", EXPECT_EQ("[" + kIPAddress2.ToString() + ".test:6]",
proxy_info2.proxy_server().host_port_pair().host()); proxy_info2.proxy_chain().ToDebugString());
} }
// Make sure that net::NetworkAnonymizationKey is not passed to the // Make sure that net::NetworkAnonymizationKey is not passed to the
@@ -1107,8 +1109,10 @@ TEST_F(ProxyResolverV8TracingTest, MyIPAddressWithNetworkAnonymizationKey) {
mock_bindings.CreateBindings()); mock_bindings.CreateBindings());
EXPECT_THAT(callback.WaitForResult(), IsOk()); EXPECT_THAT(callback.WaitForResult(), IsOk());
EXPECT_EQ(2u, host_resolver.num_resolve()); EXPECT_EQ(2u, host_resolver.num_resolve());
EXPECT_EQ("1.2.3.4-5.6.7.8.test", // Note: my_ip_address.js will construct the proxy server host using calls to
proxy_info.proxy_server().host_port_pair().host()); // myIpAddress() and myIpAddressEx(), and using a hardcoded ".test:99" suffix.
EXPECT_EQ("[1.2.3.4-5.6.7.8.test:99]",
proxy_info.proxy_chain().ToDebugString());
} }
} // namespace } // namespace

@@ -184,8 +184,8 @@ TEST_F(ProxyResolverV8Test, Basic) {
int result = resolver().GetProxyForURL(GURL("http://query.com/path"), int result = resolver().GetProxyForURL(GURL("http://query.com/path"),
&proxy_info, bindings()); &proxy_info, bindings());
EXPECT_THAT(result, IsOk()); EXPECT_THAT(result, IsOk());
EXPECT_EQ("http.query.com.path.query.com:80", EXPECT_EQ("[http.query.com.path.query.com:80]",
ProxyServerToProxyUri(proxy_info.proxy_server())); proxy_info.proxy_chain().ToDebugString());
} }
{ {
net::ProxyInfo proxy_info; net::ProxyInfo proxy_info;
@@ -194,8 +194,8 @@ TEST_F(ProxyResolverV8Test, Basic) {
EXPECT_THAT(result, IsOk()); EXPECT_THAT(result, IsOk());
// Note that FindProxyForURL(url, host) does not expect |host| to contain // Note that FindProxyForURL(url, host) does not expect |host| to contain
// the port number. // the port number.
EXPECT_EQ("ftp.query.com.90.path.query.com:80", EXPECT_EQ("[ftp.query.com.90.path.query.com:80]",
ProxyServerToProxyUri(proxy_info.proxy_server())); proxy_info.proxy_chain().ToDebugString());
EXPECT_EQ(0U, bindings()->alerts.size()); EXPECT_EQ(0U, bindings()->alerts.size());
EXPECT_EQ(0U, bindings()->errors.size()); EXPECT_EQ(0U, bindings()->errors.size());
@@ -265,8 +265,8 @@ TEST_F(ProxyResolverV8Test, SideEffects) {
int result = resolver().GetProxyForURL(GURL("http://www.google.com"), int result = resolver().GetProxyForURL(GURL("http://www.google.com"),
&proxy_info, bindings()); &proxy_info, bindings());
EXPECT_THAT(result, IsOk()); EXPECT_THAT(result, IsOk());
EXPECT_EQ(base::StringPrintf("sideffect_%d:80", i), EXPECT_EQ(base::StringPrintf("[sideffect_%d:80]", i),
ProxyServerToProxyUri(proxy_info.proxy_server())); proxy_info.proxy_chain().ToDebugString());
} }
// Reload the script -- the javascript environment should be reset, hence // Reload the script -- the javascript environment should be reset, hence
@@ -278,8 +278,8 @@ TEST_F(ProxyResolverV8Test, SideEffects) {
int result = resolver().GetProxyForURL(GURL("http://www.google.com"), int result = resolver().GetProxyForURL(GURL("http://www.google.com"),
&proxy_info, bindings()); &proxy_info, bindings());
EXPECT_THAT(result, IsOk()); EXPECT_THAT(result, IsOk());
EXPECT_EQ(base::StringPrintf("sideffect_%d:80", i), EXPECT_EQ(base::StringPrintf("[sideffect_%d:80]", i),
ProxyServerToProxyUri(proxy_info.proxy_server())); proxy_info.proxy_chain().ToDebugString());
} }
} }
@@ -360,7 +360,7 @@ TEST_F(ProxyResolverV8Test, JavascriptLibrary) {
EXPECT_THAT(bindings()->errors, IsEmpty()); EXPECT_THAT(bindings()->errors, IsEmpty());
ASSERT_THAT(result, IsOk()); ASSERT_THAT(result, IsOk());
EXPECT_EQ("success:80", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[success:80]", proxy_info.proxy_chain().ToDebugString());
} }
// Test marshalling/un-marshalling of values between C++/V8. // Test marshalling/un-marshalling of values between C++/V8.
@@ -417,7 +417,7 @@ TEST_F(ProxyResolverV8Test, BindingCalledDuringInitialization) {
EXPECT_THAT(result, IsOk()); EXPECT_THAT(result, IsOk());
EXPECT_FALSE(proxy_info.is_direct()); EXPECT_FALSE(proxy_info.is_direct());
EXPECT_EQ("127.0.0.1:80", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[127.0.0.1:80]", proxy_info.proxy_chain().ToDebugString());
// Check that no other bindings were called. // Check that no other bindings were called.
EXPECT_EQ(0U, bindings()->errors.size()); EXPECT_EQ(0U, bindings()->errors.size());
@@ -440,7 +440,7 @@ TEST_F(ProxyResolverV8Test, EndsWithCommentNoNewline) {
EXPECT_THAT(result, IsOk()); EXPECT_THAT(result, IsOk());
EXPECT_FALSE(proxy_info.is_direct()); EXPECT_FALSE(proxy_info.is_direct());
EXPECT_EQ("success:80", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[success:80]", proxy_info.proxy_chain().ToDebugString());
} }
// Try loading a PAC script that ends with a statement and has no terminal // Try loading a PAC script that ends with a statement and has no terminal
@@ -456,7 +456,7 @@ TEST_F(ProxyResolverV8Test, EndsWithStatementNoNewline) {
EXPECT_THAT(result, IsOk()); EXPECT_THAT(result, IsOk());
EXPECT_FALSE(proxy_info.is_direct()); EXPECT_FALSE(proxy_info.is_direct());
EXPECT_EQ("success:3", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[success:3]", proxy_info.proxy_chain().ToDebugString());
} }
// Test the return values from myIpAddress(), myIpAddressEx(), dnsResolve(), // Test the return values from myIpAddress(), myIpAddressEx(), dnsResolve(),
@@ -472,7 +472,7 @@ TEST_F(ProxyResolverV8Test, DNSResolutionFailure) {
EXPECT_THAT(result, IsOk()); EXPECT_THAT(result, IsOk());
EXPECT_FALSE(proxy_info.is_direct()); EXPECT_FALSE(proxy_info.is_direct());
EXPECT_EQ("success:80", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[success:80]", proxy_info.proxy_chain().ToDebugString());
} }
TEST_F(ProxyResolverV8Test, DNSResolutionOfInternationDomainName) { TEST_F(ProxyResolverV8Test, DNSResolutionOfInternationDomainName) {
@@ -551,7 +551,7 @@ TEST_F(ProxyResolverV8Test, Terminate) {
EXPECT_THAT(result, IsOk()); EXPECT_THAT(result, IsOk());
EXPECT_EQ(0u, bindings()->errors.size()); EXPECT_EQ(0u, bindings()->errors.size());
EXPECT_EQ("kittens:88", ProxyServerToProxyUri(proxy_info.proxy_server())); EXPECT_EQ("[kittens:88]", proxy_info.proxy_chain().ToDebugString());
} }
} // namespace } // namespace