OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include <string> | |
6 | |
7 #include "base/compiler_specific.h" | |
8 #include "base/run_loop.h" | |
9 #include "base/strings/utf_string_conversions.h" | |
10 #include "base/threading/sequenced_worker_pool.h" | |
11 #include "chrome/browser/chrome_notification_types.h" | |
12 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | |
13 #include "chrome/browser/chromeos/login/login_manager_test.h" | |
14 #include "chrome/browser/chromeos/login/managed/managed_user_test_base.h" | |
15 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h " | |
16 #include "chrome/browser/chromeos/login/startup_utils.h" | |
17 #include "chrome/browser/chromeos/login/supervised_user_manager.h" | |
18 #include "chrome/browser/chromeos/login/webui_login_view.h" | |
19 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | |
20 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | |
21 #include "chrome/browser/managed_mode/managed_user_constants.h" | |
22 #include "chrome/browser/managed_mode/managed_user_registration_utility.h" | |
23 #include "chrome/browser/managed_mode/managed_user_registration_utility_stub.h" | |
24 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" | |
25 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto ry.h" | |
26 #include "chrome/browser/managed_mode/managed_user_sync_service.h" | |
27 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" | |
28 #include "chromeos/cryptohome/mock_async_method_caller.h" | |
29 #include "chromeos/cryptohome/mock_homedir_methods.h" | |
30 #include "content/public/browser/notification_service.h" | |
31 #include "content/public/test/browser_test_utils.h" | |
32 #include "content/public/test/test_utils.h" | |
33 #include "sync/api/attachments/attachment_service_proxy_for_test.h" | |
34 #include "sync/api/fake_sync_change_processor.h" | |
35 #include "sync/api/sync_change.h" | |
36 #include "sync/api/sync_error_factory_mock.h" | |
37 #include "sync/protocol/sync.pb.h" | |
38 | |
39 using testing::_; | |
40 using chromeos::testing::ManagedUserTestBase; | |
41 using chromeos::testing::kTestSupervisedUserDisplayName; | |
42 using chromeos::testing::kTestManager; | |
43 | |
44 namespace chromeos { | |
45 | |
46 class SupervisedUserPasswordTest : public ManagedUserTestBase { | |
47 public: | |
48 SupervisedUserPasswordTest() : ManagedUserTestBase() {} | |
49 | |
50 private: | |
51 DISALLOW_COPY_AND_ASSIGN(SupervisedUserPasswordTest); | |
52 }; | |
53 | |
54 class SupervisedUserPasswordManagerTest : public ManagedUserTestBase { | |
55 public: | |
56 SupervisedUserPasswordManagerTest() : ManagedUserTestBase() {} | |
57 | |
58 private: | |
59 DISALLOW_COPY_AND_ASSIGN(SupervisedUserPasswordManagerTest); | |
60 }; | |
61 | |
62 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
63 PRE_PRE_PRE_PasswordChangeFromUserTest) { | |
64 PrepareUsers(); | |
65 } | |
66 | |
67 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
68 PRE_PRE_PasswordChangeFromUserTest) { | |
69 StartFlowLoginAsManager(); | |
70 FillNewUserData(kTestSupervisedUserDisplayName); | |
71 StartUserCreation("managed-user-creation-next-button", | |
72 kTestSupervisedUserDisplayName); | |
73 } | |
74 | |
75 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
Nikita (slow)
2014/04/23 09:50:17
This file doesn't have a single comment.
Please at
Denis Kuznetsov (DE-MUC)
2014/04/24 17:44:09
Done.
| |
76 PRE_PasswordChangeFromUserTest) { | |
77 SigninAsSupervisedUser(true, 0, kTestSupervisedUserDisplayName); | |
78 | |
79 const User* user = UserManager::Get()->GetUsers().at(0); | |
80 std::string sync_id = | |
81 UserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( | |
82 user->email()); | |
83 base::DictionaryValue password; | |
84 password.SetIntegerWithoutPathExpansion( | |
85 kSchemaVersion, SupervisedUserAuthentication::SCHEMA_SALT_HASHED); | |
86 password.SetIntegerWithoutPathExpansion(kPasswordRevision, 2); | |
87 | |
88 password.SetStringWithoutPathExpansion(kPasswordSignature, "signature"); | |
89 password.SetStringWithoutPathExpansion(kEncryptedPassword, | |
90 "new-encrypted-password"); | |
91 | |
92 shared_settings_adapter_->AddChange( | |
93 sync_id, managed_users::kChromeOSPasswordData, password, true); | |
94 content::RunAllPendingInMessageLoop(); | |
95 } | |
96 | |
97 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, PasswordChangeFromUserTest) { | |
98 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); | |
99 EXPECT_CALL(*mock_homedir_methods_, UpdateKeyEx(_, _, _, _, _)).Times(1); | |
100 SigninAsSupervisedUser(false, 0, kTestSupervisedUserDisplayName); | |
101 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); | |
102 } | |
103 | |
104 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
105 PRE_PRE_PRE_PasswordChangeFromManagerTest) { | |
106 PrepareUsers(); | |
107 } | |
108 | |
109 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
110 PRE_PRE_PasswordChangeFromManagerTest) { | |
111 StartFlowLoginAsManager(); | |
112 FillNewUserData(kTestSupervisedUserDisplayName); | |
113 StartUserCreation("managed-user-creation-next-button", | |
114 kTestSupervisedUserDisplayName); | |
115 } | |
116 | |
117 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
118 PRE_PasswordChangeFromManagerTest) { | |
119 const User* managed_user = UserManager::Get()->GetUsers().at(0); | |
120 | |
121 SigninAsManager(1); | |
122 | |
123 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1); | |
124 | |
125 std::string sync_id = | |
126 UserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( | |
127 managed_user->email()); | |
128 | |
129 ::sync_pb::ManagedUserSpecifics managed_user_proto; | |
130 | |
131 managed_user_proto.set_id(sync_id); | |
132 managed_user_proto.set_name(kTestSupervisedUserDisplayName); | |
133 managed_user_proto.set_acknowledged(true); | |
134 managed_user_proto.set_master_key("master key"); | |
135 managed_user_proto.set_password_signature_key("signature_key"); | |
136 managed_user_proto.set_password_encryption_key("encryption_key"); | |
137 | |
138 managed_users_adapter_->AddChange(managed_user_proto); | |
139 content::RunAllPendingInMessageLoop(); | |
140 | |
141 base::DictionaryValue password; | |
142 password.SetIntegerWithoutPathExpansion( | |
143 kSchemaVersion, SupervisedUserAuthentication::SCHEMA_SALT_HASHED); | |
144 password.SetIntegerWithoutPathExpansion(kPasswordRevision, 2); | |
145 | |
146 password.SetStringWithoutPathExpansion(kPasswordSignature, "signature"); | |
147 password.SetStringWithoutPathExpansion(kEncryptedPassword, | |
148 "new-encrypted-password"); | |
149 shared_settings_adapter_->AddChange( | |
150 sync_id, managed_users::kChromeOSPasswordData, password, true); | |
151 content::RunAllPendingInMessageLoop(); | |
152 | |
153 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); | |
154 } | |
155 | |
156 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
157 PasswordChangeFromManagerTest) { | |
158 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); | |
159 EXPECT_CALL(*mock_homedir_methods_, UpdateKeyEx(_, _, _, _, _)).Times(0); | |
160 SigninAsSupervisedUser(false, 1, kTestSupervisedUserDisplayName); | |
161 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); | |
162 } | |
163 | |
164 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
165 PRE_PRE_PRE_PRE_PasswordChangeUserAndManagerTest) { | |
166 PrepareUsers(); | |
167 } | |
168 | |
169 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
170 PRE_PRE_PRE_PasswordChangeUserAndManagerTest) { | |
171 StartFlowLoginAsManager(); | |
172 FillNewUserData(kTestSupervisedUserDisplayName); | |
173 StartUserCreation("managed-user-creation-next-button", | |
174 kTestSupervisedUserDisplayName); | |
175 } | |
176 | |
177 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
178 PRE_PRE_PasswordChangeUserAndManagerTest) { | |
179 SigninAsSupervisedUser(true, 0, kTestSupervisedUserDisplayName); | |
180 | |
181 const User* user = UserManager::Get()->GetUsers().at(0); | |
182 std::string sync_id = | |
183 UserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( | |
184 user->email()); | |
185 base::DictionaryValue password; | |
186 password.SetIntegerWithoutPathExpansion( | |
187 kSchemaVersion, SupervisedUserAuthentication::SCHEMA_SALT_HASHED); | |
188 password.SetIntegerWithoutPathExpansion(kPasswordRevision, 2); | |
189 | |
190 password.SetStringWithoutPathExpansion(kPasswordSignature, "signature"); | |
191 password.SetStringWithoutPathExpansion(kEncryptedPassword, | |
192 "new-encrypted-password"); | |
193 | |
194 shared_settings_adapter_->AddChange( | |
195 sync_id, managed_users::kChromeOSPasswordData, password, true); | |
196 content::RunAllPendingInMessageLoop(); | |
197 } | |
198 | |
199 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
200 PRE_PasswordChangeUserAndManagerTest) { | |
201 const User* managed_user = UserManager::Get()->GetUsers().at(0); | |
202 | |
203 SigninAsManager(1); | |
204 | |
205 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1); | |
206 | |
207 std::string sync_id = | |
208 UserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( | |
209 managed_user->email()); | |
210 | |
211 ::sync_pb::ManagedUserSpecifics managed_user_proto; | |
212 | |
213 managed_user_proto.set_id(sync_id); | |
214 managed_user_proto.set_name(kTestSupervisedUserDisplayName); | |
215 managed_user_proto.set_acknowledged(true); | |
216 managed_user_proto.set_master_key("master key"); | |
217 managed_user_proto.set_password_signature_key("signature_key"); | |
218 managed_user_proto.set_password_encryption_key("encryption_key"); | |
219 | |
220 managed_users_adapter_->AddChange(managed_user_proto); | |
221 content::RunAllPendingInMessageLoop(); | |
222 | |
223 base::DictionaryValue password; | |
224 password.SetIntegerWithoutPathExpansion( | |
225 kSchemaVersion, SupervisedUserAuthentication::SCHEMA_SALT_HASHED); | |
226 password.SetIntegerWithoutPathExpansion(kPasswordRevision, 2); | |
227 | |
228 password.SetStringWithoutPathExpansion(kPasswordSignature, "signature"); | |
229 password.SetStringWithoutPathExpansion(kEncryptedPassword, | |
230 "new-encrypted-password"); | |
231 shared_settings_adapter_->AddChange( | |
232 sync_id, managed_users::kChromeOSPasswordData, password, true); | |
233 content::RunAllPendingInMessageLoop(); | |
234 | |
235 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); | |
236 } | |
237 | |
238 IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest, | |
239 PasswordChangeUserAndManagerTest) { | |
240 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); | |
241 EXPECT_CALL(*mock_homedir_methods_, UpdateKeyEx(_, _, _, _, _)).Times(0); | |
242 SigninAsSupervisedUser(false, 1, kTestSupervisedUserDisplayName); | |
243 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); | |
244 } | |
245 | |
246 } // namespace chromeos | |
OLD | NEW |