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

Side by Side Diff: chrome/browser/chromeos/login/profile_auth_data_unittest.cc

Issue 2103863003: Make CanonicalCookie::Source() private. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@source
Patch Set: Merge Created 4 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/chromeos/login/profile_auth_data.h" 5 #include "chrome/browser/chromeos/login/profile_auth_data.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 const char kProxyAuthPassword1[] = "password 1"; 45 const char kProxyAuthPassword1[] = "password 1";
46 const char kProxyAuthPassword2[] = "password 2"; 46 const char kProxyAuthPassword2[] = "password 2";
47 47
48 const char kGAIACookieURL[] = "http://google.com/"; 48 const char kGAIACookieURL[] = "http://google.com/";
49 const char kSAMLIdPCookieURL[] = "http://example.com/"; 49 const char kSAMLIdPCookieURL[] = "http://example.com/";
50 const char kCookieName[] = "cookie"; 50 const char kCookieName[] = "cookie";
51 const char kCookieValue1[] = "value 1"; 51 const char kCookieValue1[] = "value 1";
52 const char kCookieValue2[] = "value 2"; 52 const char kCookieValue2[] = "value 2";
53 const char kGAIACookieDomain[] = "google.com"; 53 const char kGAIACookieDomain[] = "google.com";
54 const char kSAMLIdPCookieDomain[] = "example.com"; 54 const char kSAMLIdPCookieDomain[] = "example.com";
55 const char kSAMLIdPCookieDomainWithWildcard[] = ".example.com";
55 56
56 const char kChannelIDServerIdentifier[] = "server"; 57 const char kChannelIDServerIdentifier[] = "server";
57 58
58 } // namespace 59 } // namespace
59 60
60 class ProfileAuthDataTest : public testing::Test { 61 class ProfileAuthDataTest : public testing::Test {
61 public: 62 public:
62 // testing::Test: 63 // testing::Test:
63 void SetUp() override; 64 void SetUp() override;
64 65
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 net::HttpAuth::AUTH_SCHEME_BASIC); 168 net::HttpAuth::AUTH_SCHEME_BASIC);
168 ASSERT_TRUE(entry); 169 ASSERT_TRUE(entry);
169 EXPECT_EQ(base::ASCIIToUTF16(kProxyAuthPassword1), 170 EXPECT_EQ(base::ASCIIToUTF16(kProxyAuthPassword1),
170 entry->credentials().password()); 171 entry->credentials().password());
171 } 172 }
172 173
173 void ProfileAuthDataTest::VerifyUserCookies( 174 void ProfileAuthDataTest::VerifyUserCookies(
174 const std::string& expected_gaia_cookie_value, 175 const std::string& expected_gaia_cookie_value,
175 const std::string& expected_saml_idp_cookie_value) { 176 const std::string& expected_saml_idp_cookie_value) {
176 net::CookieList user_cookies = GetUserCookies(); 177 net::CookieList user_cookies = GetUserCookies();
177 ASSERT_EQ(2u, user_cookies.size()); 178 ASSERT_EQ(3u, user_cookies.size());
179
180 // Cookies are returned chronoligically, in the order they were set.
178 net::CanonicalCookie* cookie = &user_cookies[0]; 181 net::CanonicalCookie* cookie = &user_cookies[0];
179 // kSAMLIdPCookieURL is returned first because it was created first, so has 182 EXPECT_EQ(kCookieName, cookie->Name());
180 // the earliest creation date. 183 EXPECT_EQ(expected_saml_idp_cookie_value, cookie->Value());
181 EXPECT_EQ(GURL(kSAMLIdPCookieURL), cookie->Source()); 184 EXPECT_EQ(kSAMLIdPCookieDomainWithWildcard, cookie->Domain());
185
186 cookie = &user_cookies[1];
182 EXPECT_EQ(kCookieName, cookie->Name()); 187 EXPECT_EQ(kCookieName, cookie->Name());
183 EXPECT_EQ(expected_saml_idp_cookie_value, cookie->Value()); 188 EXPECT_EQ(expected_saml_idp_cookie_value, cookie->Value());
184 EXPECT_EQ(kSAMLIdPCookieDomain, cookie->Domain()); 189 EXPECT_EQ(kSAMLIdPCookieDomain, cookie->Domain());
185 cookie = &user_cookies[1]; 190
186 EXPECT_EQ(GURL(kGAIACookieURL), cookie->Source()); 191 cookie = &user_cookies[2];
187 EXPECT_EQ(kCookieName, cookie->Name()); 192 EXPECT_EQ(kCookieName, cookie->Name());
188 EXPECT_EQ(expected_gaia_cookie_value, cookie->Value()); 193 EXPECT_EQ(expected_gaia_cookie_value, cookie->Value());
189 EXPECT_EQ(kGAIACookieDomain, cookie->Domain()); 194 EXPECT_EQ(kGAIACookieDomain, cookie->Domain());
190 } 195 }
191 196
192 void ProfileAuthDataTest::VerifyUserChannelID( 197 void ProfileAuthDataTest::VerifyUserChannelID(
193 crypto::ECPrivateKey* expected_key) { 198 crypto::ECPrivateKey* expected_key) {
194 net::ChannelIDStore::ChannelIDList user_channel_ids = GetUserChannelIDs(); 199 net::ChannelIDStore::ChannelIDList user_channel_ids = GetUserChannelIDs();
195 ASSERT_EQ(1u, user_channel_ids.size()); 200 ASSERT_EQ(1u, user_channel_ids.size());
196 net::ChannelIDStore::ChannelID* channel_id = &user_channel_ids.front(); 201 net::ChannelIDStore::ChannelID* channel_id = &user_channel_ids.front();
(...skipping 16 matching lines...) Expand all
213 std::string()); 218 std::string());
214 219
215 net::CookieStore* cookies = GetCookies(browser_context); 220 net::CookieStore* cookies = GetCookies(browser_context);
216 // Ensure |cookies| is fully initialized. 221 // Ensure |cookies| is fully initialized.
217 run_loop_.reset(new base::RunLoop); 222 run_loop_.reset(new base::RunLoop);
218 cookies->GetAllCookiesAsync(base::Bind(&ProfileAuthDataTest::QuitLoop, 223 cookies->GetAllCookiesAsync(base::Bind(&ProfileAuthDataTest::QuitLoop,
219 base::Unretained(this))); 224 base::Unretained(this)));
220 run_loop_->Run(); 225 run_loop_->Run();
221 226
222 cookies->SetCookieWithDetailsAsync( 227 cookies->SetCookieWithDetailsAsync(
228 GURL(kSAMLIdPCookieURL), kCookieName, cookie_value,
229 kSAMLIdPCookieDomainWithWildcard, std::string(), base::Time(),
230 base::Time(), base::Time(), true, false,
231 net::CookieSameSite::DEFAULT_MODE, false, net::COOKIE_PRIORITY_DEFAULT,
232 net::CookieStore::SetCookiesCallback());
233 cookies->SetCookieWithDetailsAsync(
223 GURL(kSAMLIdPCookieURL), kCookieName, cookie_value, std::string(), 234 GURL(kSAMLIdPCookieURL), kCookieName, cookie_value, std::string(),
224 std::string(), base::Time(), base::Time(), base::Time(), true, false, 235 std::string(), base::Time(), base::Time(), base::Time(), true, false,
225 net::CookieSameSite::DEFAULT_MODE, false, net::COOKIE_PRIORITY_DEFAULT, 236 net::CookieSameSite::DEFAULT_MODE, false, net::COOKIE_PRIORITY_DEFAULT,
226 net::CookieStore::SetCookiesCallback()); 237 net::CookieStore::SetCookiesCallback());
227 cookies->SetCookieWithDetailsAsync( 238 cookies->SetCookieWithDetailsAsync(
228 GURL(kGAIACookieURL), kCookieName, cookie_value, std::string(), 239 GURL(kGAIACookieURL), kCookieName, cookie_value, std::string(),
229 std::string(), base::Time(), base::Time(), base::Time(), true, false, 240 std::string(), base::Time(), base::Time(), base::Time(), true, false,
230 net::CookieSameSite::DEFAULT_MODE, false, net::COOKIE_PRIORITY_DEFAULT, 241 net::CookieSameSite::DEFAULT_MODE, false, net::COOKIE_PRIORITY_DEFAULT,
231 net::CookieStore::SetCookiesCallback()); 242 net::CookieStore::SetCookiesCallback());
232 243
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 PopulateUserBrowserContext(); 327 PopulateUserBrowserContext();
317 328
318 Transfer(false, true); 329 Transfer(false, true);
319 330
320 VerifyTransferredUserProxyAuthEntry(); 331 VerifyTransferredUserProxyAuthEntry();
321 VerifyUserCookies(kCookieValue2, kCookieValue1); 332 VerifyUserCookies(kCookieValue2, kCookieValue1);
322 VerifyUserChannelID(channel_id_key2_.get()); 333 VerifyUserChannelID(channel_id_key2_.get());
323 } 334 }
324 335
325 } // namespace chromeos 336 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/profile_auth_data.cc ('k') | ios/net/cookies/system_cookie_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698