Chromium Code Reviews| Index: chromeos/dbus/fake_auth_policy_client_unittest.cc |
| diff --git a/chromeos/dbus/fake_auth_policy_client_unittest.cc b/chromeos/dbus/fake_auth_policy_client_unittest.cc |
| index a8b6b79a7c0cfe4ebcfc33dd59201796a69490da..3a86d3ea822bbe66d0754f998b21d90db69f2d3a 100644 |
| --- a/chromeos/dbus/fake_auth_policy_client_unittest.cc |
| +++ b/chromeos/dbus/fake_auth_policy_client_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include "chromeos/dbus/fake_auth_policy_client.h" |
| #include "base/bind.h" |
| +#include "components/signin/core/account_id/account_id.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace chromeos { |
| @@ -21,10 +22,28 @@ void JoinAdCallback(const std::string& machine_name, |
| << ", and user name: " << user_principal_name; |
| } |
| +void AuthenticateUserCallback(const std::string& user_principal_name, |
| + authpolicy::ErrorType expected, |
| + authpolicy::ErrorType actual, |
| + const std::string& obj_guid) { |
| + EXPECT_EQ(expected, actual) << "with user name: " << user_principal_name; |
| +} |
| + |
| +void RefreshDevicePolicyCallback(bool expected, bool actual) { |
| + EXPECT_EQ(expected, actual); |
| +} |
| + |
| +void RefreshUserPolicyCallback(const std::string& user_principal_name, |
| + bool expected, |
| + bool actual) { |
| + EXPECT_EQ(expected, actual) << "with user name: " << user_principal_name; |
| +} |
| + |
| void TestDomainJoin(const std::string& machine_name, |
| const std::string& user_principal_name, |
| authpolicy::ErrorType expected) { |
| FakeAuthPolicyClient client; |
| + client.Start(); |
| client.JoinAdDomain( |
| machine_name, user_principal_name, /* password_fd */ -1, |
| base::Bind(&JoinAdCallback, machine_name, user_principal_name, expected)); |
| @@ -58,4 +77,21 @@ TEST(FakeAuthPolicyClientTest, JoinAdDomain_ParseUPN) { |
| authpolicy::ERROR_PARSE_UPN_FAILED); |
| } |
| +// Tests calls to not started authpolicyd fails. |
| +TEST(FakeAuthPolicyClientTest, NotStartedAuthPolicyService) { |
| + FakeAuthPolicyClient client; |
| + client.JoinAdDomain( |
| + kCorrectMachineName, kCorrectUserName, /* password_fd */ -1, |
| + base::Bind(&JoinAdCallback, kCorrectMachineName, kCorrectUserName, |
|
hashimoto
2017/02/06 04:15:49
How about using lambdas?
Instead of base::Bind(&J
Roman Sorokin (ftl)
2017/02/06 10:30:40
Thanks for the hint! Changed for the all calls.
|
| + authpolicy::ERROR_DBUS_FAILURE)); |
| + client.AuthenticateUser( |
| + kCorrectUserName, /* password_fd */ -1, |
| + base::Bind(&AuthenticateUserCallback, kCorrectUserName, |
| + authpolicy::ERROR_DBUS_FAILURE)); |
| + client.RefreshDevicePolicy(base::Bind(&RefreshDevicePolicyCallback, false)); |
| + client.RefreshUserPolicy( |
| + AccountId::FromUserEmail(kCorrectUserName), |
| + base::Bind(&RefreshUserPolicyCallback, kCorrectUserName, false)); |
| +} |
| + |
| } // namespace chromeos |