OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 InstallUserKey(); | 199 InstallUserKey(); |
200 user_policy_.policy_data().set_username( | 200 user_policy_.policy_data().set_username( |
201 chromeos::login::StubAccountId().GetUserEmail()); | 201 chromeos::login::StubAccountId().GetUserEmail()); |
202 } | 202 } |
203 | 203 |
204 void PowerPolicyBrowserTestBase::InstallUserKey() { | 204 void PowerPolicyBrowserTestBase::InstallUserKey() { |
205 base::FilePath user_keys_dir; | 205 base::FilePath user_keys_dir; |
206 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir)); | 206 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir)); |
207 std::string sanitized_username = | 207 std::string sanitized_username = |
208 chromeos::CryptohomeClient::GetStubSanitizedUsername( | 208 chromeos::CryptohomeClient::GetStubSanitizedUsername( |
209 chromeos::login::StubAccountId().GetUserEmail()); | 209 cryptohome::Identification(chromeos::login::StubAccountId())); |
210 base::FilePath user_key_file = | 210 base::FilePath user_key_file = |
211 user_keys_dir.AppendASCII(sanitized_username) | 211 user_keys_dir.AppendASCII(sanitized_username) |
212 .AppendASCII("policy.pub"); | 212 .AppendASCII("policy.pub"); |
213 std::vector<uint8_t> user_key_bits; | 213 std::vector<uint8_t> user_key_bits; |
214 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); | 214 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); |
215 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); | 215 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); |
216 ASSERT_EQ(base::WriteFile( | 216 ASSERT_EQ(base::WriteFile( |
217 user_key_file, | 217 user_key_file, |
218 reinterpret_cast<const char*>(user_key_bits.data()), | 218 reinterpret_cast<const char*>(user_key_bits.data()), |
219 user_key_bits.size()), | 219 user_key_bits.size()), |
220 static_cast<int>(user_key_bits.size())); | 220 static_cast<int>(user_key_bits.size())); |
221 } | 221 } |
222 | 222 |
223 void PowerPolicyBrowserTestBase::StoreAndReloadUserPolicy() { | 223 void PowerPolicyBrowserTestBase::StoreAndReloadUserPolicy() { |
224 // Install the new user policy blob in session manager client. | 224 // Install the new user policy blob in session manager client. |
225 user_policy_.Build(); | 225 user_policy_.Build(); |
226 session_manager_client()->set_user_policy( | 226 session_manager_client()->set_user_policy( |
227 user_policy_.policy_data().username(), | 227 cryptohome::Identification( |
| 228 AccountId::FromUserEmail(user_policy_.policy_data().username())), |
228 user_policy_.GetBlob()); | 229 user_policy_.GetBlob()); |
229 | 230 |
230 // Reload user policy from session manager client and wait for the update to | 231 // Reload user policy from session manager client and wait for the update to |
231 // take effect. | 232 // take effect. |
232 RunClosureAndWaitForUserPolicyUpdate( | 233 RunClosureAndWaitForUserPolicyUpdate( |
233 base::Bind(&PowerPolicyBrowserTestBase::ReloadUserPolicy, this, | 234 base::Bind(&PowerPolicyBrowserTestBase::ReloadUserPolicy, this, |
234 browser()->profile()), | 235 browser()->profile()), |
235 browser()->profile()); | 236 browser()->profile()); |
236 } | 237 } |
237 | 238 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 policy = baseline_policy; | 512 policy = baseline_policy; |
512 policy.set_ac_idle_action(power_manager_client_->policy().ac_idle_action()); | 513 policy.set_ac_idle_action(power_manager_client_->policy().ac_idle_action()); |
513 policy.set_battery_idle_action( | 514 policy.set_battery_idle_action( |
514 power_manager_client_->policy().battery_idle_action()); | 515 power_manager_client_->policy().battery_idle_action()); |
515 policy.set_reason(power_manager_client_->policy().reason()); | 516 policy.set_reason(power_manager_client_->policy().reason()); |
516 EXPECT_EQ(GetDebugString(policy), | 517 EXPECT_EQ(GetDebugString(policy), |
517 GetDebugString(power_manager_client_->policy())); | 518 GetDebugString(power_manager_client_->policy())); |
518 } | 519 } |
519 | 520 |
520 } // namespace policy | 521 } // namespace policy |
OLD | NEW |