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

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

Issue 1831653002: Don't allow a leading plus in ports for proxy bypass rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
« no previous file with comments | « net/proxy/proxy_bypass_rules.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 EXPECT_EQ("*.org:443", rules.rules()[0]->ToString()); 90 EXPECT_EQ("*.org:443", rules.rules()[0]->ToString());
91 91
92 EXPECT_TRUE(rules.Matches(GURL("http://www.google.org:443"))); 92 EXPECT_TRUE(rules.Matches(GURL("http://www.google.org:443")));
93 EXPECT_TRUE(rules.Matches(GURL("https://www.google.org"))); 93 EXPECT_TRUE(rules.Matches(GURL("https://www.google.org")));
94 94
95 EXPECT_FALSE(rules.Matches(GURL("http://www.google.org"))); 95 EXPECT_FALSE(rules.Matches(GURL("http://www.google.org")));
96 EXPECT_FALSE(rules.Matches(GURL("https://www.google.com"))); 96 EXPECT_FALSE(rules.Matches(GURL("https://www.google.com")));
97 EXPECT_FALSE(rules.Matches(GURL("https://www.google.org.com"))); 97 EXPECT_FALSE(rules.Matches(GURL("https://www.google.org.com")));
98 } 98 }
99 99
100 // Tests a codepath that parses hostnamepattern:port, where "port" is invalid
101 // by containing a leading plus.
102 TEST(ProxyBypassRulesTest, ParseInvalidPort) {
103 ProxyBypassRules rules;
104 EXPECT_TRUE(rules.AddRuleFromString("*.org:443"));
105 EXPECT_FALSE(rules.AddRuleFromString("*.com:+443"));
106 EXPECT_FALSE(rules.AddRuleFromString("*.com:-443"));
107 }
108
100 TEST(ProxyBypassRulesTest, IPV4Address) { 109 TEST(ProxyBypassRulesTest, IPV4Address) {
101 ProxyBypassRules rules; 110 ProxyBypassRules rules;
102 rules.ParseFromString("192.168.1.1"); 111 rules.ParseFromString("192.168.1.1");
103 ASSERT_EQ(1u, rules.rules().size()); 112 ASSERT_EQ(1u, rules.rules().size());
104 EXPECT_EQ("192.168.1.1", rules.rules()[0]->ToString()); 113 EXPECT_EQ("192.168.1.1", rules.rules()[0]->ToString());
105 114
106 EXPECT_TRUE(rules.Matches(GURL("http://192.168.1.1"))); 115 EXPECT_TRUE(rules.Matches(GURL("http://192.168.1.1")));
107 EXPECT_TRUE(rules.Matches(GURL("https://192.168.1.1:90"))); 116 EXPECT_TRUE(rules.Matches(GURL("https://192.168.1.1:90")));
108 117
109 EXPECT_FALSE(rules.Matches(GURL("http://www.google.com"))); 118 EXPECT_FALSE(rules.Matches(GURL("http://www.google.com")));
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 EXPECT_EQ("a:b:c:d::/48", rules.rules()[0]->ToString()); 315 EXPECT_EQ("a:b:c:d::/48", rules.rules()[0]->ToString());
307 316
308 EXPECT_TRUE(rules.Matches(GURL("http://[A:b:C:9::]"))); 317 EXPECT_TRUE(rules.Matches(GURL("http://[A:b:C:9::]")));
309 EXPECT_FALSE(rules.Matches(GURL("http://foobar.com"))); 318 EXPECT_FALSE(rules.Matches(GURL("http://foobar.com")));
310 EXPECT_FALSE(rules.Matches(GURL("http://192.169.1.1"))); 319 EXPECT_FALSE(rules.Matches(GURL("http://192.169.1.1")));
311 } 320 }
312 321
313 } // namespace 322 } // namespace
314 323
315 } // namespace net 324 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_bypass_rules.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698