Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chromeos/dbus/fake_auth_policy_client.h" | 5 #include "chromeos/dbus/fake_auth_policy_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/md5.h" | 11 #include "base/md5.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/string_split.h" | |
| 13 #include "base/task_scheduler/post_task.h" | 14 #include "base/task_scheduler/post_task.h" |
| 14 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 15 #include "chromeos/chromeos_paths.h" | 16 #include "chromeos/chromeos_paths.h" |
| 16 #include "chromeos/cryptohome/cryptohome_parameters.h" | 17 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 17 #include "chromeos/dbus/cryptohome_client.h" | 18 #include "chromeos/dbus/cryptohome_client.h" |
| 18 #include "components/policy/proto/cloud_policy.pb.h" | 19 #include "components/policy/proto/cloud_policy.pb.h" |
| 19 #include "components/policy/proto/device_management_backend.pb.h" | 20 #include "components/policy/proto/device_management_backend.pb.h" |
| 20 #include "components/signin/core/account_id/account_id.h" | 21 #include "components/signin/core/account_id/account_id.h" |
| 21 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 22 | 23 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 FakeAuthPolicyClient::FakeAuthPolicyClient() {} | 59 FakeAuthPolicyClient::FakeAuthPolicyClient() {} |
| 59 | 60 |
| 60 FakeAuthPolicyClient::~FakeAuthPolicyClient() {} | 61 FakeAuthPolicyClient::~FakeAuthPolicyClient() {} |
| 61 | 62 |
| 62 void FakeAuthPolicyClient::Init(dbus::Bus* bus) {} | 63 void FakeAuthPolicyClient::Init(dbus::Bus* bus) {} |
| 63 | 64 |
| 64 void FakeAuthPolicyClient::JoinAdDomain(const std::string& machine_name, | 65 void FakeAuthPolicyClient::JoinAdDomain(const std::string& machine_name, |
| 65 const std::string& user_principal_name, | 66 const std::string& user_principal_name, |
| 66 int password_fd, | 67 int password_fd, |
| 67 const JoinCallback& callback) { | 68 const JoinCallback& callback) { |
| 69 std::vector<std::string> parts = base::SplitString( | |
| 70 user_principal_name, "@", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | |
| 71 if (parts.size() != 2U) { | |
|
Thiemo Nagel
2017/01/24 14:17:36
It seems that you'll have to check the sizes of th
achuithb
2017/01/24 19:42:11
Sounds like we need a unit test
Roman Sorokin (ftl)
2017/01/25 11:50:18
Done.
Roman Sorokin (ftl)
2017/01/25 11:50:18
Done.
| |
| 72 callback.Run(authpolicy::ERROR_PARSE_UPN_FAILED); | |
| 73 return; | |
| 74 } | |
| 75 | |
| 68 callback.Run(authpolicy::ERROR_NONE); | 76 callback.Run(authpolicy::ERROR_NONE); |
| 69 } | 77 } |
| 70 | 78 |
| 71 void FakeAuthPolicyClient::AuthenticateUser( | 79 void FakeAuthPolicyClient::AuthenticateUser( |
| 72 const std::string& user_principal_name, | 80 const std::string& user_principal_name, |
| 73 int password_fd, | 81 int password_fd, |
| 74 const AuthCallback& callback) { | 82 const AuthCallback& callback) { |
| 75 callback.Run(authpolicy::ERROR_NONE, base::MD5String(user_principal_name)); | 83 callback.Run(authpolicy::ERROR_NONE, base::MD5String(user_principal_name)); |
| 76 } | 84 } |
| 77 | 85 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 .WithShutdownBehavior( | 132 .WithShutdownBehavior( |
| 125 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | 133 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
| 126 .WithPriority(base::TaskPriority::BACKGROUND) | 134 .WithPriority(base::TaskPriority::BACKGROUND) |
| 127 .MayBlock(), | 135 .MayBlock(), |
| 128 base::Bind(&WritePolicyFile, policy_path, payload, | 136 base::Bind(&WritePolicyFile, policy_path, payload, |
| 129 "google/chromeos/user"), | 137 "google/chromeos/user"), |
| 130 callback); | 138 callback); |
| 131 } | 139 } |
| 132 | 140 |
| 133 } // namespace chromeos | 141 } // namespace chromeos |
| OLD | NEW |