summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_service_unittest.cc
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-04 02:33:58 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-04 02:33:58 +0000
commit7ec7c1899afc8537bb25ce373aa2e136aa7788dc (patch)
treec108e17742ec31aef01eef3824d1388b8a3f8937 /net/proxy/proxy_service_unittest.cc
parent5cd1f8f498abd2ed8d0bd545b224b95918cbec72 (diff)
downloadchromium_src-7ec7c1899afc8537bb25ce373aa2e136aa7788dc.zip
chromium_src-7ec7c1899afc8537bb25ce373aa2e136aa7788dc.tar.gz
chromium_src-7ec7c1899afc8537bb25ce373aa2e136aa7788dc.tar.bz2
Split out HttpUtil::SpecForRequest() into a more generic function of net_util.h.
This was a TODO, since that function is useful outside of HTTP. In the process, I uncovered some test cases in proxy_service that are passing in invalid URLs (by virtue of the extra DCHECK). This doesn't make much sense to me to support that, so I have changed them. Review URL: http://codereview.chromium.org/160558 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22359 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_service_unittest.cc')
-rw-r--r--net/proxy/proxy_service_unittest.cc33
1 files changed, 30 insertions, 3 deletions
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
index f13df7c..b6b62b6 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -236,6 +236,33 @@ TEST(ProxyServiceTest, PAC) {
EXPECT_EQ("foopy:80", info.proxy_server().ToURI());
}
+// Test that the proxy resolver does not see the URL's username/password
+// or its reference section.
+TEST(ProxyServiceTest, PAC_NoIdentityOrHash) {
+ MockProxyConfigService* config_service =
+ new MockProxyConfigService("http://foopy/proxy.pac");
+
+ MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver;
+
+ ProxyService service(config_service, resolver);
+
+ GURL url("http://username:password@www.google.com/?ref#hash#hash");
+
+ ProxyInfo info;
+ TestCompletionCallback callback;
+ int rv = service.ResolveProxy(url, &info, &callback, NULL);
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+
+ EXPECT_EQ(GURL("http://foopy/proxy.pac"), resolver->pac_url());
+ ASSERT_EQ(1u, resolver->pending_requests().size());
+ // The URL should have been simplified, stripping the username/password/hash.
+ EXPECT_EQ(GURL("http://www.google.com/?ref"),
+ resolver->pending_requests()[0]->url());
+
+ // We end here without ever completing the request -- destruction of
+ // ProxyService will cancel the outstanding request.
+}
+
TEST(ProxyServiceTest, PAC_FailoverToDirect) {
MockProxyConfigService* config_service =
new MockProxyConfigService("http://foopy/proxy.pac");
@@ -589,7 +616,7 @@ TEST(ProxyServiceTest, ProxyBypassList) {
{
ProxyService service(new MockProxyConfigService(config),
new MockAsyncProxyResolver());
- GURL test_url("local");
+ GURL test_url("http://local");
TestCompletionCallback callback;
int rv = service.ResolveProxy(test_url, &info, &callback, NULL);
EXPECT_EQ(OK, rv);
@@ -811,7 +838,7 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) {
config.proxy_rules.ParseFromString("foopy1:8080");
ProxyService service(new MockProxyConfigService(config),
new MockAsyncProxyResolver);
- GURL test_url("www.microsoft.com");
+ GURL test_url("http://www.microsoft.com");
ProxyInfo info;
TestCompletionCallback callback;
int rv = service.ResolveProxy(test_url, &info, &callback, NULL);
@@ -866,7 +893,7 @@ TEST(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
{
ProxyService service(new MockProxyConfigService(config),
new MockAsyncProxyResolver);
- GURL test_url("www.microsoft.com");
+ GURL test_url("unknown://www.microsoft.com");
ProxyInfo info;
TestCompletionCallback callback;
int rv = service.ResolveProxy(test_url, &info, &callback, NULL);