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

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

Issue 7562010: [ChromeOS] Fix login wrong password handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync, fix broken tests and add 3 new Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
diff --git a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
index 67462f436b1bd55f61784b734422f97afdc83b37..371c7a952cbdff52b7a62fd55e870fd8f1c7086f 100644
--- a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
+++ b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
@@ -45,6 +45,7 @@ using ::testing::SetArgumentPointee;
using ::testing::_;
namespace chromeos {
+
class ResolveChecker : public base::ThreadTestHelper {
public:
ResolveChecker(TestAttemptState* state,
@@ -69,6 +70,14 @@ class ResolveChecker : public base::ThreadTestHelper {
ParallelAuthenticator::AuthState expected_;
};
+class TestOnlineAttempt : public OnlineAttempt {
+ public:
+ TestOnlineAttempt(AuthAttemptState* state,
+ AuthAttemptStateResolver* resolver)
+ : OnlineAttempt(false, state, resolver) {
+ }
+};
+
class ParallelAuthenticatorTest : public ::testing::Test {
public:
ParallelAuthenticatorTest()
@@ -213,6 +222,10 @@ class ParallelAuthenticatorTest : public ::testing::Test {
auth->set_attempt_state(state);
}
+ void FakeOnlineAttempt() {
+ auth_->set_online_attempt(new TestOnlineAttempt(state_.get(), auth_.get()));
+ }
+
MessageLoop message_loop_;
BrowserThread ui_thread_;
BrowserThread file_thread_;
@@ -300,6 +313,9 @@ TEST_F(ParallelAuthenticatorTest, ResolveNothingDone) {
}
TEST_F(ParallelAuthenticatorTest, ResolvePossiblePwChange) {
+ // Set a fake online attempt so that we return intermediate cryptohome state.
+ FakeOnlineAttempt();
+
// Set up state as though a cryptohome mount attempt has occurred
// and been rejected.
state_->PresetCryptohomeStatus(false,
@@ -311,6 +327,37 @@ TEST_F(ParallelAuthenticatorTest, ResolvePossiblePwChange) {
EXPECT_TRUE(checker->Run());
}
+TEST_F(ParallelAuthenticatorTest, ResolvePossiblePwChangeToFailedMount) {
+ // Set up state as though a cryptohome mount attempt has occurred
+ // and been rejected.
+ state_->PresetCryptohomeStatus(false,
+ chromeos::kCryptohomeMountErrorKeyFailure);
+
+ // When there is no online attempt and online results, POSSIBLE_PW_CHANGE
+ // will be resolved to FAILED_MOUNT.
+ scoped_refptr<ResolveChecker> checker(
+ new ResolveChecker(state_.release(),
+ auth_.get(),
+ ParallelAuthenticator::FAILED_MOUNT));
+ EXPECT_TRUE(checker->Run());
+}
+
+TEST_F(ParallelAuthenticatorTest, ResolveNeedOldPw) {
+ // Set up state as though a cryptohome mount attempt has occurred
+ // and been rejected because of unmatched key; additionally,
+ // an online auth attempt has completed successfully.
+ state_->PresetCryptohomeStatus(
+ false,
+ chromeos::kCryptohomeMountErrorKeyFailure);
+ state_->PresetOnlineLoginStatus(GaiaAuthConsumer::ClientLoginResult(),
+ LoginFailure::None());
+ scoped_refptr<ResolveChecker> checker(
+ new ResolveChecker(state_.release(),
+ auth_.get(),
+ ParallelAuthenticator::NEED_OLD_PW));
+ EXPECT_TRUE(checker->Run());
+}
+
TEST_F(ParallelAuthenticatorTest, DriveFailedMount) {
FailOnLoginSuccess();
ExpectLoginFailure(LoginFailure(LoginFailure::COULD_NOT_MOUNT_CRYPTOHOME));
@@ -396,7 +443,7 @@ TEST_F(ParallelAuthenticatorTest, DriveRequestOldPassword) {
ExpectPasswordChange();
state_->PresetCryptohomeStatus(false,
- chromeos::kCryptohomeMountErrorKeyFailure);
+ chromeos::kCryptohomeMountErrorKeyFailure);
state_->PresetOnlineLoginStatus(result_, LoginFailure::None());
SetAttemptState(auth_, state_.release());
@@ -447,6 +494,9 @@ TEST_F(ParallelAuthenticatorTest, DriveDataRecoverButFail) {
}
TEST_F(ParallelAuthenticatorTest, ResolveNoMount) {
+ // Set a fake online attempt so that we return intermediate cryptohome state.
+ FakeOnlineAttempt();
+
// Set up state as though a cryptohome mount attempt has occurred
// and been rejected because the user doesn't exist.
state_->PresetCryptohomeStatus(
@@ -459,6 +509,22 @@ TEST_F(ParallelAuthenticatorTest, ResolveNoMount) {
EXPECT_TRUE(checker->Run());
}
+TEST_F(ParallelAuthenticatorTest, ResolveNoMountToFailedMount) {
+ // Set up state as though a cryptohome mount attempt has occurred
+ // and been rejected because the user doesn't exist.
+ state_->PresetCryptohomeStatus(
+ false,
+ chromeos::kCryptohomeMountErrorUserDoesNotExist);
+
+ // When there is no online attempt and online results, NO_MOUNT will be
+ // resolved to FAILED_MOUNT.
+ scoped_refptr<ResolveChecker> checker(
+ new ResolveChecker(state_.release(),
+ auth_.get(),
+ ParallelAuthenticator::FAILED_MOUNT));
+ EXPECT_TRUE(checker->Run());
+}
+
TEST_F(ParallelAuthenticatorTest, ResolveCreateNew) {
// Set up state as though a cryptohome mount attempt has occurred
// and been rejected because the user doesn't exist; additionally,
« no previous file with comments | « chrome/browser/chromeos/login/parallel_authenticator.cc ('k') | chrome/browser/resources/chromeos/login/oobe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698