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

Side by Side Diff: chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api_unittest.cc

Issue 2715823004: Add FingerprintUnlock KeyedService for each profile (Closed)
Patch Set: rebase Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 // This file tests the chromeos.quickUnlockPrivate extension API. 5 // This file tests the chromeos.quickUnlockPrivate extension API.
6 6
7 #include "chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_p rivate_api.h" 7 #include "chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_p rivate_api.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h" 13 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
14 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage_factory.h" 14 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
15 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h" 15 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
16 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 16 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
18 #include "chrome/browser/extensions/extension_api_unittest.h" 18 #include "chrome/browser/extensions/extension_api_unittest.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chromeos/login/auth/fake_extended_authenticator.h" 20 #include "chromeos/login/auth/fake_extended_authenticator.h"
21 #include "extensions/browser/api_test_utils.h" 21 #include "extensions/browser/api_test_utils.h"
22 #include "extensions/browser/extension_function_dispatcher.h" 22 #include "extensions/browser/extension_function_dispatcher.h"
23 23
24 using namespace extensions; 24 using namespace extensions;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 FailIfModesChanged(); 347 FailIfModesChanged();
348 EXPECT_TRUE(SetModes( 348 EXPECT_TRUE(SetModes(
349 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {"222222"})); 349 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {"222222"}));
350 EXPECT_TRUE(SetModes( 350 EXPECT_TRUE(SetModes(
351 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {""})); 351 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {""}));
352 } 352 }
353 353
354 // Ensures that quick unlock can be enabled and disabled by checking the result 354 // Ensures that quick unlock can be enabled and disabled by checking the result
355 // of quickUnlockPrivate.GetActiveModes and PinStorage::IsPinSet. 355 // of quickUnlockPrivate.GetActiveModes and PinStorage::IsPinSet.
356 TEST_F(QuickUnlockPrivateUnitTest, SetModesAndGetActiveModes) { 356 TEST_F(QuickUnlockPrivateUnitTest, SetModesAndGetActiveModes) {
357 quick_unlock::PinStorage* pin_storage = 357 quick_unlock::QuickUnlockStorage* quick_unlock_storage =
358 quick_unlock::PinStorageFactory::GetForProfile(profile()); 358 quick_unlock::QuickUnlockFactory::GetForProfile(profile());
359 359
360 // Update mode to PIN raises an event and updates GetActiveModes. 360 // Update mode to PIN raises an event and updates GetActiveModes.
361 ExpectModesChanged( 361 ExpectModesChanged(
362 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}); 362 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN});
363 EXPECT_TRUE(SetModes( 363 EXPECT_TRUE(SetModes(
364 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {"111111"})); 364 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {"111111"}));
365 EXPECT_EQ(GetActiveModes(), 365 EXPECT_EQ(GetActiveModes(),
366 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}); 366 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN});
367 EXPECT_TRUE(pin_storage->IsPinSet()); 367 EXPECT_TRUE(quick_unlock_storage->pin_storage()->IsPinSet());
368 368
369 // SetModes can be used to turn off a quick unlock mode. 369 // SetModes can be used to turn off a quick unlock mode.
370 ExpectModesChanged(QuickUnlockModeList{}); 370 ExpectModesChanged(QuickUnlockModeList{});
371 EXPECT_TRUE(SetModes(QuickUnlockModeList{}, CredentialList{})); 371 EXPECT_TRUE(SetModes(QuickUnlockModeList{}, CredentialList{}));
372 EXPECT_EQ(GetActiveModes(), QuickUnlockModeList{}); 372 EXPECT_EQ(GetActiveModes(), QuickUnlockModeList{});
373 EXPECT_FALSE(pin_storage->IsPinSet()); 373 EXPECT_FALSE(quick_unlock_storage->pin_storage()->IsPinSet());
374 } 374 }
375 375
376 // Verifies that enabling PIN quick unlock actually talks to the PIN subsystem. 376 // Verifies that enabling PIN quick unlock actually talks to the PIN subsystem.
377 TEST_F(QuickUnlockPrivateUnitTest, VerifyAuthenticationAgainstPIN) { 377 TEST_F(QuickUnlockPrivateUnitTest, VerifyAuthenticationAgainstPIN) {
378 quick_unlock::PinStorage* pin_storage = 378 quick_unlock::QuickUnlockStorage* quick_unlock_storage =
379 quick_unlock::PinStorageFactory::GetForProfile(profile()); 379 quick_unlock::QuickUnlockFactory::GetForProfile(profile());
380 380
381 EXPECT_TRUE(SetModes(QuickUnlockModeList{}, CredentialList{})); 381 EXPECT_TRUE(SetModes(QuickUnlockModeList{}, CredentialList{}));
382 EXPECT_FALSE(pin_storage->IsPinSet()); 382 EXPECT_FALSE(quick_unlock_storage->pin_storage()->IsPinSet());
383 383
384 EXPECT_TRUE(SetModes( 384 EXPECT_TRUE(SetModes(
385 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {"111111"})); 385 QuickUnlockModeList{QuickUnlockMode::QUICK_UNLOCK_MODE_PIN}, {"111111"}));
386 EXPECT_TRUE(pin_storage->IsPinSet()); 386 EXPECT_TRUE(quick_unlock_storage->pin_storage()->IsPinSet());
387 387
388 pin_storage->MarkStrongAuth(); 388 quick_unlock_storage->MarkStrongAuth();
389 pin_storage->ResetUnlockAttemptCount(); 389 quick_unlock_storage->pin_storage()->ResetUnlockAttemptCount();
390 EXPECT_TRUE(pin_storage->TryAuthenticatePin("111111")); 390 EXPECT_TRUE(quick_unlock_storage->TryAuthenticatePin("111111"));
391 EXPECT_FALSE(pin_storage->TryAuthenticatePin("000000")); 391 EXPECT_FALSE(quick_unlock_storage->TryAuthenticatePin("000000"));
392 } 392 }
393 393
394 // Verifies that the number of modes and the number of passwords given must be 394 // Verifies that the number of modes and the number of passwords given must be
395 // the same. 395 // the same.
396 TEST_F(QuickUnlockPrivateUnitTest, ThrowErrorOnMismatchedParameterCount) { 396 TEST_F(QuickUnlockPrivateUnitTest, ThrowErrorOnMismatchedParameterCount) {
397 EXPECT_FALSE(SetModesWithError("[\"valid\", [\"PIN\"], []]").empty()); 397 EXPECT_FALSE(SetModesWithError("[\"valid\", [\"PIN\"], []]").empty());
398 EXPECT_FALSE(SetModesWithError("[\"valid\", [], [\"11\"]]").empty()); 398 EXPECT_FALSE(SetModesWithError("[\"valid\", [], [\"11\"]]").empty());
399 } 399 }
400 400
401 // Validates PIN error checking in conjuction with policy-related prefs. 401 // Validates PIN error checking in conjuction with policy-related prefs.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // length pref. 485 // length pref.
486 pref_service->SetInteger(prefs::kPinUnlockMaximumLength, 4); 486 pref_service->SetInteger(prefs::kPinUnlockMaximumLength, 4);
487 CheckGetCredentialRequirements(6, 6); 487 CheckGetCredentialRequirements(6, 6);
488 488
489 // Verify that the values received from policy are sanitized. 489 // Verify that the values received from policy are sanitized.
490 pref_service->SetInteger(prefs::kPinUnlockMinimumLength, -3); 490 pref_service->SetInteger(prefs::kPinUnlockMinimumLength, -3);
491 pref_service->SetInteger(prefs::kPinUnlockMaximumLength, -3); 491 pref_service->SetInteger(prefs::kPinUnlockMaximumLength, -3);
492 CheckGetCredentialRequirements(1, 0); 492 CheckGetCredentialRequirements(1, 0);
493 } 493 }
494 } // namespace chromeos 494 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698