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

Unified Diff: net/cookies/canonical_cookie_unittest.cc

Issue 2898953008: Implement and test CanonicalCookie::IsCanonical() (Closed)
Patch Set: Add test param to Android Webview cookie test. Created 3 years, 6 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
Index: net/cookies/canonical_cookie_unittest.cc
diff --git a/net/cookies/canonical_cookie_unittest.cc b/net/cookies/canonical_cookie_unittest.cc
index 402846db30f8de12f427021b36be7a35d4ddd519..b59f1d205e00d3db493d66035553c6d0b275d825 100644
--- a/net/cookies/canonical_cookie_unittest.cc
+++ b/net/cookies/canonical_cookie_unittest.cc
@@ -596,6 +596,69 @@ TEST(CanonicalCookieTest, EnforceSecureCookiesRequireSecureScheme) {
EXPECT_TRUE(https_cookie_secure.get());
}
+TEST(CanonicalCookieTest, IsCanonical) {
+ EXPECT_TRUE(CanonicalCookie("A", "B", "x.y", "/path", base::Time(),
mmenke 2017/06/09 18:25:49 Some of these should use IP addresses, both v4 and
mmenke 2017/06/09 18:25:49 Also, if we choose to anything about the base last
Randy Smith (Not in Mondays) 2017/06/09 19:38:33 Current belief is that we're not going to do anyth
Randy Smith (Not in Mondays) 2017/06/09 19:38:33 Done, though give them a scan--I have no confidenc
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_TRUE(CanonicalCookie("", "B", "x.y", "/path", base::Time(),
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_FALSE(CanonicalCookie("A ", "B", "x.y", "/path", base::Time(),
mmenke 2017/06/09 18:25:49 I think these each need comments - fixuring out wh
Randy Smith (Not in Mondays) 2017/06/09 19:38:33 Completely fair--even writing them was that. I de
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_FALSE(CanonicalCookie("A=", "B", "x.y", "/path", base::Time(),
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_FALSE(CanonicalCookie("A", "B;", "x.y", "/path", base::Time(),
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_FALSE(CanonicalCookie("A", "B", ";x.y", "/path", base::Time(),
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_FALSE(CanonicalCookie("A", "B", "x.y ", "/path", base::Time(),
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_FALSE(CanonicalCookie("A", "B", "x.y", "path", base::Time(),
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_FALSE(CanonicalCookie("A", "B", "x.y", "", base::Time(), base::Time(),
+ base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_FALSE(CanonicalCookie("A", "B", "x.y", "/path ", base::Time(),
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_FALSE(CanonicalCookie("A", "B", "x.y", "/path;", base::Time(),
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+ EXPECT_TRUE(CanonicalCookie("A", "B", "x.y", "/path", base::Time(),
+ base::Time(), base::Time(), false, false,
+ CookieSameSite::NO_RESTRICTION,
+ COOKIE_PRIORITY_LOW)
+ .IsCanonical());
+}
+
TEST(CanonicalCookieTest, TestPrefixHistograms) {
base::HistogramTester histograms;
const char kCookiePrefixHistogram[] = "Cookie.CookiePrefix";

Powered by Google App Engine
This is Rietveld 408576698