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

Unified Diff: chrome/browser/chromeos/login/profile_auth_data_unittest.cc

Issue 538543003: Fix copying of SAML IdP cookies on subsequent logins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tests. Created 6 years, 3 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: chrome/browser/chromeos/login/profile_auth_data_unittest.cc
diff --git a/chrome/browser/chromeos/login/profile_auth_data_unittest.cc b/chrome/browser/chromeos/login/profile_auth_data_unittest.cc
index 272d6036780643f7e67c0ee03fd3ecea7966b171..1726bb97755a8fdbe8a6b65e8cae4c7e14bdc064 100644
--- a/chrome/browser/chromeos/login/profile_auth_data_unittest.cc
+++ b/chrome/browser/chromeos/login/profile_auth_data_unittest.cc
@@ -47,8 +47,8 @@ const char kSAMLIdPCookieURL[] = "http://example.com/";
const char kCookieName[] = "cookie";
const char kCookieValue1[] = "value 1";
const char kCookieValue2[] = "value 2";
-const char kGAIACookieDomain[] = ".google.com";
-const char kSAMLIdPCookieDomain[] = ".example.com";
+const char kGAIACookieDomain[] = "google.com";
+const char kSAMLIdPCookieDomain[] = "example.com";
const char kChannelIDServerIdentifier[] = "server";
const char kChannelIDPrivateKey1[] = "private key 1";
@@ -91,7 +91,7 @@ class ProfileAuthDataTest : public testing::Test {
net::CookieMonster* GetCookies(content::BrowserContext* browser_context);
net::ChannelIDStore* GetChannelIDs(content::BrowserContext* browser_context);
- void QuitLoop(bool ignored);
+ void QuitLoop(const net::CookieList& ignored);
void StoreCookieListAndQuitLoop(const net::CookieList& cookie_list);
void StoreChannelIDListAndQuitLoop(
const net::ChannelIDStore::ChannelIDList& channel_id_list);
@@ -178,13 +178,15 @@ void ProfileAuthDataTest::VerifyUserCookies(
net::CookieList user_cookies = GetUserCookies();
ASSERT_EQ(2u, user_cookies.size());
net::CanonicalCookie* cookie = &user_cookies[0];
- EXPECT_EQ(kGAIACookieURL, cookie->Source());
- EXPECT_EQ(kCookieName, cookie->Name());
- EXPECT_EQ(expected_gaia_cookie_value, cookie->Value());
- cookie = &user_cookies[1];
EXPECT_EQ(kSAMLIdPCookieURL, cookie->Source());
EXPECT_EQ(kCookieName, cookie->Name());
EXPECT_EQ(expected_saml_idp_cookie_value, cookie->Value());
+ EXPECT_EQ(kSAMLIdPCookieDomain, cookie->Domain());
+ cookie = &user_cookies[1];
+ EXPECT_EQ(kGAIACookieURL, cookie->Source());
+ EXPECT_EQ(kCookieName, cookie->Name());
+ EXPECT_EQ(expected_gaia_cookie_value, cookie->Value());
+ EXPECT_EQ(kGAIACookieDomain, cookie->Domain());
}
void ProfileAuthDataTest::VerifyUserChannelID(
@@ -214,33 +216,37 @@ void ProfileAuthDataTest::PopulateBrowserContext(
std::string());
net::CookieMonster* cookies = GetCookies(browser_context);
+ // Ensure |cookies| is fully initialized.
run_loop_.reset(new base::RunLoop);
- cookies->SetCookieWithDetailsAsync(
- GURL(kGAIACookieURL),
- kCookieName,
- cookie_value,
- kGAIACookieDomain,
- std::string(),
- base::Time(),
- true,
- false,
- net::COOKIE_PRIORITY_DEFAULT,
- base::Bind(&ProfileAuthDataTest::QuitLoop, base::Unretained(this)));
- run_loop_->Run();
- run_loop_.reset(new base::RunLoop);
- cookies->SetCookieWithDetailsAsync(
- GURL(kSAMLIdPCookieURL),
- kCookieName,
- cookie_value,
- kSAMLIdPCookieDomain,
- std::string(),
- base::Time(),
- true,
- false,
- net::COOKIE_PRIORITY_DEFAULT,
- base::Bind(&ProfileAuthDataTest::QuitLoop, base::Unretained(this)));
+ cookies->GetAllCookiesAsync(base::Bind(&ProfileAuthDataTest::QuitLoop,
+ base::Unretained(this)));
run_loop_->Run();
+ net::CookieList cookie_list;
+ cookie_list.push_back(net::CanonicalCookie(GURL(kGAIACookieURL),
+ kCookieName,
+ cookie_value,
+ kGAIACookieDomain,
+ std::string(),
+ base::Time(),
+ base::Time(),
+ base::Time(),
+ true,
+ false,
+ net::COOKIE_PRIORITY_DEFAULT));
+ cookie_list.push_back(net::CanonicalCookie(GURL(kSAMLIdPCookieURL),
+ kCookieName,
+ cookie_value,
+ kSAMLIdPCookieDomain,
+ std::string(),
+ base::Time(),
+ base::Time(),
+ base::Time(),
+ true,
+ false,
+ net::COOKIE_PRIORITY_DEFAULT));
+ cookies->ImportCookies(cookie_list);
+
GetChannelIDs(browser_context)->SetChannelID(kChannelIDServerIdentifier,
base::Time(),
base::Time(),
@@ -270,7 +276,7 @@ net::ChannelIDStore* ProfileAuthDataTest::GetChannelIDs(
GetChannelIDStore();
}
-void ProfileAuthDataTest::QuitLoop(bool ignored) {
+void ProfileAuthDataTest::QuitLoop(const net::CookieList& ignored) {
run_loop_->Quit();
}

Powered by Google App Engine
This is Rietveld 408576698