Commit f363f71c authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Add more tests for IPv4 mapped IPv6 literals in proxy resolution.

Bug: 997359
Change-Id: I6d6dbe7d9ee75b82506530529318044873a28f39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769703
Commit-Queue: Eric Roman <eroman@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690132}
parent 4d24a33c
......@@ -94,6 +94,13 @@ void ExpectBypassMisc(
"[FD80::1]",
"foo",
"www.example3.com",
// TODO(crbug.com/997359): This should be moved into
// ExpectBypassLocalHost().
"[::ffff:127.0.0.1]",
"[::ffff:127.100.0.0]",
// TODO(crbug.com/997359): This should be moved into
// ExpectBypassLinkLocal().
"[::ffff:169.254.3.2]",
#if !defined(BYPASS_LOOPBACK)
"loopback",
"loopback.",
......@@ -379,6 +386,7 @@ TEST(ProxyBypassRulesTest, ParseAndMatchCIDR_IPv4) {
EXPECT_TRUE(rules.Matches(GURL("http://192.168.1.1")));
EXPECT_TRUE(rules.Matches(GURL("ftp://192.168.4.4")));
EXPECT_TRUE(rules.Matches(GURL("https://192.168.0.0:81")));
// Test that an IPv4 mapped IPv6 literal matches an IPv4 CIDR rule.
EXPECT_TRUE(rules.Matches(GURL("http://[::ffff:192.168.11.11]")));
EXPECT_FALSE(rules.Matches(GURL("http://foobar.com")));
......@@ -396,6 +404,21 @@ TEST(ProxyBypassRulesTest, ParseAndMatchCIDR_IPv6) {
EXPECT_TRUE(rules.Matches(GURL("http://[A:b:C:9::]")));
EXPECT_FALSE(rules.Matches(GURL("http://foobar.com")));
EXPECT_FALSE(rules.Matches(GURL("http://192.169.1.1")));
// Test that an IPv4 literal matches an IPv4 mapped IPv6 CIDR rule.
// This is the IPv4 mapped equivalent to 192.168.1.1/16.
rules.ParseFromString("::ffff:192.168.1.1/112");
EXPECT_TRUE(rules.Matches(GURL("http://[::ffff:192.168.1.3]")));
EXPECT_TRUE(rules.Matches(GURL("http://192.168.11.11")));
EXPECT_FALSE(rules.Matches(GURL("http://10.10.1.1")));
// Test using an IP range that is close to IPv4 mapped, but not
// quite. Should not result in matches.
rules.ParseFromString("::fffe:192.168.1.1/112");
EXPECT_TRUE(rules.Matches(GURL("http://[::fffe:192.168.1.3]")));
EXPECT_FALSE(rules.Matches(GURL("http://[::ffff:192.168.1.3]")));
EXPECT_FALSE(rules.Matches(GURL("http://192.168.11.11")));
EXPECT_FALSE(rules.Matches(GURL("http://10.10.1.1")));
}
// Test that parsing an IPv6 range given a bracketed literal is not supported.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment