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

Unified Diff: net/proxy/proxy_config_service_linux_unittest.cc

Issue 2968573002: Check the return value of base::StringToInt() in (Closed)
Patch Set: address mmenke's comments Created 3 years, 6 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
« no previous file with comments | « net/proxy/proxy_config_service_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_config_service_linux_unittest.cc
diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc
index 6650825a04f6946f107703fe0bb6d3b788e32210..0bda1a456f06a5bdee7497d2fe117c1139de98f3 100644
--- a/net/proxy/proxy_config_service_linux_unittest.cc
+++ b/net/proxy/proxy_config_service_linux_unittest.cc
@@ -29,6 +29,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+// TODO(eroman): Convert these to parameterized tests using TEST_P().
+
namespace net {
namespace {
@@ -1157,6 +1159,33 @@ TEST_F(ProxyConfigServiceLinuxTest, KDEConfigParser) {
GURL(), // pac_url
ProxyRulesExpectation::Empty(),
},
+ {
+ TEST_DESC("Invalid proxy type (ProxyType=-3)"),
+
+ // Input.
+ "[Proxy Settings]\nProxyType=-3\n",
+ {}, // env_values
+
+ // Expected result.
+ ProxyConfigService::CONFIG_VALID,
+ false, // auto_detect
+ GURL(), // pac_url
+ ProxyRulesExpectation::Empty(),
+ },
+
+ {
+ TEST_DESC("Invalid proxy type (ProxyType=AB-)"),
+
+ // Input.
+ "[Proxy Settings]\nProxyType=AB-\n",
+ {}, // env_values
+
+ // Expected result.
+ ProxyConfigService::CONFIG_VALID,
+ false, // auto_detect
+ GURL(), // pac_url
+ ProxyRulesExpectation::Empty(),
+ },
{
TEST_DESC("Auto detect"),
@@ -1313,7 +1342,7 @@ TEST_F(ProxyConfigServiceLinuxTest, KDEConfigParser) {
},
{
- TEST_DESC("Correctly parse bypass list with ReversedException"),
+ TEST_DESC("Correctly parse bypass list with ReversedException=true"),
// Input.
"[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
@@ -1331,6 +1360,79 @@ TEST_F(ProxyConfigServiceLinuxTest, KDEConfigParser) {
"*.google.com"), // bypass rules
},
+ {
+ TEST_DESC("Correctly parse bypass list with ReversedException=false"),
+
+ // Input.
+ "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
+ "NoProxyFor=.google.com\nReversedException=false\n",
+ {}, // env_values
+
+ // Expected result.
+ ProxyConfigService::CONFIG_VALID,
+ false, // auto_detect
+ GURL(), // pac_url
+ ProxyRulesExpectation::PerScheme("www.google.com:80", // http
+ "", // https
+ "", // ftp
+ "*.google.com"), // bypass rules
+ },
+
+ {
+ TEST_DESC("Correctly parse bypass list with ReversedException=1"),
+
+ // Input.
+ "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
+ "NoProxyFor=.google.com\nReversedException=1\n",
+ {}, // env_values
+
+ // Expected result.
+ ProxyConfigService::CONFIG_VALID,
+ false, // auto_detect
+ GURL(), // pac_url
+ ProxyRulesExpectation::PerSchemeWithBypassReversed(
+ "www.google.com:80", // http
+ "", // https
+ "", // ftp
+ "*.google.com"), // bypass rules
+ },
+
+ {
+ TEST_DESC("Overflow: ReversedException=18446744073709551617"),
+
+ // Input.
+ "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
+ "NoProxyFor=.google.com\nReversedException=18446744073709551617\n",
+ {}, // env_values
+
+ // Expected result.
+ ProxyConfigService::CONFIG_VALID,
+ false, // auto_detect
+ GURL(), // pac_url
+ ProxyRulesExpectation::PerScheme("www.google.com:80", // http
+ "", // https
+ "", // ftp
+ "*.google.com"), // bypass rules
+ },
+
+ {
+ TEST_DESC("Not a number: ReversedException=noitpecxE"),
+
+ // Input.
+ "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
+ "NoProxyFor=.google.com\nReversedException=noitpecxE\n",
+ {}, // env_values
+
+ // Expected result.
+ ProxyConfigService::CONFIG_VALID,
+ false, // auto_detect
+ GURL(), // pac_url
+ ProxyRulesExpectation::PerScheme("www.google.com:80", // http
+ "", // https
+ "", // ftp
+ "*.google.com"), // bypass rules
+ },
+
{
TEST_DESC("socks"),
« no previous file with comments | « net/proxy/proxy_config_service_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698