OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <limits.h> | 5 #include <limits.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) { | 272 TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) { |
273 std::string dictionary_domain("x.y.z.google.com"); | 273 std::string dictionary_domain("x.y.z.google.com"); |
274 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 274 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
275 | 275 |
276 // Fail the HD with D being the domain and H having a dot requirement. | 276 // Fail the HD with D being the domain and H having a dot requirement. |
277 EXPECT_FALSE(AddSdchDictionary(dictionary_text, | 277 EXPECT_FALSE(AddSdchDictionary(dictionary_text, |
278 GURL("http://w.x.y.z.google.com"))); | 278 GURL("http://w.x.y.z.google.com"))); |
279 } | 279 } |
280 | 280 |
| 281 TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionaryTrailingDot) { |
| 282 std::string dictionary_domain("x.y.z.google.com"); |
| 283 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
| 284 |
| 285 // Fail the HD with D being the domain and H having a dot requirement. |
| 286 EXPECT_FALSE(AddSdchDictionary(dictionary_text, |
| 287 GURL("http://w.x.y.z.google.com."))); |
| 288 } |
| 289 |
281 TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) { | 290 TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) { |
282 // Make sure that a prefix that matches the domain postfix won't confuse | 291 // Make sure that a prefix that matches the domain postfix won't confuse |
283 // the validation checks. | 292 // the validation checks. |
284 std::string dictionary_domain("www.google.com"); | 293 std::string dictionary_domain("www.google.com"); |
285 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 294 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
286 | 295 |
287 // Fail the HD with D being the domain and H having a dot requirement. | 296 // Fail the HD with D being the domain and H having a dot requirement. |
288 EXPECT_FALSE(AddSdchDictionary(dictionary_text, | 297 EXPECT_FALSE(AddSdchDictionary(dictionary_text, |
289 GURL("http://www.google.com.www.google.com"))); | 298 GURL("http://www.google.com.www.google.com"))); |
290 } | 299 } |
291 | 300 |
292 TEST_F(SdchManagerTest, CanSetLeadingDotDomainDictionary) { | 301 TEST_F(SdchManagerTest, CanSetLeadingDotDomainDictionary) { |
293 // Make sure that a prefix that matches the domain postfix won't confuse | 302 // Make sure that a prefix that matches the domain postfix won't confuse |
294 // the validation checks. | 303 // the validation checks. |
295 std::string dictionary_domain(".google.com"); | 304 std::string dictionary_domain(".google.com"); |
296 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 305 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
297 | 306 |
298 // Verify that a leading dot in the domain is acceptable, as long as the host | 307 // Verify that a leading dot in the domain is acceptable, as long as the host |
299 // name does not contain any dots preceding the matched domain name. | 308 // name does not contain any dots preceding the matched domain name. |
300 EXPECT_TRUE(AddSdchDictionary(dictionary_text, GURL("http://www.google.com")))
; | 309 EXPECT_TRUE(AddSdchDictionary(dictionary_text, GURL("http://www.google.com")))
; |
301 } | 310 } |
302 | 311 |
| 312 TEST_F(SdchManagerTest, |
| 313 CanSetLeadingDotDomainDictionaryFromURLWithTrailingDot) { |
| 314 // Make sure that a prefix that matches the domain postfix won't confuse |
| 315 // the validation checks. |
| 316 std::string dictionary_domain(".google.com"); |
| 317 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
| 318 |
| 319 // Verify that a leading dot in the domain is acceptable, as long as the host |
| 320 // name does not contain any dots preceding the matched domain name. |
| 321 EXPECT_TRUE(AddSdchDictionary(dictionary_text, |
| 322 GURL("http://www.google.com."))); |
| 323 } |
| 324 |
| 325 TEST_F(SdchManagerTest, CannotSetLeadingDotDomainDictionary) { |
| 326 // Make sure that a prefix that matches the domain postfix won't confuse |
| 327 // the validation checks. |
| 328 std::string dictionary_domain(".google.com"); |
| 329 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
| 330 |
| 331 // Verify that a leading dot in the domain does not affect the name containing |
| 332 // dots failure. |
| 333 EXPECT_FALSE(AddSdchDictionary(dictionary_text, |
| 334 GURL("http://www.subdomain.google.com"))); |
| 335 } |
| 336 |
| 337 TEST_F(SdchManagerTest, CannotSetLeadingDotDomainDictionaryTrailingDot) { |
| 338 // Make sure that a prefix that matches the domain postfix won't confuse |
| 339 // the validation checks. |
| 340 std::string dictionary_domain(".google.com"); |
| 341 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
| 342 |
| 343 // Verify that a trailing period in the URL doesn't affect the check. |
| 344 EXPECT_FALSE(AddSdchDictionary(dictionary_text, |
| 345 GURL("http://www.subdomain.google.com."))); |
| 346 } |
| 347 |
303 // Make sure the order of the tests is not helping us or confusing things. | 348 // Make sure the order of the tests is not helping us or confusing things. |
304 // See test CanSetExactMatchDictionary above for first try. | 349 // See test CanSetExactMatchDictionary above for first try. |
305 TEST_F(SdchManagerTest, CanStillSetExactMatchDictionary) { | 350 TEST_F(SdchManagerTest, CanStillSetExactMatchDictionary) { |
306 std::string dictionary_domain("x.y.z.google.com"); | 351 std::string dictionary_domain("x.y.z.google.com"); |
307 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); | 352 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); |
308 | 353 |
309 // Perfect match should *STILL* work. | 354 // Perfect match should *STILL* work. |
310 EXPECT_TRUE(AddSdchDictionary(dictionary_text, | 355 EXPECT_TRUE(AddSdchDictionary(dictionary_text, |
311 GURL("http://" + dictionary_domain))); | 356 GURL("http://" + dictionary_domain))); |
312 } | 357 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 dictionary = NULL; | 547 dictionary = NULL; |
503 sdch_manager()->GetVcdiffDictionary( | 548 sdch_manager()->GetVcdiffDictionary( |
504 server_hash, | 549 server_hash, |
505 GURL("http://" + dictionary_domain + "/random_url"), | 550 GURL("http://" + dictionary_domain + "/random_url"), |
506 &dictionary); | 551 &dictionary); |
507 EXPECT_FALSE(dictionary.get()); | 552 EXPECT_FALSE(dictionary.get()); |
508 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url)); | 553 EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url)); |
509 } | 554 } |
510 | 555 |
511 } // namespace net | 556 } // namespace net |
512 | |
OLD | NEW |