OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_bypass_rules.h" | 5 #include "net/proxy/proxy_bypass_rules.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "net/proxy/proxy_config_service_common_unittest.h" | 9 #include "net/proxy/proxy_config_service_common_unittest.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 // This is a bit of a gray-area, but GURL does not strip trailing dots | 269 // This is a bit of a gray-area, but GURL does not strip trailing dots |
270 // in host-names, so the following are considered non-local. | 270 // in host-names, so the following are considered non-local. |
271 {"http://www./x", false}, | 271 {"http://www./x", false}, |
272 {"http://localhost./x", false}, | 272 {"http://localhost./x", false}, |
273 }; | 273 }; |
274 | 274 |
275 ProxyBypassRules rules; | 275 ProxyBypassRules rules; |
276 rules.ParseFromString("<local>"); | 276 rules.ParseFromString("<local>"); |
277 | 277 |
278 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 278 for (size_t i = 0; i < arraysize(tests); ++i) { |
279 SCOPED_TRACE(base::StringPrintf( | 279 SCOPED_TRACE(base::StringPrintf( |
280 "Test[%d]: %s", static_cast<int>(i), tests[i].url)); | 280 "Test[%d]: %s", static_cast<int>(i), tests[i].url)); |
281 EXPECT_EQ(tests[i].expected_is_local, rules.Matches(GURL(tests[i].url))); | 281 EXPECT_EQ(tests[i].expected_is_local, rules.Matches(GURL(tests[i].url))); |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 TEST(ProxyBypassRulesTest, ParseAndMatchCIDR_IPv4) { | 285 TEST(ProxyBypassRulesTest, ParseAndMatchCIDR_IPv4) { |
286 ProxyBypassRules rules; | 286 ProxyBypassRules rules; |
287 rules.ParseFromString("192.168.1.1/16"); | 287 rules.ParseFromString("192.168.1.1/16"); |
288 ASSERT_EQ(1u, rules.rules().size()); | 288 ASSERT_EQ(1u, rules.rules().size()); |
(...skipping 17 matching lines...) Expand all Loading... |
306 EXPECT_EQ("a:b:c:d::/48", rules.rules()[0]->ToString()); | 306 EXPECT_EQ("a:b:c:d::/48", rules.rules()[0]->ToString()); |
307 | 307 |
308 EXPECT_TRUE(rules.Matches(GURL("http://[A:b:C:9::]"))); | 308 EXPECT_TRUE(rules.Matches(GURL("http://[A:b:C:9::]"))); |
309 EXPECT_FALSE(rules.Matches(GURL("http://foobar.com"))); | 309 EXPECT_FALSE(rules.Matches(GURL("http://foobar.com"))); |
310 EXPECT_FALSE(rules.Matches(GURL("http://192.169.1.1"))); | 310 EXPECT_FALSE(rules.Matches(GURL("http://192.169.1.1"))); |
311 } | 311 } |
312 | 312 |
313 } // namespace | 313 } // namespace |
314 | 314 |
315 } // namespace net | 315 } // namespace net |
OLD | NEW |