Commit fd87a8b1 authored by Dylan Cutler's avatar Dylan Cutler Committed by Chromium LUCI CQ

Have //net:net_unittests pass even if CanonicalCookie's constructor is

private.

This is part of a larger update to clean up the creation of
CanonicalCookie instances and make the default constructor private.

I verified the tests pass when the default constructor is private by
changing canonical_cookie.h when building/running net_unittests.

Bug: 1102874
Change-Id: I21e6a53d521025cd485d0abff482184143d1bf12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2564942Reviewed-by: default avatarMaksim Orlovich <morlovich@chromium.org>
Commit-Queue: Dylan Cutler <dylancutler@google.com>
Cr-Commit-Position: refs/heads/master@{#832373}
parent cd0412d2
This diff is collapsed.
......@@ -119,7 +119,7 @@ std::unique_ptr<CanonicalCookie> BuildCanonicalCookie(
: base::Time();
std::string cookie_path = pc.Path();
return std::make_unique<CanonicalCookie>(
return CanonicalCookie::CreateUnsafeCookieForTesting(
pc.Name(), pc.Value(), "." + url.host(), cookie_path, creation_time,
cookie_expires, base::Time(), pc.IsSecure(), pc.IsHttpOnly(),
pc.SameSite(), pc.Priority(), pc.IsSameParty());
......@@ -233,10 +233,11 @@ std::unique_ptr<CookieMonster> CreateMonsterFromStoreForGC(
// The URL must be HTTPS since |secure| can be true or false, and because
// strict secure cookies are enforced, the cookie will fail to be created if
// |secure| is true but the URL is an insecure scheme.
std::unique_ptr<CanonicalCookie> cc(std::make_unique<CanonicalCookie>(
"a", "1", base::StringPrintf("h%05d.izzle", i), "/path", creation_time,
expiration_time, base::Time(), secure, false,
CookieSameSite::NO_RESTRICTION, COOKIE_PRIORITY_DEFAULT, false));
std::unique_ptr<CanonicalCookie> cc =
CanonicalCookie::CreateUnsafeCookieForTesting(
"a", "1", base::StringPrintf("h%05d.izzle", i), "/path",
creation_time, expiration_time, base::Time(), secure, false,
CookieSameSite::NO_RESTRICTION, COOKIE_PRIORITY_DEFAULT, false);
cc->SetLastAccessDate(last_access_time);
store->AddCookie(*cc);
}
......
This diff is collapsed.
......@@ -550,14 +550,14 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
EXPECT_TRUE(this->SetCanonicalCookie(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"A", "B", foo_foo_host, "/foo", one_hour_ago, one_hour_from_now,
base::Time(), false /* secure */, false /* httponly */,
CookieSameSite::LAX_MODE, COOKIE_PRIORITY_DEFAULT, false),
this->www_foo_foo_.url(), true));
EXPECT_TRUE(this->SetCanonicalCookie(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"C", "D", "." + foo_bar_domain, "/bar", two_hours_ago, base::Time(),
one_hour_ago, false, true, CookieSameSite::LAX_MODE,
COOKIE_PRIORITY_DEFAULT, false),
......@@ -567,7 +567,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
EXPECT_TRUE(
this->SetCanonicalCookieReturnAccessResult(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"E", "F", http_foo_host, "/", base::Time(), base::Time(),
base::Time(), true, false, CookieSameSite::NO_RESTRICTION,
COOKIE_PRIORITY_DEFAULT, false),
......@@ -592,7 +592,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
// a secure cookie then overwriting it from a non-secure source should fail.
EXPECT_TRUE(this->SetCanonicalCookie(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"E", "F", https_foo_host, "/", base::Time(), base::Time(),
base::Time(), true /* secure */, false /* httponly */,
CookieSameSite::NO_RESTRICTION, COOKIE_PRIORITY_DEFAULT,
......@@ -601,7 +601,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
EXPECT_TRUE(this->SetCanonicalCookieReturnAccessResult(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"E", "F", http_foo_host, "/", base::Time(),
base::Time(), base::Time(), true /* secure */,
false /* httponly */, CookieSameSite::NO_RESTRICTION,
......@@ -615,7 +615,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
// httponly cookie.
EXPECT_TRUE(this->SetCanonicalCookieReturnAccessResult(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"G", "H", http_foo_host, "/unique", base::Time(),
base::Time(), base::Time(), false /* secure */,
true /* httponly */, CookieSameSite::LAX_MODE,
......@@ -642,7 +642,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
// an httponly cookie.
EXPECT_TRUE(this->SetCanonicalCookie(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"G", "H", http_foo_host, "/unique", base::Time(), base::Time(),
base::Time(), false /* secure */, true /* httponly */,
CookieSameSite::LAX_MODE, COOKIE_PRIORITY_DEFAULT,
......@@ -651,7 +651,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
EXPECT_TRUE(this->SetCanonicalCookieReturnAccessResult(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"G", "H", http_foo_host, "/unique", base::Time(),
base::Time(), base::Time(), false /* secure */,
true /* httponly */, CookieSameSite::LAX_MODE,
......@@ -663,7 +663,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
// Leave store in same state as if the above tests had been run.
EXPECT_TRUE(this->SetCanonicalCookie(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"G", "H", http_foo_host, "/unique", base::Time(), base::Time(),
base::Time(), false /* secure */, true /* httponly */,
CookieSameSite::LAX_MODE, COOKIE_PRIORITY_DEFAULT,
......@@ -742,28 +742,28 @@ TYPED_TEST_P(CookieStoreTest, SecureEnforcement) {
// but the other combinations work.
EXPECT_FALSE(this->SetCanonicalCookie(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"A", "B", http_domain, "/", base::Time::Now(), base::Time(),
base::Time(), true, false, CookieSameSite::STRICT_MODE,
COOKIE_PRIORITY_DEFAULT, false /* same_party */),
http_url, true /*modify_httponly*/));
EXPECT_TRUE(this->SetCanonicalCookie(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"A", "B", http_domain, "/", base::Time::Now(), base::Time(),
base::Time(), true, false, CookieSameSite::STRICT_MODE,
COOKIE_PRIORITY_DEFAULT, false /* same_party */),
https_url, true /*modify_httponly*/));
EXPECT_TRUE(this->SetCanonicalCookie(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"A", "B", http_domain, "/", base::Time::Now(), base::Time(),
base::Time(), false, false, CookieSameSite::STRICT_MODE,
COOKIE_PRIORITY_DEFAULT, false /* same_party */),
https_url, true /*modify_httponly*/));
EXPECT_TRUE(this->SetCanonicalCookie(
cs,
std::make_unique<CanonicalCookie>(
CanonicalCookie::CreateUnsafeCookieForTesting(
"A", "B", http_domain, "/", base::Time::Now(), base::Time(),
base::Time(), false, false, CookieSameSite::STRICT_MODE,
COOKIE_PRIORITY_DEFAULT, false /* same_party */),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment