pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Pavel Kalinnikov | d797063 | 2017-06-20 09:07:34 | [diff] [blame] | 5 | #include "components/url_pattern_index/url_pattern.h" |
pkalinnikov | 35d1881 | 2017-04-05 17:28:18 | [diff] [blame] | 6 | |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 7 | #include "testing/gtest/include/gtest/gtest.h" |
| 8 | #include "url/gurl.h" |
| 9 | |
Pavel Kalinnikov | d797063 | 2017-06-20 09:07:34 | [diff] [blame] | 10 | namespace url_pattern_index { |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 11 | |
| 12 | namespace { |
| 13 | |
| 14 | constexpr proto::AnchorType kAnchorNone = proto::ANCHOR_TYPE_NONE; |
| 15 | constexpr proto::AnchorType kBoundary = proto::ANCHOR_TYPE_BOUNDARY; |
| 16 | constexpr proto::AnchorType kSubdomain = proto::ANCHOR_TYPE_SUBDOMAIN; |
Karan Bhatia | a9c4e1d | 2018-09-10 23:37:47 | [diff] [blame] | 17 | constexpr UrlPattern::MatchCase kMatchCase = UrlPattern::MatchCase::kTrue; |
| 18 | constexpr UrlPattern::MatchCase kDonotMatchCase = UrlPattern::MatchCase::kFalse; |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 19 | |
| 20 | } // namespace |
| 21 | |
Karan Bhatia | a9c4e1d | 2018-09-10 23:37:47 | [diff] [blame] | 22 | TEST(UrlPatternTest, MatchesUrl) { |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 23 | const struct { |
| 24 | UrlPattern url_pattern; |
| 25 | const char* url; |
| 26 | bool expect_match; |
| 27 | } kTestCases[] = { |
pkalinnikov | 35d1881 | 2017-04-05 17:28:18 | [diff] [blame] | 28 | {{"", proto::URL_PATTERN_TYPE_SUBSTRING}, "http://ex.com/", true}, |
| 29 | {{"", proto::URL_PATTERN_TYPE_WILDCARDED}, "http://ex.com/", true}, |
| 30 | {{"", kBoundary, kAnchorNone}, "http://ex.com/", true}, |
| 31 | {{"", kSubdomain, kAnchorNone}, "http://ex.com/", true}, |
| 32 | {{"", kSubdomain, kAnchorNone}, "http://ex.com/", true}, |
| 33 | {{"^", kSubdomain, kAnchorNone}, "http://ex.com/", false}, |
| 34 | {{".", kSubdomain, kAnchorNone}, "http://ex.com/", false}, |
| 35 | {{"", kAnchorNone, kBoundary}, "http://ex.com/", true}, |
| 36 | {{"^", kAnchorNone, kBoundary}, "http://ex.com/", true}, |
| 37 | {{".", kAnchorNone, kBoundary}, "http://ex.com/", false}, |
| 38 | {{"", kBoundary, kBoundary}, "http://ex.com/", false}, |
| 39 | {{"", kSubdomain, kBoundary}, "http://ex.com/", false}, |
| 40 | {{"com/", kSubdomain, kBoundary}, "http://ex.com/", true}, |
| 41 | |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 42 | {{"xampl", proto::URL_PATTERN_TYPE_SUBSTRING}, |
| 43 | "http://example.com", |
| 44 | true}, |
| 45 | {{"example", proto::URL_PATTERN_TYPE_SUBSTRING}, |
| 46 | "http://example.com", |
| 47 | true}, |
| 48 | {{"/a?a"}, "http://ex.com/a?a", true}, |
| 49 | {{"^abc"}, "http://ex.com/abc?a", true}, |
| 50 | {{"^abc"}, "http://ex.com/a?abc", true}, |
| 51 | {{"^abc"}, "http://ex.com/abc?abc", true}, |
pkalinnikov | 35d1881 | 2017-04-05 17:28:18 | [diff] [blame] | 52 | {{"^abc^abc"}, "http://ex.com/abc?abc", true}, |
| 53 | {{"^com^abc^abc"}, "http://ex.com/abc?abc", false}, |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 54 | |
| 55 | {{"http://ex", kBoundary, kAnchorNone}, "http://example.com", true}, |
pkalinnikov | 35d1881 | 2017-04-05 17:28:18 | [diff] [blame] | 56 | {{"http://ex", kAnchorNone, kAnchorNone}, "http://example.com", true}, |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 57 | {{"mple.com/", kAnchorNone, kBoundary}, "http://example.com", true}, |
pkalinnikov | 35d1881 | 2017-04-05 17:28:18 | [diff] [blame] | 58 | {{"mple.com/", kAnchorNone, kAnchorNone}, "http://example.com", true}, |
| 59 | {{"mple.com/", kSubdomain, kAnchorNone}, "http://example.com", false}, |
| 60 | {{"ex.com", kSubdomain, kAnchorNone}, "http://hex.com", false}, |
| 61 | {{"ex.com", kSubdomain, kAnchorNone}, "http://ex.com", true}, |
| 62 | {{"ex.com", kSubdomain, kAnchorNone}, "http://hex.ex.com", true}, |
| 63 | {{"ex.com", kSubdomain, kAnchorNone}, "http://hex.hex.com", false}, |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 64 | |
| 65 | // Note: "example.com" will be normalized into "example.com/". |
Charlie Harrison | e88a4853 | 2018-12-04 20:31:58 | [diff] [blame] | 66 | {{"example.com^", kSubdomain, kAnchorNone}, |
| 67 | "http://www.example.com", |
| 68 | true}, |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 69 | {{"http://*mpl", kBoundary, kAnchorNone}, "http://example.com", true}, |
| 70 | {{"mpl*com/", kAnchorNone, kBoundary}, "http://example.com", true}, |
| 71 | {{"example^com"}, "http://example.com", false}, |
| 72 | {{"example^com"}, "http://example/com", true}, |
| 73 | {{"example.com^"}, "http://example.com:8080", true}, |
| 74 | {{"http*.com/", kBoundary, kBoundary}, "http://example.com", true}, |
| 75 | {{"http*.org/", kBoundary, kBoundary}, "http://example.com", false}, |
| 76 | |
| 77 | {{"/path?*&p1=*&p2="}, "http://ex.com/aaa/path/bbb?k=v&p1=0&p2=1", false}, |
| 78 | {{"/path?*&p1=*&p2="}, "http://ex.com/aaa/path?k=v&p1=0&p2=1", true}, |
| 79 | {{"/path?*&p1=*&p2="}, "http://ex.com/aaa/path?k=v&k=v&p1=0&p2=1", true}, |
| 80 | {{"/path?*&p1=*&p2="}, |
| 81 | "http://ex.com/aaa/path?k=v&p1=0&p3=10&p2=1", |
| 82 | true}, |
| 83 | {{"/path?*&p1=*&p2="}, "http://ex.com/aaa/path&p1=0&p2=1", false}, |
| 84 | {{"/path?*&p1=*&p2="}, "http://ex.com/aaa/path?k=v&p2=0&p1=1", false}, |
| 85 | |
| 86 | {{"abc*def*ghijk*xyz"}, |
| 87 | "http://example.com/abcdeffffghijkmmmxyzzz", |
| 88 | true}, |
| 89 | {{"abc*cdef"}, "http://example.com/abcdef", false}, |
| 90 | |
| 91 | {{"^^a^^"}, "http://ex.com/?a=/", true}, |
| 92 | {{"^^a^^"}, "http://ex.com/?a=/&b=0", true}, |
Karan Bhatia | 1d1eaed2 | 2019-02-20 21:07:17 | [diff] [blame] | 93 | {{"^^a^^"}, "http://ex.com/?a=x", false}, |
| 94 | // The last ^ matches the end of the url. |
| 95 | {{"^^a^^"}, "http://ex.com/?a=", true}, |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 96 | |
| 97 | {{"ex.com^path^*k=v^"}, "http://ex.com/path/?k1=v1&ak=v&kk=vv", true}, |
| 98 | {{"ex.com^path^*k=v^"}, "http://ex.com/p/path/?k1=v1&ak=v&kk=vv", false}, |
| 99 | {{"a^a&a^a&"}, "http://ex.com/a/a/a/a/?a&a&a&a&a", true}, |
| 100 | |
| 101 | {{"abc*def^"}, "http://ex.com/abc/a/ddef/", true}, |
pkalinnikov | 854818d6 | 2016-07-22 11:55:10 | [diff] [blame] | 102 | |
| 103 | {{"https://example.com/"}, "http://example.com/", false}, |
| 104 | {{"example.com/", kSubdomain, kAnchorNone}, "http://example.com/", true}, |
| 105 | {{"examp", kSubdomain, kAnchorNone}, "http://example.com/", true}, |
| 106 | {{"xamp", kSubdomain, kAnchorNone}, "http://example.com/", false}, |
| 107 | {{"examp", kSubdomain, kAnchorNone}, "http://test.example.com/", true}, |
| 108 | {{"t.examp", kSubdomain, kAnchorNone}, "http://test.example.com/", false}, |
| 109 | {{"com^", kSubdomain, kAnchorNone}, "http://test.example.com/", true}, |
Charles Harrison | 78ff41bf | 2018-02-08 20:21:11 | [diff] [blame] | 110 | {{"com^x", kSubdomain, kBoundary}, "http://a.com/x", true}, |
pkalinnikov | 854818d6 | 2016-07-22 11:55:10 | [diff] [blame] | 111 | {{"x.com", kSubdomain, kAnchorNone}, "http://ex.com/?url=x.com", false}, |
| 112 | {{"ex.com/", kSubdomain, kBoundary}, "http://ex.com/", true}, |
| 113 | {{"ex.com^", kSubdomain, kBoundary}, "http://ex.com/", true}, |
| 114 | {{"ex.co", kSubdomain, kBoundary}, "http://ex.com/", false}, |
| 115 | {{"ex.com", kSubdomain, kBoundary}, "http://rex.com.ex.com/", false}, |
| 116 | {{"ex.com/", kSubdomain, kBoundary}, "http://rex.com.ex.com/", true}, |
| 117 | {{"http", kSubdomain, kBoundary}, "http://http.com/", false}, |
| 118 | {{"http", kSubdomain, kAnchorNone}, "http://http.com/", true}, |
| 119 | {{"/example.com", kSubdomain, kBoundary}, "http://example.com/", false}, |
| 120 | {{"/example.com/", kSubdomain, kBoundary}, "http://example.com/", false}, |
Charles Harrison | 78ff41bf | 2018-02-08 20:21:11 | [diff] [blame] | 121 | {{".", kSubdomain, kAnchorNone}, "http://a..com/", true}, |
| 122 | {{"^", kSubdomain, kAnchorNone}, "http://a..com/", false}, |
| 123 | {{".", kSubdomain, kAnchorNone}, "http://a.com./", false}, |
| 124 | {{"^", kSubdomain, kAnchorNone}, "http://a.com./", true}, |
| 125 | {{".", kSubdomain, kAnchorNone}, "http://a.com../", true}, |
| 126 | {{"^", kSubdomain, kAnchorNone}, "http://a.com../", true}, |
| 127 | {{"/path", kSubdomain, kAnchorNone}, "http://a.com./path/to/x", true}, |
| 128 | {{"^path", kSubdomain, kAnchorNone}, "http://a.com./path/to/x", true}, |
| 129 | {{"/path", kSubdomain, kBoundary}, "http://a.com./path", true}, |
| 130 | {{"^path", kSubdomain, kBoundary}, "http://a.com./path", true}, |
| 131 | {{"path", kSubdomain, kBoundary}, "http://a.com./path", false}, |
Karan Bhatia | a9c4e1d | 2018-09-10 23:37:47 | [diff] [blame] | 132 | // Case-sensitivity tests. |
| 133 | {{"path", proto::URL_PATTERN_TYPE_SUBSTRING, kDonotMatchCase}, |
| 134 | "http://a.com/PaTh", |
| 135 | true}, |
| 136 | {{"path", proto::URL_PATTERN_TYPE_SUBSTRING, kMatchCase}, |
| 137 | "http://a.com/PaTh", |
| 138 | false}, |
| 139 | {{"path", proto::URL_PATTERN_TYPE_SUBSTRING, kDonotMatchCase}, |
| 140 | "http://a.com/path", |
| 141 | true}, |
| 142 | {{"path", proto::URL_PATTERN_TYPE_SUBSTRING, kMatchCase}, |
| 143 | "http://a.com/path", |
| 144 | true}, |
| 145 | {{"abc*def^", proto::URL_PATTERN_TYPE_WILDCARDED, kMatchCase}, |
| 146 | "http://a.com/abcxAdef/vo", |
| 147 | true}, |
| 148 | {{"abc*def^", proto::URL_PATTERN_TYPE_WILDCARDED, kMatchCase}, |
| 149 | "http://a.com/aBcxAdeF/vo", |
| 150 | false}, |
| 151 | {{"abc*def^", proto::URL_PATTERN_TYPE_WILDCARDED, kDonotMatchCase}, |
| 152 | "http://a.com/aBcxAdeF/vo", |
| 153 | true}, |
| 154 | {{"abc*def^", proto::URL_PATTERN_TYPE_WILDCARDED, kDonotMatchCase}, |
| 155 | "http://a.com/abcxAdef/vo", |
| 156 | true}, |
Karan Bhatia | 1d1eaed2 | 2019-02-20 21:07:17 | [diff] [blame] | 157 | {{"abc^", kAnchorNone, kAnchorNone}, "https://xyz.com/abc/123", true}, |
| 158 | {{"abc^", kAnchorNone, kAnchorNone}, "https://xyz.com/abc", true}, |
| 159 | {{"abc^", kAnchorNone, kAnchorNone}, "https://abc.com", false}, |
| 160 | {{"abc^", kAnchorNone, kBoundary}, "https://xyz.com/abc/", true}, |
| 161 | {{"abc^", kAnchorNone, kBoundary}, "https://xyz.com/abc", true}, |
| 162 | {{"abc^", kAnchorNone, kBoundary}, "https://xyz.com/abc/123", false}, |
| 163 | {{"http://abc.com/x^", kBoundary, kAnchorNone}, "http://abc.com/x", true}, |
| 164 | {{"http://abc.com/x^", kBoundary, kAnchorNone}, |
| 165 | "http://abc.com/x/", |
| 166 | true}, |
| 167 | {{"http://abc.com/x^", kBoundary, kAnchorNone}, |
| 168 | "http://abc.com/x/123", |
| 169 | true}, |
| 170 | {{"http://abc.com/x^", kBoundary, kBoundary}, "http://abc.com/x", true}, |
| 171 | {{"http://abc.com/x^", kBoundary, kBoundary}, "http://abc.com/x/", true}, |
| 172 | {{"http://abc.com/x^", kBoundary, kBoundary}, |
| 173 | "http://abc.com/x/123", |
| 174 | false}, |
| 175 | {{"abc.com^", kSubdomain, kAnchorNone}, "http://xyz.abc.com/123", true}, |
| 176 | {{"abc.com^", kSubdomain, kAnchorNone}, "http://xyz.abc.com", true}, |
| 177 | {{"abc.com^", kSubdomain, kAnchorNone}, |
| 178 | "http://abc.com.xyz.com?q=abc.com", |
| 179 | false}, |
| 180 | {{"abc.com^", kSubdomain, kBoundary}, "http://xyz.abc.com/123", false}, |
| 181 | {{"abc.com^", kSubdomain, kBoundary}, "http://xyz.abc.com", true}, |
| 182 | {{"abc.com^", kSubdomain, kBoundary}, |
| 183 | "http://abc.com.xyz.com?q=abc.com/", |
| 184 | false}, |
| 185 | {{"abc*^", kAnchorNone, kAnchorNone}, "https://abc.com", true}, |
| 186 | {{"abc*^", kAnchorNone, kAnchorNone}, "https://abc.com?q=123", true}, |
| 187 | {{"abc*^", kAnchorNone, kBoundary}, "https://abc.com", true}, |
| 188 | {{"abc*^", kAnchorNone, kBoundary}, "https://abc.com?q=123", true}, |
Karandeep Bhatia | cf2b1a0 | 2019-02-25 23:09:31 | [diff] [blame] | 189 | {{"abc*", kAnchorNone, kBoundary}, "https://a.com/abcxyz", true}, |
| 190 | {{"*google.com", kBoundary, kAnchorNone}, "https://www.google.com", true}, |
| 191 | {{"*", kBoundary, kBoundary}, "https://example.com", true}, |
| 192 | {{"", kBoundary, kBoundary}, "https://example.com", false}, |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | for (const auto& test_case : kTestCases) { |
pkalinnikov | 35d1881 | 2017-04-05 17:28:18 | [diff] [blame] | 196 | SCOPED_TRACE(testing::Message() << "Rule: " << test_case.url_pattern |
| 197 | << "; URL: " << GURL(test_case.url)); |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 198 | |
Karan Bhatia | e0aeb0e | 2018-09-12 18:57:21 | [diff] [blame] | 199 | GURL url(test_case.url); |
| 200 | const bool is_match = |
| 201 | test_case.url_pattern.MatchesUrl(UrlPattern::UrlInfo(url)); |
pkalinnikov | 15cf724 | 2016-07-13 08:57:34 | [diff] [blame] | 202 | EXPECT_EQ(test_case.expect_match, is_match); |
| 203 | } |
| 204 | } |
| 205 | |
Pavel Kalinnikov | d797063 | 2017-06-20 09:07:34 | [diff] [blame] | 206 | } // namespace url_pattern_index |