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

Side by Side Diff: net/cookies/cookie_store_unittest.h

Issue 2246613003: Update cookie value and attribute setting behavior to match other UAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fixes from mmenke Created 4 years, 4 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 | « no previous file | net/cookies/parsed_cookie.cc » ('j') | net/cookies/parsed_cookie.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NET_COOKIES_COOKIE_STORE_UNITTEST_H_ 5 #ifndef NET_COOKIES_COOKIE_STORE_UNITTEST_H_
6 #define NET_COOKIES_COOKIE_STORE_UNITTEST_H_ 6 #define NET_COOKIES_COOKIE_STORE_UNITTEST_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 EXPECT_FALSE(it->IsPersistent()); 458 EXPECT_FALSE(it->IsPersistent());
459 // Some CookieStores don't store last access date. 459 // Some CookieStores don't store last access date.
460 if (!it->LastAccessDate().is_null()) 460 if (!it->LastAccessDate().is_null())
461 EXPECT_EQ(it->CreationDate(), it->LastAccessDate()); 461 EXPECT_EQ(it->CreationDate(), it->LastAccessDate());
462 EXPECT_TRUE(it->IsSecure()); 462 EXPECT_TRUE(it->IsSecure());
463 EXPECT_FALSE(it->IsHttpOnly()); 463 EXPECT_FALSE(it->IsHttpOnly());
464 464
465 EXPECT_TRUE(++it == cookies.end()); 465 EXPECT_TRUE(++it == cookies.end());
466 } 466 }
467 467
468 TYPED_TEST_P(CookieStoreTest, EmptyKeyTest) {
469 CookieStore* cs = this->GetCookieStore();
470
471 GURL url1("http://foo1.bar.com");
472 EXPECT_TRUE(this->SetCookie(cs, url1, "foo"));
473 EXPECT_EQ("foo", this->GetCookies(cs, url1));
474
475 // Regression tests for https://crbug.com/601786
476 GURL url2("http://foo2.bar.com");
477 EXPECT_TRUE(this->SetCookie(cs, url2, "foo"));
478 EXPECT_TRUE(this->SetCookie(cs, url2, "\t"));
479 EXPECT_EQ("", this->GetCookies(cs, url2));
480
481 GURL url3("http://foo3.bar.com");
482 EXPECT_TRUE(this->SetCookie(cs, url3, "foo"));
483 EXPECT_TRUE(this->SetCookie(cs, url3, "="));
484 EXPECT_EQ("", this->GetCookies(cs, url3));
485
486 GURL url4("http://foo4.bar.com");
487 EXPECT_TRUE(this->SetCookie(cs, url4, "foo"));
488 EXPECT_TRUE(this->SetCookie(cs, url4, ""));
489 EXPECT_EQ("", this->GetCookies(cs, url4));
490
491 GURL url5("http://foo5.bar.com");
492 EXPECT_TRUE(this->SetCookie(cs, url5, "foo"));
493 EXPECT_TRUE(this->SetCookie(cs, url5, "; bar"));
494 EXPECT_EQ("", this->GetCookies(cs, url5));
495
496 GURL url6("http://foo6.bar.com");
497 EXPECT_TRUE(this->SetCookie(cs, url6, "foo"));
498 EXPECT_TRUE(this->SetCookie(cs, url6, " "));
499 EXPECT_EQ("", this->GetCookies(cs, url6));
500 }
501
468 TYPED_TEST_P(CookieStoreTest, DomainTest) { 502 TYPED_TEST_P(CookieStoreTest, DomainTest) {
469 CookieStore* cs = this->GetCookieStore(); 503 CookieStore* cs = this->GetCookieStore();
470 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "A=B")); 504 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "A=B"));
471 this->MatchCookieLines("A=B", 505 this->MatchCookieLines("A=B",
472 this->GetCookies(cs, this->http_www_google_.url())); 506 this->GetCookies(cs, this->http_www_google_.url()));
473 EXPECT_TRUE( 507 EXPECT_TRUE(
474 this->SetCookie(cs, this->http_www_google_.url(), 508 this->SetCookie(cs, this->http_www_google_.url(),
475 this->http_www_google_.Format("C=D; domain=.%D"))); 509 this->http_www_google_.Format("C=D; domain=.%D")));
476 this->MatchCookieLines("A=B; C=D", 510 this->MatchCookieLines("A=B; C=D",
477 this->GetCookies(cs, this->http_www_google_.url())); 511 this->GetCookies(cs, this->http_www_google_.url()));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 589
556 // Test that setting a cookie which specifies an invalid domain has 590 // Test that setting a cookie which specifies an invalid domain has
557 // no side-effect. An invalid domain in this context is one which does 591 // no side-effect. An invalid domain in this context is one which does
558 // not match the originating domain. 592 // not match the originating domain.
559 TYPED_TEST_P(CookieStoreTest, InvalidDomainTest) { 593 TYPED_TEST_P(CookieStoreTest, InvalidDomainTest) {
560 CookieStore* cs = this->GetCookieStore(); 594 CookieStore* cs = this->GetCookieStore();
561 GURL url_foobar("http://foo.bar.com"); 595 GURL url_foobar("http://foo.bar.com");
562 596
563 // More specific sub-domain than allowed. 597 // More specific sub-domain than allowed.
564 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "a=1; domain=.yo.foo.bar.com")); 598 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "a=1; domain=.yo.foo.bar.com"));
599 // Regression test for https://crbug.com/601786
600 EXPECT_FALSE(
601 this->SetCookie(cs, url_foobar, "a=1; domain=.yo.foo.bar.com; domain="));
565 602
566 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "b=2; domain=.foo.com")); 603 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "b=2; domain=.foo.com"));
567 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "c=3; domain=.bar.foo.com")); 604 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "c=3; domain=.bar.foo.com"));
568 605
569 // Different TLD, but the rest is a substring. 606 // Different TLD, but the rest is a substring.
570 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "d=4; domain=.foo.bar.com.net")); 607 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "d=4; domain=.foo.bar.com.net"));
571 608
572 // A substring that isn't really a parent domain. 609 // A substring that isn't really a parent domain.
573 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "e=5; domain=ar.com")); 610 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "e=5; domain=ar.com"));
574 611
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 this->MatchCookieLines("A=B; C=D", 1404 this->MatchCookieLines("A=B; C=D",
1368 this->GetCookies(cs, this->http_www_google_.url())); 1405 this->GetCookies(cs, this->http_www_google_.url()));
1369 // Delete the session cookie. 1406 // Delete the session cookie.
1370 this->DeleteSessionCookies(cs); 1407 this->DeleteSessionCookies(cs);
1371 // Check that the session cookie has been deleted but not the persistent one. 1408 // Check that the session cookie has been deleted but not the persistent one.
1372 EXPECT_EQ("C=D", this->GetCookies(cs, this->http_www_google_.url())); 1409 EXPECT_EQ("C=D", this->GetCookies(cs, this->http_www_google_.url()));
1373 } 1410 }
1374 1411
1375 REGISTER_TYPED_TEST_CASE_P(CookieStoreTest, 1412 REGISTER_TYPED_TEST_CASE_P(CookieStoreTest,
1376 SetCookieWithDetailsAsync, 1413 SetCookieWithDetailsAsync,
1414 EmptyKeyTest,
1377 DomainTest, 1415 DomainTest,
1378 DomainWithTrailingDotTest, 1416 DomainWithTrailingDotTest,
1379 ValidSubdomainTest, 1417 ValidSubdomainTest,
1380 InvalidDomainTest, 1418 InvalidDomainTest,
1381 InvalidDomainSameDomainAndRegistry, 1419 InvalidDomainSameDomainAndRegistry,
1382 DomainWithoutLeadingDotParentDomain, 1420 DomainWithoutLeadingDotParentDomain,
1383 DomainWithoutLeadingDotSameDomain, 1421 DomainWithoutLeadingDotSameDomain,
1384 CaseInsensitiveDomainTest, 1422 CaseInsensitiveDomainTest,
1385 TestIpAddress, 1423 TestIpAddress,
1386 TestIpAddressNoDomainCookies, 1424 TestIpAddressNoDomainCookies,
(...skipping 19 matching lines...) Expand all
1406 OverwritePersistentCookie, 1444 OverwritePersistentCookie,
1407 CookieOrdering, 1445 CookieOrdering,
1408 GetAllCookiesAsync, 1446 GetAllCookiesAsync,
1409 DeleteCookieAsync, 1447 DeleteCookieAsync,
1410 DeleteCanonicalCookieAsync, 1448 DeleteCanonicalCookieAsync,
1411 DeleteSessionCookie); 1449 DeleteSessionCookie);
1412 1450
1413 } // namespace net 1451 } // namespace net
1414 1452
1415 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ 1453 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_
OLDNEW
« no previous file with comments | « no previous file | net/cookies/parsed_cookie.cc » ('j') | net/cookies/parsed_cookie.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698