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

Unified Diff: chromeos/dbus/fake_auth_policy_client_unittest.cc

Issue 2794493002: Add AuthPolicyLoginHelper (Closed)
Patch Set: Update after review Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/fake_auth_policy_client.cc ('k') | chromeos/dbus/fake_upstart_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e220238e18e8d2c30796b8f74b9fb910f1adb156..634255929bd921c7c70980d5610fc7ae42455251 100644
--- a/chromeos/dbus/fake_auth_policy_client_unittest.cc
+++ b/chromeos/dbus/fake_auth_policy_client_unittest.cc
@@ -5,6 +5,8 @@
#include "chromeos/dbus/fake_auth_policy_client.h"
#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "components/signin/core/account_id/account_id.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -16,84 +18,109 @@ const char kCorrectUserName[] = "user@realm.com";
} // namespace
+class FakeAuthPolicyClientTest : public ::testing::Test {
+ public:
+ FakeAuthPolicyClientTest(){};
+
+ protected:
+ FakeAuthPolicyClient* authpolicy_client() { return &client_; }
+
+ private:
+ FakeAuthPolicyClient client_;
+ base::MessageLoop loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeAuthPolicyClientTest);
+};
+
// Tests parsing machine name.
-TEST(FakeAuthPolicyClientTest, JoinAdDomain_ParseMachineName) {
- FakeAuthPolicyClient client;
- client.set_started(true);
- client.JoinAdDomain("correct_length1", kCorrectUserName, /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_NONE, error);
- }));
- client.JoinAdDomain("", kCorrectUserName, /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_BAD_MACHINE_NAME, error);
- }));
- client.JoinAdDomain(
+TEST_F(FakeAuthPolicyClientTest, JoinAdDomain_ParseMachineName) {
+ authpolicy_client()->set_started(true);
+ authpolicy_client()->JoinAdDomain("correct_length1", kCorrectUserName,
+ /* password_fd */ -1,
+ base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_NONE, error);
+ }));
+ authpolicy_client()->JoinAdDomain(
+ "", kCorrectUserName, /* password_fd */ -1,
+ base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_BAD_MACHINE_NAME, error);
+ }));
+ authpolicy_client()->JoinAdDomain(
"too_long_machine_name", kCorrectUserName, /* password_fd */ -1,
base::Bind([](authpolicy::ErrorType error) {
EXPECT_EQ(authpolicy::ERROR_MACHINE_NAME_TOO_LONG, error);
}));
- client.JoinAdDomain("invalid:name", kCorrectUserName, /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_BAD_MACHINE_NAME, error);
- }));
- client.JoinAdDomain(">nvalidname", kCorrectUserName, /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_BAD_MACHINE_NAME, error);
- }));
+ authpolicy_client()->JoinAdDomain(
+ "invalid:name", kCorrectUserName, /* password_fd */ -1,
+ base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_BAD_MACHINE_NAME, error);
+ }));
+ authpolicy_client()->JoinAdDomain(
+ ">nvalidname", kCorrectUserName, /* password_fd */ -1,
+ base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_BAD_MACHINE_NAME, error);
+ }));
+
+ base::RunLoop().RunUntilIdle();
}
// Tests parsing user name.
-TEST(FakeAuthPolicyClientTest, JoinAdDomain_ParseUPN) {
- FakeAuthPolicyClient client;
- client.set_started(true);
- client.JoinAdDomain(kCorrectMachineName, "user@realm.com",
- /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_NONE, error);
- }));
- client.JoinAdDomain(kCorrectMachineName, "user", /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
- }));
- client.JoinAdDomain(kCorrectMachineName, "", /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
- }));
- client.JoinAdDomain(kCorrectMachineName, "user@", /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
- }));
- client.JoinAdDomain(kCorrectMachineName, "@realm", /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
- }));
- client.JoinAdDomain(kCorrectMachineName, "user@realm@com",
- /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
- }));
+TEST_F(FakeAuthPolicyClientTest, JoinAdDomain_ParseUPN) {
+ authpolicy_client()->set_started(true);
+ authpolicy_client()->JoinAdDomain(kCorrectMachineName, "user@realm.com",
+ /* password_fd */ -1,
+ base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_NONE, error);
+ }));
+ authpolicy_client()->JoinAdDomain(
+ kCorrectMachineName, "user", /* password_fd */ -1,
+ base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
+ }));
+ authpolicy_client()->JoinAdDomain(
+ kCorrectMachineName, "", /* password_fd */ -1,
+ base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
+ }));
+ authpolicy_client()->JoinAdDomain(
+ kCorrectMachineName, "user@", /* password_fd */ -1,
+ base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
+ }));
+ authpolicy_client()->JoinAdDomain(
+ kCorrectMachineName, "@realm", /* password_fd */ -1,
+ base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
+ }));
+ authpolicy_client()->JoinAdDomain(
+ kCorrectMachineName, "user@realm@com",
+ /* password_fd */ -1, base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_PARSE_UPN_FAILED, error);
+ }));
+
+ base::RunLoop().RunUntilIdle();
}
// Tests calls to not started authpolicyd fails.
-TEST(FakeAuthPolicyClientTest, NotStartedAuthPolicyService) {
- FakeAuthPolicyClient client;
- client.JoinAdDomain(kCorrectMachineName, kCorrectUserName,
- /* password_fd */ -1,
- base::Bind([](authpolicy::ErrorType error) {
- EXPECT_EQ(authpolicy::ERROR_DBUS_FAILURE, error);
- }));
- client.AuthenticateUser(
+TEST_F(FakeAuthPolicyClientTest, NotStartedAuthPolicyService) {
+ authpolicy_client()->JoinAdDomain(
+ kCorrectMachineName, kCorrectUserName,
+ /* password_fd */ -1, base::Bind([](authpolicy::ErrorType error) {
+ EXPECT_EQ(authpolicy::ERROR_DBUS_FAILURE, error);
+ }));
+ authpolicy_client()->AuthenticateUser(
kCorrectUserName, /* password_fd */ -1,
base::Bind([](authpolicy::ErrorType error,
const authpolicy::ActiveDirectoryAccountData&) {
EXPECT_EQ(authpolicy::ERROR_DBUS_FAILURE, error);
}));
- client.RefreshDevicePolicy(
+ authpolicy_client()->RefreshDevicePolicy(
base::Bind([](bool success) { EXPECT_FALSE(success); }));
- client.RefreshUserPolicy(
+ authpolicy_client()->RefreshUserPolicy(
AccountId::FromUserEmail(kCorrectUserName),
base::Bind([](bool success) { EXPECT_FALSE(success); }));
+
+ base::RunLoop().RunUntilIdle();
}
} // namespace chromeos
« no previous file with comments | « chromeos/dbus/fake_auth_policy_client.cc ('k') | chromeos/dbus/fake_upstart_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698