Index: ash/login/lock_screen_controller_unittest.cc |
diff --git a/ash/login/lock_screen_controller_unittest.cc b/ash/login/lock_screen_controller_unittest.cc |
index cc3f8d45e43c2467b4a1d1703b27e42b957905d0..3e42c9ee679438c372efa3643aa090e7051d6d41 100644 |
--- a/ash/login/lock_screen_controller_unittest.cc |
+++ b/ash/login/lock_screen_controller_unittest.cc |
@@ -4,58 +4,38 @@ |
#include "ash/login/lock_screen_controller.h" |
+#include "ash/login/mock_lock_screen_client.h" |
#include "ash/shell.h" |
#include "ash/test/ash_test_base.h" |
#include "base/run_loop.h" |
-#include "chromeos/cryptohome/system_salt_getter.h" |
+ |
+using ::testing::_; |
namespace ash { |
namespace { |
- |
-class TestLockScreenClient : public mojom::LockScreenClient { |
- public: |
- TestLockScreenClient() : binding_(this) {} |
- ~TestLockScreenClient() override = default; |
- |
- mojom::LockScreenClientPtr CreateInterfacePtrAndBind() { |
- return binding_.CreateInterfacePtrAndBind(); |
- } |
- |
- // mojom::LockScreenClient: |
- void AuthenticateUser(const AccountId& account_id, |
- const std::string& password, |
- bool authenticated_by_pin) override { |
- ++autentication_requests_count_; |
- } |
- |
- int authentication_requests_count() const { |
- return autentication_requests_count_; |
- } |
- |
- private: |
- mojo::Binding<ash::mojom::LockScreenClient> binding_; |
- int autentication_requests_count_ = 0; |
- |
- DISALLOW_COPY_AND_ASSIGN(TestLockScreenClient); |
-}; |
- |
using LockScreenControllerTest = test::AshTestBase; |
- |
} // namespace |
TEST_F(LockScreenControllerTest, RequestAuthentication) { |
- LockScreenController* lock_screen_controller = |
- Shell::Get()->lock_screen_controller(); |
- TestLockScreenClient lock_screen_client; |
- lock_screen_controller->SetClient( |
- lock_screen_client.CreateInterfacePtrAndBind()); |
- EXPECT_EQ(0, lock_screen_client.authentication_requests_count()); |
+ LockScreenController* controller = Shell::Get()->lock_screen_controller(); |
+ std::unique_ptr<MockLockScreenClient> client = BindMockLockScreenClient(); |
AccountId id = AccountId::FromUserEmail("user1@test.com"); |
- lock_screen_controller->AuthenticateUser(id, std::string(), false); |
+ |
+ // We hardcode the hashed password. This is fine because the password hash |
+ // algorithm should never accidently change; if it does we will need to |
+ // have cryptohome migration code and one failing test isn't a problem. |
+ std::string password = "password"; |
+ std::string hashed_password = "40c7b00f3bccc7675ec5b732de4bfbe4"; |
+ EXPECT_NE(password, hashed_password); |
+ |
+ // Verify AuthenticateUser mojo call is run with the same account id, a |
+ // (hashed) password, and the correct PIN state. |
+ EXPECT_CALL(*client, AuthenticateUser(id, hashed_password, false)); |
+ controller->AuthenticateUser(id, password, false); |
+ |
base::RunLoop().RunUntilIdle(); |
- EXPECT_EQ(1, lock_screen_client.authentication_requests_count()); |
} |
} // namespace ash |