| Index: net/proxy/proxy_service_unittest.cc
|
| diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
|
| index 6271809c7745044f3c7352b0d288df63ac634168..8086284ef93159c33b435e4b598d85547a86187a 100644
|
| --- a/net/proxy/proxy_service_unittest.cc
|
| +++ b/net/proxy/proxy_service_unittest.cc
|
| @@ -382,6 +382,35 @@ TEST_F(ProxyServiceTest, PAC_FailoverAfterDirect) {
|
| EXPECT_TRUE(info.is_empty());
|
| }
|
|
|
| +TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) {
|
| + // Test whether the ProxyConfigSource set by the ProxyConfigService is applied
|
| + // to ProxyInfo after the proxy is resolved via a PAC script.
|
| + ProxyConfig config =
|
| + ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac"));
|
| + config.set_source(PROXY_CONFIG_SOURCE_TEST);
|
| +
|
| + MockProxyConfigService* config_service = new MockProxyConfigService(config);
|
| + MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver;
|
| + ProxyService service(config_service, resolver, NULL);
|
| +
|
| + // Resolve something.
|
| + GURL url("http://www.google.com/");
|
| + ProxyInfo info;
|
| + TestCompletionCallback callback;
|
| + int rv = service.ResolveProxy(
|
| + url, &info, callback.callback(), NULL, BoundNetLog());
|
| + ASSERT_EQ(ERR_IO_PENDING, rv);
|
| + resolver->pending_set_pac_script_request()->CompleteNow(OK);
|
| + ASSERT_EQ(1u, resolver->pending_requests().size());
|
| +
|
| + // Set the result in proxy resolver.
|
| + resolver->pending_requests()[0]->results()->UseNamedProxy("foopy");
|
| + resolver->pending_requests()[0]->CompleteNow(OK);
|
| +
|
| + EXPECT_EQ(OK, callback.WaitForResult());
|
| + EXPECT_EQ(PROXY_CONFIG_SOURCE_TEST, info.config_source());
|
| +}
|
| +
|
| TEST_F(ProxyServiceTest, ProxyResolverFails) {
|
| // Test what happens when the ProxyResolver fails. The download and setting
|
| // of the PAC script have already succeeded, so this corresponds with a
|
| @@ -1120,6 +1149,56 @@ TEST_F(ProxyServiceTest, PerProtocolProxyTests) {
|
| }
|
| }
|
|
|
| +TEST_F(ProxyServiceTest, ProxyConfigSourcePropagates) {
|
| + // Test that the proxy config source is set correctly when resolving proxies
|
| + // using manual proxy rules. Namely, the config source should only be set if
|
| + // any of the rules were applied.
|
| + {
|
| + ProxyConfig config;
|
| + config.set_source(PROXY_CONFIG_SOURCE_TEST);
|
| + config.proxy_rules().ParseFromString("https=foopy2:8080");
|
| + ProxyService service(
|
| + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
|
| + GURL test_url("http://www.google.com");
|
| + ProxyInfo info;
|
| + TestCompletionCallback callback;
|
| + int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
|
| + BoundNetLog());
|
| + ASSERT_EQ(OK, rv);
|
| + // Should be SOURCE_NONE, since there are no HTTP proxies configured.
|
| + EXPECT_EQ(PROXY_CONFIG_SOURCE_NONE, info.config_source());
|
| + }
|
| + {
|
| + ProxyConfig config;
|
| + config.set_source(PROXY_CONFIG_SOURCE_TEST);
|
| + config.proxy_rules().ParseFromString("https=foopy2:8080");
|
| + ProxyService service(
|
| + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
|
| + GURL test_url("https://www.google.com");
|
| + ProxyInfo info;
|
| + TestCompletionCallback callback;
|
| + int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
|
| + BoundNetLog());
|
| + ASSERT_EQ(OK, rv);
|
| + // Used the HTTPS proxy. So source should be TEST.
|
| + EXPECT_EQ(PROXY_CONFIG_SOURCE_TEST, info.config_source());
|
| + }
|
| + {
|
| + ProxyConfig config;
|
| + config.set_source(PROXY_CONFIG_SOURCE_TEST);
|
| + ProxyService service(
|
| + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
|
| + GURL test_url("http://www.google.com");
|
| + ProxyInfo info;
|
| + TestCompletionCallback callback;
|
| + int rv = service.ResolveProxy(test_url, &info, callback.callback(), NULL,
|
| + BoundNetLog());
|
| + ASSERT_EQ(OK, rv);
|
| + // ProxyConfig is empty. Source should be NONE.
|
| + EXPECT_EQ(PROXY_CONFIG_SOURCE_NONE, info.config_source());
|
| + }
|
| +}
|
| +
|
| // If only HTTP and a SOCKS proxy are specified, check if ftp/https queries
|
| // fall back to the SOCKS proxy.
|
| TEST_F(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
|
|
|