Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chromeos/dbus/fake_auth_policy_client_unittest.cc

Issue 2835473002: Chromad: Allow offline login. (Closed)
Patch Set: Add TryAuthenticateUser call Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/dbus/fake_auth_policy_client.cc ('k') | chromeos/login/auth/authpolicy_login_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "components/signin/core/account_id/account_id.h" 10 #include "components/signin/core/account_id/account_id.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace chromeos { 13 namespace chromeos {
14 namespace { 14 namespace {
15 15
16 const char kCorrectMachineName[] = "machine_name"; 16 const char kCorrectMachineName[] = "machine_name";
17 const char kCorrectUserName[] = "user@realm.com"; 17 const char kCorrectUserName[] = "user@realm.com";
18 const char kObjectGUID[] = "user-object-guid";
18 19
19 } // namespace 20 } // namespace
20 21
21 class FakeAuthPolicyClientTest : public ::testing::Test { 22 class FakeAuthPolicyClientTest : public ::testing::Test {
22 public: 23 public:
23 FakeAuthPolicyClientTest(){}; 24 FakeAuthPolicyClientTest() {}
24 25
25 protected: 26 protected:
26 FakeAuthPolicyClient* authpolicy_client() { return &client_; } 27 FakeAuthPolicyClient* authpolicy_client() { return &client_; }
27 28
28 private: 29 private:
29 FakeAuthPolicyClient client_; 30 FakeAuthPolicyClient client_;
30 base::MessageLoop loop_; 31 base::MessageLoop loop_;
31 32
32 DISALLOW_COPY_AND_ASSIGN(FakeAuthPolicyClientTest); 33 DISALLOW_COPY_AND_ASSIGN(FakeAuthPolicyClientTest);
33 }; 34 };
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 })); 95 }));
95 authpolicy_client()->JoinAdDomain( 96 authpolicy_client()->JoinAdDomain(
96 kCorrectMachineName, "user@realm@com", 97 kCorrectMachineName, "user@realm@com",
97 /* password_fd */ -1, base::Bind([](authpolicy::ErrorType error) { 98 /* password_fd */ -1, base::Bind([](authpolicy::ErrorType error) {
98 EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error); 99 EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
99 })); 100 }));
100 101
101 base::RunLoop().RunUntilIdle(); 102 base::RunLoop().RunUntilIdle();
102 } 103 }
103 104
105 // Test AuthenticateUser.
106 TEST_F(FakeAuthPolicyClientTest, AuthenticateUser_ByObjectGUID) {
107 authpolicy_client()->set_started(true);
108 // Check that objectGUID do not change.
109 authpolicy_client()->AuthenticateUser(
110 kCorrectUserName, kObjectGUID, /* password_fd */ -1,
111 base::Bind(
112 [](authpolicy::ErrorType error,
113 const authpolicy::ActiveDirectoryAccountData& account_data) {
114 EXPECT_EQ(authpolicy::ERROR_NONE, error);
115 EXPECT_EQ(kObjectGUID, account_data.account_id());
116 }));
117 }
118
104 // Tests calls to not started authpolicyd fails. 119 // Tests calls to not started authpolicyd fails.
105 TEST_F(FakeAuthPolicyClientTest, NotStartedAuthPolicyService) { 120 TEST_F(FakeAuthPolicyClientTest, NotStartedAuthPolicyService) {
106 authpolicy_client()->JoinAdDomain( 121 authpolicy_client()->JoinAdDomain(
107 kCorrectMachineName, kCorrectUserName, 122 kCorrectMachineName, kCorrectUserName,
108 /* password_fd */ -1, base::Bind([](authpolicy::ErrorType error) { 123 /* password_fd */ -1, base::Bind([](authpolicy::ErrorType error) {
109 EXPECT_EQ(authpolicy::ERROR_DBUS_FAILURE, error); 124 EXPECT_EQ(authpolicy::ERROR_DBUS_FAILURE, error);
110 })); 125 }));
111 authpolicy_client()->AuthenticateUser( 126 authpolicy_client()->AuthenticateUser(
112 kCorrectUserName, /* password_fd */ -1, 127 kCorrectUserName, std::string() /* object_guid */, /* password_fd */ -1,
113 base::Bind([](authpolicy::ErrorType error, 128 base::Bind([](authpolicy::ErrorType error,
114 const authpolicy::ActiveDirectoryAccountData&) { 129 const authpolicy::ActiveDirectoryAccountData&) {
115 EXPECT_EQ(authpolicy::ERROR_DBUS_FAILURE, error); 130 EXPECT_EQ(authpolicy::ERROR_DBUS_FAILURE, error);
116 })); 131 }));
117 authpolicy_client()->RefreshDevicePolicy( 132 authpolicy_client()->RefreshDevicePolicy(
118 base::Bind([](bool success) { EXPECT_FALSE(success); })); 133 base::Bind([](bool success) { EXPECT_FALSE(success); }));
119 authpolicy_client()->RefreshUserPolicy( 134 authpolicy_client()->RefreshUserPolicy(
120 AccountId::FromUserEmail(kCorrectUserName), 135 AccountId::FromUserEmail(kCorrectUserName),
121 base::Bind([](bool success) { EXPECT_FALSE(success); })); 136 base::Bind([](bool success) { EXPECT_FALSE(success); }));
122 137
123 base::RunLoop().RunUntilIdle(); 138 base::RunLoop().RunUntilIdle();
124 } 139 }
125 140
126 } // namespace chromeos 141 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_auth_policy_client.cc ('k') | chromeos/login/auth/authpolicy_login_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698