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

Side by Side Diff: net/proxy/proxy_config_service_linux_unittest.cc

Issue 2968573002: Check the return value of base::StringToInt() in (Closed)
Patch Set: Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/proxy/proxy_config_service_linux.h" 5 #include "net/proxy/proxy_config_service_linux.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/synchronization/lock.h" 23 #include "base/synchronization/lock.h"
24 #include "base/synchronization/waitable_event.h" 24 #include "base/synchronization/waitable_event.h"
25 #include "base/threading/thread.h" 25 #include "base/threading/thread.h"
26 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
27 #include "net/proxy/proxy_config.h" 27 #include "net/proxy/proxy_config.h"
28 #include "net/proxy/proxy_config_service_common_unittest.h" 28 #include "net/proxy/proxy_config_service_common_unittest.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 #include "testing/platform_test.h" 30 #include "testing/platform_test.h"
31 31
32 // TODO(eroman): Convert these to parameterized tests using TEST_P().
33
32 namespace net { 34 namespace net {
33 namespace { 35 namespace {
34 36
35 // Set of values for all environment variables that we might 37 // Set of values for all environment variables that we might
36 // query. NULL represents an unset variable. 38 // query. NULL represents an unset variable.
37 struct EnvVarValues { 39 struct EnvVarValues {
38 // The strange capitalization is so that the field matches the 40 // The strange capitalization is so that the field matches the
39 // environment variable name exactly. 41 // environment variable name exactly.
40 const char* DESKTOP_SESSION; 42 const char* DESKTOP_SESSION;
41 const char* HOME; 43 const char* HOME;
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 // Input. 1152 // Input.
1151 "[Proxy Settings]\nProxyType=0\n", 1153 "[Proxy Settings]\nProxyType=0\n",
1152 {}, // env_values 1154 {}, // env_values
1153 1155
1154 // Expected result. 1156 // Expected result.
1155 ProxyConfigService::CONFIG_VALID, 1157 ProxyConfigService::CONFIG_VALID,
1156 false, // auto_detect 1158 false, // auto_detect
1157 GURL(), // pac_url 1159 GURL(), // pac_url
1158 ProxyRulesExpectation::Empty(), 1160 ProxyRulesExpectation::Empty(),
1159 }, 1161 },
1162 {
1163 TEST_DESC("No proxying (negative value)"),
mmenke 2017/06/29 22:21:20 Maybe a test in each group where the ProxyType is
eroman 2017/06/29 22:33:58 Done.
1164
1165 // Input.
1166 "[Proxy Settings]\nProxyType=-3\n",
1167 {}, // env_values
1168
1169 // Expected result.
1170 ProxyConfigService::CONFIG_VALID,
1171 false, // auto_detect
1172 GURL(), // pac_url
1173 ProxyRulesExpectation::Empty(),
1174 },
1160 1175
1161 { 1176 {
1162 TEST_DESC("Auto detect"), 1177 TEST_DESC("Auto detect"),
1163 1178
1164 // Input. 1179 // Input.
1165 "[Proxy Settings]\nProxyType=3\n", 1180 "[Proxy Settings]\nProxyType=3\n",
1166 {}, // env_values 1181 {}, // env_values
1167 1182
1168 // Expected result. 1183 // Expected result.
1169 ProxyConfigService::CONFIG_VALID, 1184 ProxyConfigService::CONFIG_VALID,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 false, // auto_detect 1321 false, // auto_detect
1307 GURL(), // pac_url 1322 GURL(), // pac_url
1308 ProxyRulesExpectation::PerScheme( 1323 ProxyRulesExpectation::PerScheme(
1309 "www.google.com:80", // http 1324 "www.google.com:80", // http
1310 "", // https 1325 "", // https
1311 "", // ftp 1326 "", // ftp
1312 "*.google.com,*.kde.org"), // bypass rules 1327 "*.google.com,*.kde.org"), // bypass rules
1313 }, 1328 },
1314 1329
1315 { 1330 {
1316 TEST_DESC("Correctly parse bypass list with ReversedException"), 1331 TEST_DESC("Correctly parse bypass list with ReversedException=true"),
1317 1332
1318 // Input. 1333 // Input.
1319 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n" 1334 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
1320 "NoProxyFor=.google.com\nReversedException=true\n", 1335 "NoProxyFor=.google.com\nReversedException=true\n",
1321 {}, // env_values 1336 {}, // env_values
1322 1337
1323 // Expected result. 1338 // Expected result.
1324 ProxyConfigService::CONFIG_VALID, 1339 ProxyConfigService::CONFIG_VALID,
1325 false, // auto_detect 1340 false, // auto_detect
1326 GURL(), // pac_url 1341 GURL(), // pac_url
1327 ProxyRulesExpectation::PerSchemeWithBypassReversed( 1342 ProxyRulesExpectation::PerSchemeWithBypassReversed(
1328 "www.google.com:80", // http 1343 "www.google.com:80", // http
1329 "", // https 1344 "", // https
1330 "", // ftp 1345 "", // ftp
1331 "*.google.com"), // bypass rules 1346 "*.google.com"), // bypass rules
1332 }, 1347 },
1333 1348
1334 { 1349 {
1350 TEST_DESC("Correctly parse bypass list with ReversedException=1"),
1351
1352 // Input.
1353 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
1354 "NoProxyFor=.google.com\nReversedException=1\n",
1355 {}, // env_values
1356
1357 // Expected result.
1358 ProxyConfigService::CONFIG_VALID,
1359 false, // auto_detect
1360 GURL(), // pac_url
1361 ProxyRulesExpectation::PerSchemeWithBypassReversed(
1362 "www.google.com:80", // http
1363 "", // https
1364 "", // ftp
1365 "*.google.com"), // bypass rules
1366 },
1367
1368 {
1369 TEST_DESC("Correctly parse bypass list with ReversedException=false"),
eroman 2017/06/29 21:11:18 This is weird -- it tries parsing "false" as a num
1370
1371 // Input.
1372 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
1373 "NoProxyFor=.google.com\nReversedException=false\n",
1374 {}, // env_values
1375
1376 // Expected result.
1377 ProxyConfigService::CONFIG_VALID,
1378 false, // auto_detect
1379 GURL(), // pac_url
1380 ProxyRulesExpectation::PerScheme("www.google.com:80", // http
1381 "", // https
1382 "", // ftp
1383 "*.google.com"), // bypass rules
1384 },
1385
1386 {
1387 TEST_DESC("Correctly parse bypass list with "
1388 "ReversedException=18446744073709551617"),
eroman 2017/06/29 21:11:18 Previously this would be interpreted as true (beca
1389
1390 // Input.
1391 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
1392 "NoProxyFor=.google.com\nReversedException=18446744073709551617\n",
1393 {}, // env_values
1394
1395 // Expected result.
1396 ProxyConfigService::CONFIG_VALID,
1397 false, // auto_detect
1398 GURL(), // pac_url
1399 ProxyRulesExpectation::PerScheme("www.google.com:80", // http
1400 "", // https
1401 "", // ftp
1402 "*.google.com"), // bypass rules
1403 },
1404
1405 {
1335 TEST_DESC("socks"), 1406 TEST_DESC("socks"),
1336 1407
1337 // Input. 1408 // Input.
1338 "[Proxy Settings]\nProxyType=1\nsocksProxy=socks.com 888\n", 1409 "[Proxy Settings]\nProxyType=1\nsocksProxy=socks.com 888\n",
1339 {}, // env_values 1410 {}, // env_values
1340 1411
1341 // Expected result. 1412 // Expected result.
1342 ProxyConfigService::CONFIG_VALID, 1413 ProxyConfigService::CONFIG_VALID,
1343 false, // auto_detect 1414 false, // auto_detect
1344 GURL(), // pac_url 1415 GURL(), // pac_url
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 1872
1802 //----------------------------------------------------- 1873 //-----------------------------------------------------
1803 1874
1804 // TODO(eroman): Add a test where kioslaverc is deleted next. Currently this 1875 // TODO(eroman): Add a test where kioslaverc is deleted next. Currently this
1805 // doesn't trigger any notifications, but it probably should. 1876 // doesn't trigger any notifications, but it probably should.
1806 } 1877 }
1807 1878
1808 } // namespace 1879 } // namespace
1809 1880
1810 } // namespace net 1881 } // namespace net
OLDNEW
« net/proxy/proxy_config_service_linux.cc ('K') | « 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