OLD | NEW |
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 "chrome/browser/policy/url_blacklist_manager.h" | 5 #include "chrome/browser/policy/url_blacklist_manager.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 EXPECT_TRUE(URLBlacklist::HasStandardScheme(GURL("ws://example.com"))); | 233 EXPECT_TRUE(URLBlacklist::HasStandardScheme(GURL("ws://example.com"))); |
234 EXPECT_TRUE(URLBlacklist::HasStandardScheme(GURL("wss://example.com"))); | 234 EXPECT_TRUE(URLBlacklist::HasStandardScheme(GURL("wss://example.com"))); |
235 EXPECT_FALSE(URLBlacklist::HasStandardScheme(GURL("wtf://example.com"))); | 235 EXPECT_FALSE(URLBlacklist::HasStandardScheme(GURL("wtf://example.com"))); |
236 } | 236 } |
237 | 237 |
238 INSTANTIATE_TEST_CASE_P( | 238 INSTANTIATE_TEST_CASE_P( |
239 URLBlacklistFilterToComponentsTestInstance, | 239 URLBlacklistFilterToComponentsTestInstance, |
240 URLBlacklistFilterToComponentsTest, | 240 URLBlacklistFilterToComponentsTest, |
241 testing::Values( | 241 testing::Values( |
242 FilterTestParams("google.com", | 242 FilterTestParams("google.com", |
243 "", ".google.com", true, 0u, ""), | 243 std::string(), |
| 244 ".google.com", |
| 245 true, |
| 246 0u, |
| 247 std::string()), |
244 FilterTestParams(".google.com", | 248 FilterTestParams(".google.com", |
245 "", "google.com", false, 0u, ""), | 249 std::string(), |
| 250 "google.com", |
| 251 false, |
| 252 0u, |
| 253 std::string()), |
246 FilterTestParams("http://google.com", | 254 FilterTestParams("http://google.com", |
247 "http", ".google.com", true, 0u, ""), | 255 "http", |
| 256 ".google.com", |
| 257 true, |
| 258 0u, |
| 259 std::string()), |
248 FilterTestParams("google.com/", | 260 FilterTestParams("google.com/", |
249 "", ".google.com", true, 0u, "/"), | 261 std::string(), |
| 262 ".google.com", |
| 263 true, |
| 264 0u, |
| 265 "/"), |
250 FilterTestParams("http://google.com:8080/whatever", | 266 FilterTestParams("http://google.com:8080/whatever", |
251 "http", ".google.com", true, 8080u, "/whatever"), | 267 "http", |
| 268 ".google.com", |
| 269 true, |
| 270 8080u, |
| 271 "/whatever"), |
252 FilterTestParams("http://user:pass@google.com:8080/whatever", | 272 FilterTestParams("http://user:pass@google.com:8080/whatever", |
253 "http", ".google.com", true, 8080u, "/whatever"), | 273 "http", |
| 274 ".google.com", |
| 275 true, |
| 276 8080u, |
| 277 "/whatever"), |
254 FilterTestParams("123.123.123.123", | 278 FilterTestParams("123.123.123.123", |
255 "", "123.123.123.123", false, 0u, ""), | 279 std::string(), |
| 280 "123.123.123.123", |
| 281 false, |
| 282 0u, |
| 283 std::string()), |
256 FilterTestParams("https://123.123.123.123", | 284 FilterTestParams("https://123.123.123.123", |
257 "https", "123.123.123.123", false, 0u, ""), | 285 "https", |
| 286 "123.123.123.123", |
| 287 false, |
| 288 0u, |
| 289 std::string()), |
258 FilterTestParams("123.123.123.123/", | 290 FilterTestParams("123.123.123.123/", |
259 "", "123.123.123.123", false, 0u, "/"), | 291 std::string(), |
| 292 "123.123.123.123", |
| 293 false, |
| 294 0u, |
| 295 "/"), |
260 FilterTestParams("http://123.123.123.123:123/whatever", | 296 FilterTestParams("http://123.123.123.123:123/whatever", |
261 "http", "123.123.123.123", false, 123u, "/whatever"), | 297 "http", |
| 298 "123.123.123.123", |
| 299 false, |
| 300 123u, |
| 301 "/whatever"), |
262 FilterTestParams("*", | 302 FilterTestParams("*", |
263 "", "", true, 0u, ""), | 303 std::string(), |
| 304 std::string(), |
| 305 true, |
| 306 0u, |
| 307 std::string()), |
264 FilterTestParams("ftp://*", | 308 FilterTestParams("ftp://*", |
265 "ftp", "", true, 0u, ""), | 309 "ftp", |
| 310 std::string(), |
| 311 true, |
| 312 0u, |
| 313 std::string()), |
266 FilterTestParams("http://*/whatever", | 314 FilterTestParams("http://*/whatever", |
267 "http", "", true, 0u, "/whatever"))); | 315 "http", |
| 316 std::string(), |
| 317 true, |
| 318 0u, |
| 319 "/whatever"))); |
268 | 320 |
269 TEST_F(URLBlacklistManagerTest, Filtering) { | 321 TEST_F(URLBlacklistManagerTest, Filtering) { |
270 URLBlacklist blacklist; | 322 URLBlacklist blacklist; |
271 | 323 |
272 // Block domain and all subdomains, for any filtered scheme. | 324 // Block domain and all subdomains, for any filtered scheme. |
273 scoped_ptr<base::ListValue> blocked(new base::ListValue); | 325 scoped_ptr<base::ListValue> blocked(new base::ListValue); |
274 blocked->Append(new base::StringValue("google.com")); | 326 blocked->Append(new base::StringValue("google.com")); |
275 blacklist.Block(blocked.get()); | 327 blacklist.Block(blocked.get()); |
276 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://google.com"))); | 328 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://google.com"))); |
277 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://google.com/"))); | 329 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://google.com/"))); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 517 |
466 // Sync gets a free pass. | 518 // Sync gets a free pass. |
467 GURL sync_url( | 519 GURL sync_url( |
468 GaiaUrls::GetInstance()->service_login_url() + "?service=chromiumsync"); | 520 GaiaUrls::GetInstance()->service_login_url() + "?service=chromiumsync"); |
469 net::URLRequest sync_request(sync_url, NULL, &context); | 521 net::URLRequest sync_request(sync_url, NULL, &context); |
470 sync_request.set_load_flags(net::LOAD_MAIN_FRAME); | 522 sync_request.set_load_flags(net::LOAD_MAIN_FRAME); |
471 EXPECT_FALSE(blacklist_manager_->IsRequestBlocked(sync_request)); | 523 EXPECT_FALSE(blacklist_manager_->IsRequestBlocked(sync_request)); |
472 } | 524 } |
473 | 525 |
474 } // namespace policy | 526 } // namespace policy |
OLD | NEW |