1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/proxy/proxy_config_service_win.h"
7 #include "net/base/net_errors.h"
8 #include "net/proxy/proxy_config.h"
9 #include "net/proxy/proxy_config_service_common_unittest.h"
10 #include "testing/gtest/include/gtest/gtest.h"
14 TEST(ProxyConfigServiceWinTest
, SetFromIEConfig
) {
17 WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ie_config
;
19 // Expected outputs (fields of the ProxyConfig).
22 ProxyRulesExpectation proxy_rules
;
23 const char* proxy_bypass_list
; // newline separated
29 NULL
, // lpszAutoConfigUrl
31 NULL
, // lpszProxyBypass
37 ProxyRulesExpectation::Empty(),
44 L
"http://wpad/wpad.dat", // lpszAutoConfigUrl
46 NULL
, // lpszProxy_bypass
51 GURL("http://wpad/wpad.dat"), // pac_url
52 ProxyRulesExpectation::Empty(),
55 // Invalid PAC url string.
59 L
"wpad.dat", // lpszAutoConfigUrl
61 NULL
, // lpszProxy_bypass
67 ProxyRulesExpectation::Empty(),
70 // Single-host in proxy list.
74 NULL
, // lpszAutoConfigUrl
75 L
"www.google.com", // lpszProxy
76 NULL
, // lpszProxy_bypass
82 ProxyRulesExpectation::Single(
83 "www.google.com:80", // single proxy
87 // Per-scheme proxy rules.
91 NULL
, // lpszAutoConfigUrl
92 L
"http=www.google.com:80;https=www.foo.com:110", // lpszProxy
93 NULL
, // lpszProxy_bypass
99 ProxyRulesExpectation::PerScheme(
100 "www.google.com:80", // http
101 "www.foo.com:110", // https
106 // SOCKS proxy configuration.
109 FALSE
, // fAutoDetect
110 NULL
, // lpszAutoConfigUrl
111 L
"http=www.google.com:80;https=www.foo.com:110;"
112 L
"ftp=ftpproxy:20;socks=foopy:130", // lpszProxy
113 NULL
, // lpszProxy_bypass
117 // Note that "socks" is interprted as meaning "socks4", since that is how
118 // Internet Explorer applies the settings. For more details on this
120 // http://code.google.com/p/chromium/issues/detail?id=55912#c2
121 false, // auto_detect
123 ProxyRulesExpectation::PerSchemeWithSocks(
124 "www.google.com:80", // http
125 "www.foo.com:110", // https
126 "ftpproxy:20", // ftp
127 "socks4://foopy:130", // socks
131 // Bypass local names.
135 NULL
, // lpszAutoConfigUrl
137 L
"<local>", // lpszProxy_bypass
142 ProxyRulesExpectation::EmptyWithBypass("<local>"),
145 // Bypass "google.com" and local names, using semicolon as delimiter
146 // (ignoring white space).
150 NULL
, // lpszAutoConfigUrl
152 L
"<local> ; google.com", // lpszProxy_bypass
158 ProxyRulesExpectation::EmptyWithBypass("<local>,google.com"),
161 // Bypass "foo.com" and "google.com", using lines as delimiter.
165 NULL
, // lpszAutoConfigUrl
167 L
"foo.com\r\ngoogle.com", // lpszProxy_bypass
173 ProxyRulesExpectation::EmptyWithBypass("foo.com,google.com"),
176 // Bypass "foo.com" and "google.com", using commas as delimiter.
180 NULL
, // lpszAutoConfigUrl
182 L
"foo.com, google.com", // lpszProxy_bypass
188 ProxyRulesExpectation::EmptyWithBypass("foo.com,google.com"),
192 for (size_t i
= 0; i
< ARRAYSIZE_UNSAFE(tests
); ++i
) {
194 ProxyConfigServiceWin::SetFromIEConfig(&config
, tests
[i
].ie_config
);
196 EXPECT_EQ(tests
[i
].auto_detect
, config
.auto_detect());
197 EXPECT_EQ(tests
[i
].pac_url
, config
.pac_url());
198 EXPECT_TRUE(tests
[i
].proxy_rules
.Matches(config
.proxy_rules()));
199 EXPECT_EQ(PROXY_CONFIG_SOURCE_SYSTEM
, config
.source());