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

Side by Side Diff: chrome/browser/chromeos/login/signin/device_id_browsertest.cc

Issue 2208583006: UMA for pin unlock success/failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed failing test. Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 FakeGaia::MergeSessionParams params; 106 FakeGaia::MergeSessionParams params;
107 params.email = user_id; 107 params.email = user_id;
108 params.refresh_token = refresh_token; 108 params.refresh_token = refresh_token;
109 fake_gaia_->UpdateMergeSessionParams(params); 109 fake_gaia_->UpdateMergeSessionParams(params);
110 fake_gaia_->MapEmailToGaiaId(user_id, gaia_id); 110 fake_gaia_->MapEmailToGaiaId(user_id, gaia_id);
111 111
112 GetLoginDisplay()->ShowSigninScreenForCreds(user_id, password); 112 GetLoginDisplay()->ShowSigninScreenForCreds(user_id, password);
113 WaitForSessionStart(); 113 WaitForSessionStart();
114 } 114 }
115 115
116 void SignInOffline(const std::string& user_id, const std::string& password) { 116 void SignInOffline(const std::string& user_id,
117 const std::string& password,
118 bool using_pin) {
jdufault 2016/08/19 22:03:42 If this takes a param it should pass it using the
sammiequon 2016/08/22 17:15:31 Done.
117 WaitForSigninScreen(); 119 WaitForSigninScreen();
118 120
119 JS().ExecuteAsync( 121 JS().ExecuteAsync(base::StringPrintf(
120 base::StringPrintf("chrome.send('authenticateUser', ['%s', '%s'])", 122 "chrome.send('authenticateUser', ['%s', '%s', false])", user_id.c_str(),
121 user_id.c_str(), password.c_str())); 123 password.c_str()));
122 WaitForSessionStart(); 124 WaitForSessionStart();
123 } 125 }
124 126
125 void RemoveUser(const AccountId& account_id) { 127 void RemoveUser(const AccountId& account_id) {
126 user_manager::UserManager::Get()->RemoveUser(account_id, this); 128 user_manager::UserManager::Get()->RemoveUser(account_id, this);
127 user_removal_loop_.Run(); 129 user_removal_loop_.Run();
128 } 130 }
129 131
130 private: 132 private:
131 // user_manager::RemoveUserDelegate: 133 // user_manager::RemoveUserDelegate:
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 CHECK_EQ(device_id, GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail))); 198 CHECK_EQ(device_id, GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail)));
197 } 199 }
198 200
199 // Authenticate the first user offline and verify that device ID remains 201 // Authenticate the first user offline and verify that device ID remains
200 // the same. 202 // the same.
201 IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_PRE_NewUsers) { 203 IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_PRE_NewUsers) {
202 const std::string device_id = 204 const std::string device_id =
203 GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail)); 205 GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail));
204 EXPECT_FALSE(device_id.empty()); 206 EXPECT_FALSE(device_id.empty());
205 207
206 SignInOffline(kFakeUserEmail, kFakeUserPassword); 208 SignInOffline(kFakeUserEmail, kFakeUserPassword, false);
207 CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kFakeUserEmail), 209 CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kFakeUserEmail),
208 kRefreshToken2); 210 kRefreshToken2);
209 211
210 // Verify that device ID remained the same after offline auth. 212 // Verify that device ID remained the same after offline auth.
211 CHECK_EQ(device_id, GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail))); 213 CHECK_EQ(device_id, GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail)));
212 } 214 }
213 215
214 // Add the second user. 216 // Add the second user.
215 IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_NewUsers) { 217 IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_PRE_NewUsers) {
216 WaitForSigninScreen(); 218 WaitForSigninScreen();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Can't use SetKnownUserDeviceId here, because it forbids changing a device 256 // Can't use SetKnownUserDeviceId here, because it forbids changing a device
255 // ID. 257 // ID.
256 user_manager::known_user::SetStringPref( 258 user_manager::known_user::SetStringPref(
257 AccountId::FromUserEmail(kFakeUserEmail), "device_id", std::string()); 259 AccountId::FromUserEmail(kFakeUserEmail), "device_id", std::string());
258 } 260 }
259 261
260 // Tests that after the first sign in the device ID has been moved to the Local 262 // Tests that after the first sign in the device ID has been moved to the Local
261 // state. 263 // state.
262 IN_PROC_BROWSER_TEST_F(DeviceIDTest, Migration) { 264 IN_PROC_BROWSER_TEST_F(DeviceIDTest, Migration) {
263 EXPECT_TRUE(GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail)).empty()); 265 EXPECT_TRUE(GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail)).empty());
264 SignInOffline(kFakeUserEmail, kFakeUserPassword); 266 SignInOffline(kFakeUserEmail, kFakeUserPassword, false);
265 CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kFakeUserEmail), 267 CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kFakeUserEmail),
266 kRefreshToken1); 268 kRefreshToken1);
267 } 269 }
268 270
269 // Set up a user that doesn't have a device ID. 271 // Set up a user that doesn't have a device ID.
270 IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_LegacyUsers) { 272 IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_LegacyUsers) {
271 SignInOnline(kFakeUserEmail, kFakeUserPassword, kRefreshToken1, 273 SignInOnline(kFakeUserEmail, kFakeUserPassword, kRefreshToken1,
272 kFakeUserGaiaId); 274 kFakeUserGaiaId);
273 275
274 PrefService* prefs = 276 PrefService* prefs =
275 ProfileHelper::Get() 277 ProfileHelper::Get()
276 ->GetProfileByUser(user_manager::UserManager::Get()->GetActiveUser()) 278 ->GetProfileByUser(user_manager::UserManager::Get()->GetActiveUser())
277 ->GetPrefs(); 279 ->GetPrefs();
278 EXPECT_TRUE( 280 EXPECT_TRUE(
279 prefs->GetString(prefs::kGoogleServicesSigninScopedDeviceId).empty()); 281 prefs->GetString(prefs::kGoogleServicesSigninScopedDeviceId).empty());
280 282
281 // Can't use SetKnownUserDeviceId here, because it forbids changing a device 283 // Can't use SetKnownUserDeviceId here, because it forbids changing a device
282 // ID. 284 // ID.
283 user_manager::known_user::SetStringPref( 285 user_manager::known_user::SetStringPref(
284 AccountId::FromUserEmail(kFakeUserEmail), "device_id", std::string()); 286 AccountId::FromUserEmail(kFakeUserEmail), "device_id", std::string());
285 } 287 }
286 288
287 // Tests that device ID has been generated after the first sign in. 289 // Tests that device ID has been generated after the first sign in.
288 IN_PROC_BROWSER_TEST_F(DeviceIDTest, LegacyUsers) { 290 IN_PROC_BROWSER_TEST_F(DeviceIDTest, LegacyUsers) {
289 EXPECT_TRUE(GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail)).empty()); 291 EXPECT_TRUE(GetDeviceId(AccountId::FromUserEmail(kFakeUserEmail)).empty());
290 SignInOffline(kFakeUserEmail, kFakeUserPassword); 292 SignInOffline(kFakeUserEmail, kFakeUserPassword, false);
291 // Last param |auth_code| is empty, because we don't pass a device ID to GAIA 293 // Last param |auth_code| is empty, because we don't pass a device ID to GAIA
292 // in this case. 294 // in this case.
293 CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kFakeUserEmail), 295 CheckDeviceIDIsConsistent(AccountId::FromUserEmail(kFakeUserEmail),
294 std::string()); 296 std::string());
295 } 297 }
296 298
297 } // namespace chromeos 299 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/lock/screen_locker.cc ('k') | chrome/browser/resources/chromeos/login/login_shared.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698