| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" | 4 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" |
| 5 | 5 |
| 6 #include <stdint.h> |
| 7 |
| 6 #include <string> | 8 #include <string> |
| 7 #include <vector> | 9 #include <vector> |
| 8 | 10 |
| 9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 11 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 12 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 13 #include "base/prefs/scoped_user_pref_update.h" | 15 #include "base/prefs/scoped_user_pref_update.h" |
| 14 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 42 const char kEnterpriseUser[] = "testuser@example.com"; | 44 const char kEnterpriseUser[] = "testuser@example.com"; |
| 43 | 45 |
| 44 void SetUserKeys(policy::UserPolicyBuilder* user_policy) { | 46 void SetUserKeys(policy::UserPolicyBuilder* user_policy) { |
| 45 std::string username = user_policy->policy_data().username(); | 47 std::string username = user_policy->policy_data().username(); |
| 46 base::FilePath user_keys_dir; | 48 base::FilePath user_keys_dir; |
| 47 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir)); | 49 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir)); |
| 48 const std::string sanitized_username = | 50 const std::string sanitized_username = |
| 49 chromeos::CryptohomeClient::GetStubSanitizedUsername(username); | 51 chromeos::CryptohomeClient::GetStubSanitizedUsername(username); |
| 50 const base::FilePath user_key_file = | 52 const base::FilePath user_key_file = |
| 51 user_keys_dir.AppendASCII(sanitized_username).AppendASCII("policy.pub"); | 53 user_keys_dir.AppendASCII(sanitized_username).AppendASCII("policy.pub"); |
| 52 std::vector<uint8> user_key_bits; | 54 std::vector<uint8_t> user_key_bits; |
| 53 ASSERT_TRUE(user_policy->GetSigningKey()->ExportPublicKey(&user_key_bits)); | 55 ASSERT_TRUE(user_policy->GetSigningKey()->ExportPublicKey(&user_key_bits)); |
| 54 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); | 56 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); |
| 55 ASSERT_EQ(base::WriteFile(user_key_file, | 57 ASSERT_EQ(base::WriteFile(user_key_file, |
| 56 reinterpret_cast<const char*>(user_key_bits.data()), | 58 reinterpret_cast<const char*>(user_key_bits.data()), |
| 57 user_key_bits.size()), | 59 user_key_bits.size()), |
| 58 static_cast<int>(user_key_bits.size())); | 60 static_cast<int>(user_key_bits.size())); |
| 59 } | 61 } |
| 60 | 62 |
| 61 void SetDeviceAffiliationID( | 63 void SetDeviceAffiliationID( |
| 62 policy::DevicePolicyCrosTestHelper* test_helper, | 64 policy::DevicePolicyCrosTestHelper* test_helper, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 131 } |
| 130 | 132 |
| 131 void AppendCommandLineSwitchesForLoginManager(base::CommandLine* command_line) { | 133 void AppendCommandLineSwitchesForLoginManager(base::CommandLine* command_line) { |
| 132 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 134 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 133 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); | 135 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); |
| 134 } | 136 } |
| 135 | 137 |
| 136 } // namespace affiliation_test_helper | 138 } // namespace affiliation_test_helper |
| 137 | 139 |
| 138 } // namespace policy | 140 } // namespace policy |
| OLD | NEW |