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

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

Issue 2716383002: Add Active Directory enterprise enrollment/domain join tests (Closed)
Patch Set: 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..254723c5c712623b83caf82fc86343869dc46c07 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 ad_machine_name_input[] =
achuithb 2017/02/27 16:03:47 Shouldn't this be kAdMachineNameInput? Same for re
Roman Sorokin (ftl) 2017/02/27 16:20:48 yeah, my bad.
+ "document.querySelector('#oauth-enroll-ad-join-ui /deep/ "
+ "#machineNameInput')";
+const char ad_username_input[] =
+ "document.querySelector('#oauth-enroll-ad-join-ui /deep/ #userInput')";
+const char ad_password_input[] =
+ "document.querySelector('#oauth-enroll-ad-join-ui /deep/ #passwordInput')";
+const char ad_test_realm[] = "ad_test_realm.com";
+const char ad_test_user[] = "ad_test_user@ad_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,28 @@ class EnterpriseEnrollmentTest : public LoginManagerTest {
"}));");
}
+ void SubmitActiveDirectoryCredentials(const std::string& machine_name,
achuithb 2017/02/27 16:03:47 Function comment.
Roman Sorokin (ftl) 2017/02/27 16:20:49 Done.
+ const std::string& username,
+ const std::string& password) {
+ EXPECT_TRUE(IsStepDisplayed("ad-join"));
+ js_checker().ExpectFalse(std::string(ad_machine_name_input) + ".hidden");
+ js_checker().ExpectFalse(std::string(ad_username_input) + ".hidden");
+ js_checker().ExpectFalse(std::string(ad_password_input) + ".hidden");
+ const std::string set_machine_name =
+ std::string(ad_machine_name_input) + ".value = '" + machine_name + "'";
+ const std::string set_username =
+ std::string(ad_username_input) + ".value = '" + username + "'";
+ const std::string set_password =
+ std::string(ad_password_input) + ".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 +141,20 @@ class EnterpriseEnrollmentTest : public LoginManagerTest {
});
}
+ void SetupActiveDirectoryJoin() {
achuithb 2017/02/27 16:03:47 Function comment
Roman Sorokin (ftl) 2017/02/27 16:20:49 Done.
+ 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(ad_test_realm, 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,69 @@ 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", ad_test_user, "password");
achuithb 2017/02/27 16:03:47 Some more newlines in this test would help readabi
Roman Sorokin (ftl) 2017/02/27 16:20:49 Done.
+ 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", ad_test_user, "");
+ EXPECT_TRUE(IsStepDisplayed("ad-join"));
+ js_checker().ExpectFalse(std::string(ad_machine_name_input) + ".isInvalid");
+ js_checker().ExpectFalse(std::string(ad_username_input) + ".isInvalid");
+ js_checker().ExpectTrue(std::string(ad_password_input) + ".isInvalid");
+
+ // Checking error in case of too long machine name.
+ SubmitActiveDirectoryCredentials("too_long_machine_name", ad_test_user,
+ "password");
+ EXPECT_TRUE(IsStepDisplayed("ad-join"));
+ js_checker().ExpectTrue(std::string(ad_machine_name_input) + ".isInvalid");
+ js_checker().ExpectFalse(std::string(ad_username_input) + ".isInvalid");
+ js_checker().ExpectFalse(std::string(ad_password_input) + ".isInvalid");
+
+ // Checking error in case of bad username (without realm).
+ SubmitActiveDirectoryCredentials("machine_name", "ad_test_user", "password");
+ EXPECT_TRUE(IsStepDisplayed("ad-join"));
+ js_checker().ExpectFalse(std::string(ad_machine_name_input) + ".isInvalid");
+ js_checker().ExpectTrue(std::string(ad_username_input) + ".isInvalid");
+ js_checker().ExpectFalse(std::string(ad_password_input) + ".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