Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: net/proxy/proxy_config_unittest.cc

Issue 12315019: Change ProxyRules to handle ProxyLists rather than just single ProxyServer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/proxy/proxy_config_unittest.cc
diff --git a/net/proxy/proxy_config_unittest.cc b/net/proxy/proxy_config_unittest.cc
index 47ea68946f671c8842901e206f82941074d0956c..64cf31d2eb902dd5726cec8c54e42affb1e9fce3 100644
--- a/net/proxy/proxy_config_unittest.cc
+++ b/net/proxy/proxy_config_unittest.cc
@@ -11,11 +11,11 @@ namespace net {
namespace {
void ExpectProxyServerEquals(const char* expectation,
- const ProxyServer& proxy_server) {
+ const ProxyList& proxy_servers) {
if (expectation == NULL) {
- EXPECT_FALSE(proxy_server.is_valid());
+ EXPECT_TRUE(proxy_servers.IsEmpty());
} else {
- EXPECT_EQ(expectation, proxy_server.ToURI());
+ EXPECT_EQ(expectation, proxy_servers.ToPacString());
}
}
@@ -51,21 +51,21 @@ TEST(ProxyConfigTest, Equals) {
// Test |ProxyConfig::proxy_rules|.
config2.proxy_rules().type = ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
- config2.proxy_rules().single_proxy =
- ProxyServer::FromURI("myproxy:80", ProxyServer::SCHEME_HTTP);
+ config2.proxy_rules().single_proxy.SetSingleProxyServer(
+ ProxyServer::FromURI("myproxy:80", ProxyServer::SCHEME_HTTP));
EXPECT_FALSE(config1.Equals(config2));
EXPECT_FALSE(config2.Equals(config1));
config1.proxy_rules().type = ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
- config1.proxy_rules().single_proxy =
- ProxyServer::FromURI("myproxy:100", ProxyServer::SCHEME_HTTP);
+ config1.proxy_rules().single_proxy.SetSingleProxyServer(
+ ProxyServer::FromURI("myproxy:100", ProxyServer::SCHEME_HTTP));
EXPECT_FALSE(config1.Equals(config2));
EXPECT_FALSE(config2.Equals(config1));
- config1.proxy_rules().single_proxy =
- ProxyServer::FromURI("myproxy", ProxyServer::SCHEME_HTTP);
+ config1.proxy_rules().single_proxy.SetSingleProxyServer(
+ ProxyServer::FromURI("myproxy", ProxyServer::SCHEME_HTTP));
EXPECT_TRUE(config1.Equals(config2));
EXPECT_TRUE(config2.Equals(config1));
@@ -100,6 +100,7 @@ TEST(ProxyConfigTest, ParseProxyRules) {
const char* proxy_rules;
ProxyConfig::ProxyRules::Type type;
+ // These will be PAC-stle strings, eg 'PROXY foo.com'
const char* single_proxy;
const char* proxy_for_http;
const char* proxy_for_https;
@@ -111,7 +112,7 @@ TEST(ProxyConfigTest, ParseProxyRules) {
"myproxy:80",
ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY,
- "myproxy:80",
+ "PROXY myproxy:80",
NULL,
NULL,
NULL,
@@ -124,7 +125,7 @@ TEST(ProxyConfigTest, ParseProxyRules) {
ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
NULL,
- "myproxy:80",
+ "PROXY myproxy:80",
NULL,
NULL,
NULL,
@@ -137,8 +138,8 @@ TEST(ProxyConfigTest, ParseProxyRules) {
ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
NULL,
NULL,
- "socks4://foopy:1080",
- "ftp-proxy:80",
+ "SOCKS foopy:1080",
+ "PROXY ftp-proxy:80",
NULL,
},
@@ -149,7 +150,7 @@ TEST(ProxyConfigTest, ParseProxyRules) {
"foopy ; ftp=ftp-proxy",
ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY,
- "foopy:80",
+ "PROXY foopy:80",
NULL,
NULL,
NULL,
@@ -166,11 +167,11 @@ TEST(ProxyConfigTest, ParseProxyRules) {
NULL,
NULL,
NULL,
- "ftp-proxy:80",
+ "PROXY ftp-proxy:80",
NULL,
},
- // Include duplicate entries -- last one wins.
+ // Include duplicate entries for a single scheme.
{
"ftp=ftp1 ; ftp=ftp2 ; ftp=ftp3",
@@ -178,10 +179,35 @@ TEST(ProxyConfigTest, ParseProxyRules) {
NULL,
NULL,
NULL,
- "ftp3:80",
+ "PROXY ftp1:80;PROXY ftp2:80;PROXY ftp3:80",
+ NULL,
+ },
+
+ // Include duplicate entries for a multiple schemes.
+ {
+ "ftp=ftp1 ; http=http1; ftp=ftp2 ; http=http2 ; ftp=ftp3",
+
+ ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
+ NULL,
+ "PROXY http1:80;PROXY http2:80",
+ NULL,
+ "PROXY ftp1:80;PROXY ftp2:80;PROXY ftp3:80",
NULL,
},
+ // Include non-default proxy schemes.
+ {
+ "http=https://secure_proxy; ftp=socks4://socks_proxy; https=socks://foo",
+
+ ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
+ NULL,
+ "HTTPS secure_proxy:443",
+ "SOCKS5 foo:1080",
+ "SOCKS socks_proxy:1080",
+ NULL,
+ },
+
+
// Only SOCKS proxy present, others being blank.
{
"socks=foopy",
@@ -191,7 +217,7 @@ TEST(ProxyConfigTest, ParseProxyRules) {
NULL,
NULL,
NULL,
- "socks4://foopy:1080",
+ "SOCKS foopy:1080",
},
// SOCKS proxy present along with other proxies too
@@ -200,10 +226,10 @@ TEST(ProxyConfigTest, ParseProxyRules) {
ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
NULL,
- "httpproxy:80",
- "httpsproxy:80",
- "ftpproxy:80",
- "socks4://foopy:1080",
+ "PROXY httpproxy:80",
+ "PROXY httpsproxy:80",
+ "PROXY ftpproxy:80",
+ "SOCKS foopy:1080",
},
// SOCKS proxy (with modifier) present along with some proxies
@@ -213,10 +239,10 @@ TEST(ProxyConfigTest, ParseProxyRules) {
ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
NULL,
- "httpproxy:80",
- "httpsproxy:80",
+ "PROXY httpproxy:80",
+ "PROXY httpsproxy:80",
NULL,
- "socks5://foopy:1080",
+ "SOCKS5 foopy:1080",
},
// Include unsupported schemes -- they are discarded.
@@ -226,10 +252,35 @@ TEST(ProxyConfigTest, ParseProxyRules) {
ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
NULL,
NULL,
- "myhttpsproxy:80",
+ "PROXY myhttpsproxy:80",
NULL,
NULL,
},
+
+ // direct:// discarded as a first or only option for a scheme.
eroman 2013/02/26 01:13:50 Why do we do this?
marq_use_my_chromium_address 2013/02/27 23:08:19 We don't any more.
+ {
+ "http=direct://; http=myhttpproxy; https=direct://",
+
+ ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
+ NULL,
+ "PROXY myhttpproxy:80",
+ NULL,
+ NULL,
+ NULL,
+ },
+
+ // direct:// kept as a second option for a scheme.
+ {
+ "http=myhttpproxy; http=direct://",
+
+ ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
+ NULL,
+ "PROXY myhttpproxy:80;DIRECT",
+ NULL,
+ NULL,
+ NULL,
+ },
+
};
ProxyConfig config;

Powered by Google App Engine
This is Rietveld 408576698