OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/chromeos/login/login_manager_test.h" | 12 #include "chrome/browser/chromeos/login/login_manager_test.h" |
13 #include "chrome/browser/chromeos/login/managed/managed_user_test_base.h" | |
14 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h
" | |
15 #include "chrome/browser/chromeos/login/startup_utils.h" | 13 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 14 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" |
| 15 #include "chrome/browser/chromeos/login/supervised/supervised_user_test_base.h" |
16 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 16 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
17 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 17 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
18 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 18 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
19 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | 19 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
20 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 20 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
21 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 21 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
22 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h" | 22 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h" |
23 #include "chrome/browser/supervised_user/supervised_user_registration_utility_st
ub.h" | 23 #include "chrome/browser/supervised_user/supervised_user_registration_utility_st
ub.h" |
24 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
.h" | 24 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
.h" |
25 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
_factory.h" | 25 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
_factory.h" |
26 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" | 26 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" |
27 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h" | 27 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h" |
28 #include "chromeos/cryptohome/mock_async_method_caller.h" | 28 #include "chromeos/cryptohome/mock_async_method_caller.h" |
29 #include "chromeos/cryptohome/mock_homedir_methods.h" | 29 #include "chromeos/cryptohome/mock_homedir_methods.h" |
30 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
31 #include "content/public/test/browser_test_utils.h" | 31 #include "content/public/test/browser_test_utils.h" |
32 #include "content/public/test/test_utils.h" | 32 #include "content/public/test/test_utils.h" |
33 #include "sync/api/attachments/attachment_service_proxy_for_test.h" | 33 #include "sync/api/attachments/attachment_service_proxy_for_test.h" |
34 #include "sync/api/fake_sync_change_processor.h" | 34 #include "sync/api/fake_sync_change_processor.h" |
35 #include "sync/api/sync_change.h" | 35 #include "sync/api/sync_change.h" |
36 #include "sync/api/sync_error_factory_mock.h" | 36 #include "sync/api/sync_error_factory_mock.h" |
37 #include "sync/protocol/sync.pb.h" | 37 #include "sync/protocol/sync.pb.h" |
38 | 38 |
39 using testing::_; | 39 using testing::_; |
40 using chromeos::ManagedUserTestBase; | 40 using chromeos::SupervisedUserTestBase; |
41 using chromeos::kTestSupervisedUserDisplayName; | 41 using chromeos::kTestSupervisedUserDisplayName; |
42 using chromeos::kTestManager; | 42 using chromeos::kTestManager; |
43 | 43 |
44 namespace chromeos { | 44 namespace chromeos { |
45 | 45 |
46 class SupervisedUserPasswordTest : public ManagedUserTestBase { | 46 class SupervisedUserPasswordTest : public SupervisedUserTestBase { |
47 public: | 47 public: |
48 SupervisedUserPasswordTest() : ManagedUserTestBase() {} | 48 SupervisedUserPasswordTest() : SupervisedUserTestBase() {} |
49 | 49 |
50 private: | 50 private: |
51 DISALLOW_COPY_AND_ASSIGN(SupervisedUserPasswordTest); | 51 DISALLOW_COPY_AND_ASSIGN(SupervisedUserPasswordTest); |
52 }; | 52 }; |
53 | 53 |
54 class SupervisedUserPasswordManagerTest : public ManagedUserTestBase { | 54 class SupervisedUserPasswordManagerTest : public SupervisedUserTestBase { |
55 public: | 55 public: |
56 SupervisedUserPasswordManagerTest() : ManagedUserTestBase() {} | 56 SupervisedUserPasswordManagerTest() : SupervisedUserTestBase() {} |
57 | 57 |
58 private: | 58 private: |
59 DISALLOW_COPY_AND_ASSIGN(SupervisedUserPasswordManagerTest); | 59 DISALLOW_COPY_AND_ASSIGN(SupervisedUserPasswordManagerTest); |
60 }; | 60 }; |
61 | 61 |
62 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | 62 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, |
63 DISABLED_PRE_PRE_PRE_PasswordChangeFromUserTest) { | 63 DISABLED_PRE_PRE_PRE_PasswordChangeFromUserTest) { |
64 PrepareUsers(); | 64 PrepareUsers(); |
65 } | 65 } |
66 | 66 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 StartFlowLoginAsManager(); | 116 StartFlowLoginAsManager(); |
117 FillNewUserData(kTestSupervisedUserDisplayName); | 117 FillNewUserData(kTestSupervisedUserDisplayName); |
118 StartUserCreation("managed-user-creation-next-button", | 118 StartUserCreation("managed-user-creation-next-button", |
119 kTestSupervisedUserDisplayName); | 119 kTestSupervisedUserDisplayName); |
120 } | 120 } |
121 | 121 |
122 // Manager signs in, gets sync notification about supervised user password | 122 // Manager signs in, gets sync notification about supervised user password |
123 // update, and performs migration. | 123 // update, and performs migration. |
124 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | 124 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, |
125 DISABLED_PRE_PasswordChangeFromManagerTest) { | 125 DISABLED_PRE_PasswordChangeFromManagerTest) { |
126 const User* managed_user = UserManager::Get()->GetUsers().at(0); | 126 const User* supervised_user = UserManager::Get()->GetUsers().at(0); |
127 | 127 |
128 SigninAsManager(1); | 128 SigninAsManager(1); |
129 | 129 |
130 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1); | 130 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1); |
131 | 131 |
132 std::string sync_id = | 132 std::string sync_id = |
133 UserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( | 133 UserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( |
134 managed_user->email()); | 134 supervised_user->email()); |
135 | 135 |
136 ::sync_pb::ManagedUserSpecifics managed_user_proto; | 136 ::sync_pb::ManagedUserSpecifics managed_user_proto; |
137 | 137 |
138 managed_user_proto.set_id(sync_id); | 138 managed_user_proto.set_id(sync_id); |
139 managed_user_proto.set_name(kTestSupervisedUserDisplayName); | 139 managed_user_proto.set_name(kTestSupervisedUserDisplayName); |
140 managed_user_proto.set_acknowledged(true); | 140 managed_user_proto.set_acknowledged(true); |
141 managed_user_proto.set_master_key("master key"); | 141 managed_user_proto.set_master_key("master key"); |
142 managed_user_proto.set_password_signature_key("signature_key"); | 142 managed_user_proto.set_password_signature_key("signature_key"); |
143 managed_user_proto.set_password_encryption_key("encryption_key"); | 143 managed_user_proto.set_password_encryption_key("encryption_key"); |
144 | 144 |
145 managed_users_adapter_->AddChange(managed_user_proto, false); | 145 supervised_users_adapter_->AddChange(managed_user_proto, false); |
146 content::RunAllPendingInMessageLoop(); | 146 content::RunAllPendingInMessageLoop(); |
147 | 147 |
148 base::DictionaryValue password; | 148 base::DictionaryValue password; |
149 password.SetIntegerWithoutPathExpansion( | 149 password.SetIntegerWithoutPathExpansion( |
150 kSchemaVersion, SupervisedUserAuthentication::SCHEMA_SALT_HASHED); | 150 kSchemaVersion, SupervisedUserAuthentication::SCHEMA_SALT_HASHED); |
151 password.SetIntegerWithoutPathExpansion(kPasswordRevision, 2); | 151 password.SetIntegerWithoutPathExpansion(kPasswordRevision, 2); |
152 | 152 |
153 password.SetStringWithoutPathExpansion(kPasswordSignature, "signature"); | 153 password.SetStringWithoutPathExpansion(kPasswordSignature, "signature"); |
154 password.SetStringWithoutPathExpansion(kEncryptedPassword, | 154 password.SetStringWithoutPathExpansion(kEncryptedPassword, |
155 "new-encrypted-password"); | 155 "new-encrypted-password"); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 shared_settings_adapter_->AddChange( | 205 shared_settings_adapter_->AddChange( |
206 sync_id, supervised_users::kChromeOSPasswordData, password, true, false); | 206 sync_id, supervised_users::kChromeOSPasswordData, password, true, false); |
207 content::RunAllPendingInMessageLoop(); | 207 content::RunAllPendingInMessageLoop(); |
208 } | 208 } |
209 | 209 |
210 // After that manager signs in, and also detects password change. Manager | 210 // After that manager signs in, and also detects password change. Manager |
211 // performs the migration. | 211 // performs the migration. |
212 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | 212 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, |
213 DISABLED_PRE_PasswordChangeUserAndManagerTest) { | 213 DISABLED_PRE_PasswordChangeUserAndManagerTest) { |
214 const User* managed_user = UserManager::Get()->GetUsers().at(0); | 214 const User* supervised_user = UserManager::Get()->GetUsers().at(0); |
215 | 215 |
216 SigninAsManager(1); | 216 SigninAsManager(1); |
217 | 217 |
218 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1); | 218 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1); |
219 | 219 |
220 std::string sync_id = | 220 std::string sync_id = |
221 UserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( | 221 UserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( |
222 managed_user->email()); | 222 supervised_user->email()); |
223 | 223 |
224 ::sync_pb::ManagedUserSpecifics managed_user_proto; | 224 ::sync_pb::ManagedUserSpecifics managed_user_proto; |
225 | 225 |
226 managed_user_proto.set_id(sync_id); | 226 managed_user_proto.set_id(sync_id); |
227 managed_user_proto.set_name(kTestSupervisedUserDisplayName); | 227 managed_user_proto.set_name(kTestSupervisedUserDisplayName); |
228 managed_user_proto.set_acknowledged(true); | 228 managed_user_proto.set_acknowledged(true); |
229 managed_user_proto.set_master_key("master key"); | 229 managed_user_proto.set_master_key("master key"); |
230 managed_user_proto.set_password_signature_key("signature_key"); | 230 managed_user_proto.set_password_signature_key("signature_key"); |
231 managed_user_proto.set_password_encryption_key("encryption_key"); | 231 managed_user_proto.set_password_encryption_key("encryption_key"); |
232 | 232 |
233 managed_users_adapter_->AddChange(managed_user_proto, false); | 233 supervised_users_adapter_->AddChange(managed_user_proto, false); |
234 content::RunAllPendingInMessageLoop(); | 234 content::RunAllPendingInMessageLoop(); |
235 | 235 |
236 base::DictionaryValue password; | 236 base::DictionaryValue password; |
237 password.SetIntegerWithoutPathExpansion( | 237 password.SetIntegerWithoutPathExpansion( |
238 kSchemaVersion, SupervisedUserAuthentication::SCHEMA_SALT_HASHED); | 238 kSchemaVersion, SupervisedUserAuthentication::SCHEMA_SALT_HASHED); |
239 password.SetIntegerWithoutPathExpansion(kPasswordRevision, 2); | 239 password.SetIntegerWithoutPathExpansion(kPasswordRevision, 2); |
240 | 240 |
241 password.SetStringWithoutPathExpansion(kPasswordSignature, "signature"); | 241 password.SetStringWithoutPathExpansion(kPasswordSignature, "signature"); |
242 password.SetStringWithoutPathExpansion(kEncryptedPassword, | 242 password.SetStringWithoutPathExpansion(kEncryptedPassword, |
243 "new-encrypted-password"); | 243 "new-encrypted-password"); |
244 shared_settings_adapter_->AddChange( | 244 shared_settings_adapter_->AddChange( |
245 sync_id, supervised_users::kChromeOSPasswordData, password, true, false); | 245 sync_id, supervised_users::kChromeOSPasswordData, password, true, false); |
246 content::RunAllPendingInMessageLoop(); | 246 content::RunAllPendingInMessageLoop(); |
247 | 247 |
248 testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); | 248 testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); |
249 } | 249 } |
250 | 250 |
251 // When supervised user signs in, password is already migrated, so no migration | 251 // When supervised user signs in, password is already migrated, so no migration |
252 // should be attempted. | 252 // should be attempted. |
253 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | 253 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, |
254 DISABLED_PasswordChangeUserAndManagerTest) { | 254 DISABLED_PasswordChangeUserAndManagerTest) { |
255 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); | 255 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); |
256 EXPECT_CALL(*mock_homedir_methods_, UpdateKeyEx(_, _, _, _, _)).Times(0); | 256 EXPECT_CALL(*mock_homedir_methods_, UpdateKeyEx(_, _, _, _, _)).Times(0); |
257 SigninAsSupervisedUser(false, 1, kTestSupervisedUserDisplayName); | 257 SigninAsSupervisedUser(false, 1, kTestSupervisedUserDisplayName); |
258 testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); | 258 testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); |
259 } | 259 } |
260 | 260 |
261 } // namespace chromeos | 261 } // namespace chromeos |
OLD | NEW |