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

Unified Diff: net/cookies/canonical_cookie_unittest.cc

Issue 1868493002: Ignore cookies with invalid 'SameSite' attribute values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/cookies/parsed_cookie.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/canonical_cookie_unittest.cc
diff --git a/net/cookies/canonical_cookie_unittest.cc b/net/cookies/canonical_cookie_unittest.cc
index a7e82fd9d82b22b8273cd99da7c2e22df461cc27..80b772e9b2f427250612c5ada047926a5558b4da 100644
--- a/net/cookies/canonical_cookie_unittest.cc
+++ b/net/cookies/canonical_cookie_unittest.cc
@@ -93,12 +93,6 @@ TEST(CanonicalCookieTest, Create) {
EXPECT_EQ(CookieSameSite::STRICT_MODE, cookie->SameSite());
cookie = CanonicalCookie::Create(url, "A=2; SameSite=Lax", creation_time,
same_site_options);
- EXPECT_TRUE(cookie.get());
- EXPECT_EQ(CookieSameSite::LAX_MODE, cookie->SameSite());
- cookie = CanonicalCookie::Create(url, "A=2; SameSite", creation_time,
- same_site_options);
- EXPECT_TRUE(cookie.get());
- EXPECT_EQ(CookieSameSite::NO_RESTRICTION, cookie->SameSite());
// Test the creating cookies using specific parameter instead of a cookie
// string.
@@ -129,6 +123,23 @@ TEST(CanonicalCookieTest, Create) {
EXPECT_EQ(CookieSameSite::NO_RESTRICTION, cookie->SameSite());
}
+TEST(CanonicalCookieTest, CreateInvalidSameSite) {
+ GURL url("http://www.example.com/test/foo.html");
+ base::Time now = base::Time::Now();
+ scoped_ptr<CanonicalCookie> cookie;
+ CookieOptions options;
+
+ // Invalid 'SameSite' attribute values.
+ options.set_same_site_cookie_mode(
+ CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX);
+
+ cookie = CanonicalCookie::Create(url, "A=2; SameSite=Invalid", now, options);
+ EXPECT_EQ(nullptr, cookie.get());
+
+ cookie = CanonicalCookie::Create(url, "A=2; SameSite", now, options);
+ EXPECT_EQ(nullptr, cookie.get());
+}
+
TEST(CanonicalCookieTest, EmptyExpiry) {
GURL url("http://www7.ipdl.inpit.go.jp/Tokujitu/tjkta.ipdl?N0000=108");
base::Time creation_time = base::Time::Now();
« no previous file with comments | « no previous file | net/cookies/parsed_cookie.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698