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

Unified Diff: chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc

Issue 2716383002: Add Active Directory enterprise enrollment/domain join tests (Closed)
Patch Set: Update after review Created 3 years, 10 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 | « chrome/browser/chromeos/login/enrollment/enrollment_screen.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc
diff --git a/chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc b/chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc
index 2a75d861aff611e8ed7f695e293cbb24e5b3afb5..41f22f90311119e95d557af98d0958582bc232fc 100644
--- a/chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc
+++ b/chrome/browser/chromeos/login/enterprise_enrollment_browsertest.cc
@@ -14,6 +14,8 @@
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/upstart_client.h"
#include "content/public/test/test_utils.h"
using testing::_;
@@ -22,6 +24,20 @@ using testing::InvokeWithoutArgs;
namespace chromeos {
+namespace {
+
+const char kAdMachineNameInput[] =
+ "document.querySelector('#oauth-enroll-ad-join-ui /deep/ "
+ "#machineNameInput')";
+const char kAdUsernameInput[] =
+ "document.querySelector('#oauth-enroll-ad-join-ui /deep/ #userInput')";
+const char kAdPasswordInput[] =
+ "document.querySelector('#oauth-enroll-ad-join-ui /deep/ #passwordInput')";
+const char kAdTestRealm[] = "test_realm.com";
+const char kAdTestUser[] = "test_user@test_realm.com";
+
+} // namespace
+
class EnterpriseEnrollmentTest : public LoginManagerTest {
public:
EnterpriseEnrollmentTest()
@@ -41,7 +57,7 @@ class EnterpriseEnrollmentTest : public LoginManagerTest {
}
using OnSetupEnrollmentHelper =
- void (*)(EnterpriseEnrollmentHelperMock* mock);
+ std::function<void(EnterpriseEnrollmentHelperMock*)>;
// The given function will be executed when the next enrollment helper is
// created.
@@ -75,6 +91,29 @@ class EnterpriseEnrollmentTest : public LoginManagerTest {
"}));");
}
+ // Submits Active Directory domain join credentials.
+ void SubmitActiveDirectoryCredentials(const std::string& machine_name,
+ const std::string& username,
+ const std::string& password) {
+ EXPECT_TRUE(IsStepDisplayed("ad-join"));
+ js_checker().ExpectFalse(std::string(kAdMachineNameInput) + ".hidden");
+ js_checker().ExpectFalse(std::string(kAdUsernameInput) + ".hidden");
+ js_checker().ExpectFalse(std::string(kAdPasswordInput) + ".hidden");
+ const std::string set_machine_name =
+ std::string(kAdMachineNameInput) + ".value = '" + machine_name + "'";
+ const std::string set_username =
+ std::string(kAdUsernameInput) + ".value = '" + username + "'";
+ const std::string set_password =
+ std::string(kAdPasswordInput) + ".value = '" + password + "'";
+ js_checker().ExecuteAsync(set_machine_name);
+ js_checker().ExecuteAsync(set_username);
+ js_checker().ExecuteAsync(set_password);
+ js_checker().Evaluate(
+ "document.querySelector('#oauth-enroll-ad-join-ui /deep/ "
+ "#button').fire('tap')");
+ ExecutePendingJavaScript();
+ }
+
void DisableAttributePromptUpdate() {
AddEnrollmentSetupFunction(
[](EnterpriseEnrollmentHelperMock* enrollment_helper) {
@@ -103,6 +142,19 @@ class EnterpriseEnrollmentTest : public LoginManagerTest {
});
}
+ // Forces the Active Directory domain join flow during enterprise enrollment.
+ void SetupActiveDirectoryJoin() {
+ AddEnrollmentSetupFunction([this](
+ EnterpriseEnrollmentHelperMock* enrollment_helper) {
+ // Causes the attribute-prompt flow to activate.
+ EXPECT_CALL(*enrollment_helper, EnrollUsingAuthCode("test_auth_code", _))
+ .WillOnce(InvokeWithoutArgs([this]() {
+ this->enrollment_screen()->JoinDomain(base::BindOnce([](
+ const std::string& realm) { EXPECT_EQ(kAdTestRealm, realm); }));
+ }));
+ });
+ }
+
// Fills out the UI with device attribute information and submits it.
void SubmitAttributePromptUpdate() {
// Fill out the attribute prompt info and submit it.
@@ -229,4 +281,73 @@ IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentTest,
enrollment_screen()->enrollment_helper_.reset();
}
+// Shows the enrollment screen and mocks the enrollment helper to show Active
+// Directory domain join screen. Verifies the domain join screen is displayed.
+// Submits Active Directory credentials. Verifies that the AuthpolicyClient
+// calls us back with the correct realm.
+IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentTest,
+ TestActiveDirectoryEnrollment_Success) {
+ ShowEnrollmentScreen();
+ DisableAttributePromptUpdate();
+ SetupActiveDirectoryJoin();
+ SubmitEnrollmentCredentials();
+
+ chromeos::DBusThreadManager::Get()
+ ->GetUpstartClient()
+ ->StartAuthPolicyService();
+
+ SubmitActiveDirectoryCredentials("machine_name", kAdTestUser, "password");
+ EXPECT_FALSE(IsStepDisplayed("ad-join"));
+
+ CompleteEnrollment();
+ // Verify that the success page is displayed.
+ EXPECT_TRUE(IsStepDisplayed("success"));
+ EXPECT_FALSE(IsStepDisplayed("error"));
+
+ // We have to remove the enrollment_helper before the dtor gets called.
+ enrollment_screen()->enrollment_helper_.reset();
+}
+
+// Shows the enrollment screen and mocks the enrollment helper to show Active
+// Directory domain join screen. Verifies the domain join screen is displayed.
+// Submits Active Directory different incorrect credentials. Verifies that the
+// correct error is displayed.
+IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentTest,
+ TestActiveDirectoryEnrollment_UIErrors) {
+ ShowEnrollmentScreen();
+ SetupActiveDirectoryJoin();
+ SubmitEnrollmentCredentials();
+
+ chromeos::DBusThreadManager::Get()
+ ->GetUpstartClient()
+ ->StartAuthPolicyService();
+
+ // Checking error in case of empty password. Whether password is not empty
+ // being checked in the UI. Machine name length is checked after that in the
+ // authpolicyd.
+ SubmitActiveDirectoryCredentials("too_long_machine_name", kAdTestUser, "");
+ EXPECT_TRUE(IsStepDisplayed("ad-join"));
+ js_checker().ExpectFalse(std::string(kAdMachineNameInput) + ".isInvalid");
+ js_checker().ExpectFalse(std::string(kAdUsernameInput) + ".isInvalid");
+ js_checker().ExpectTrue(std::string(kAdPasswordInput) + ".isInvalid");
+
+ // Checking error in case of too long machine name.
+ SubmitActiveDirectoryCredentials("too_long_machine_name", kAdTestUser,
+ "password");
+ EXPECT_TRUE(IsStepDisplayed("ad-join"));
+ js_checker().ExpectTrue(std::string(kAdMachineNameInput) + ".isInvalid");
+ js_checker().ExpectFalse(std::string(kAdUsernameInput) + ".isInvalid");
+ js_checker().ExpectFalse(std::string(kAdPasswordInput) + ".isInvalid");
+
+ // Checking error in case of bad username (without realm).
+ SubmitActiveDirectoryCredentials("machine_name", "test_user", "password");
+ EXPECT_TRUE(IsStepDisplayed("ad-join"));
+ js_checker().ExpectFalse(std::string(kAdMachineNameInput) + ".isInvalid");
+ js_checker().ExpectTrue(std::string(kAdUsernameInput) + ".isInvalid");
+ js_checker().ExpectFalse(std::string(kAdPasswordInput) + ".isInvalid");
+
+ // We have to remove the enrollment_helper before the dtor gets called.
+ enrollment_screen()->enrollment_helper_.reset();
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/enrollment/enrollment_screen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698