Commit 54aab8f1 authored by Achuith Bhandarkar's avatar Achuith Bhandarkar Committed by Commit Bot

Support for fake enterprise enrollment.

* Add WizardController::SkipEnrollmentPromptsForTesting to skip
enrollment prompts.
* Do not automatically log in after enrollment.
* Some additional logging.

BUG=chromium:651249
TEST=enterprise_FakeEnrollment

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ie8516d3b97055c9435697a0071ddf66e5e7dac07
Reviewed-on: https://chromium-review.googlesource.com/696296Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Commit-Queue: Achuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505882}
parent c404009d
...@@ -351,7 +351,7 @@ void EnrollmentScreen::OnDeviceAttributeProvided(const std::string& asset_id, ...@@ -351,7 +351,7 @@ void EnrollmentScreen::OnDeviceAttributeProvided(const std::string& asset_id,
void EnrollmentScreen::OnDeviceAttributeUpdatePermission(bool granted) { void EnrollmentScreen::OnDeviceAttributeUpdatePermission(bool granted) {
// If user is permitted to update device attributes // If user is permitted to update device attributes
// Show attribute prompt screen // Show attribute prompt screen
if (granted) { if (granted && !WizardController::skip_enrollment_prompts()) {
// TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed.
LOG(WARNING) << "Show device attribute prompt screen"; LOG(WARNING) << "Show device attribute prompt screen";
StartupUtils::MarkDeviceRegistered( StartupUtils::MarkDeviceRegistered(
...@@ -405,7 +405,8 @@ void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { ...@@ -405,7 +405,8 @@ void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() {
retry_backoff_->InformOfRequest(true); retry_backoff_->InformOfRequest(true);
if (elapsed_timer_) if (elapsed_timer_)
UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_);
if (WizardController::UsingHandsOffEnrollment()) { if (WizardController::UsingHandsOffEnrollment() ||
WizardController::skip_enrollment_prompts()) {
OnConfirmationClosed(); OnConfirmationClosed();
} else { } else {
view_->ShowEnrollmentStatus( view_->ShowEnrollmentStatus(
......
...@@ -248,6 +248,9 @@ WizardController* WizardController::default_controller_ = nullptr; ...@@ -248,6 +248,9 @@ WizardController* WizardController::default_controller_ = nullptr;
// static // static
bool WizardController::skip_post_login_screens_ = false; bool WizardController::skip_post_login_screens_ = false;
// static
bool WizardController::skip_enrollment_prompts_ = false;
// static // static
bool WizardController::zero_delay_enabled_ = false; bool WizardController::zero_delay_enabled_ = false;
...@@ -1464,6 +1467,11 @@ void WizardController::SkipPostLoginScreensForTesting() { ...@@ -1464,6 +1467,11 @@ void WizardController::SkipPostLoginScreensForTesting() {
skip_post_login_screens_ = true; skip_post_login_screens_ = true;
} }
// static
void WizardController::SkipEnrollmentPromptsForTesting() {
skip_enrollment_prompts_ = true;
}
// static // static
bool WizardController::UsingHandsOffEnrollment() { bool WizardController::UsingHandsOffEnrollment() {
return policy::DeviceCloudPolicyManagerChromeOS:: return policy::DeviceCloudPolicyManagerChromeOS::
......
...@@ -71,6 +71,9 @@ class WizardController : public BaseScreenDelegate, ...@@ -71,6 +71,9 @@ class WizardController : public BaseScreenDelegate,
return skip_post_login_screens_; return skip_post_login_screens_;
} }
// Whether to skip any prompts that may be normally shown during enrollment.
static bool skip_enrollment_prompts() { return skip_enrollment_prompts_; }
// Sets delays to zero. MUST be used only for tests. // Sets delays to zero. MUST be used only for tests.
static void SetZeroDelays(); static void SetZeroDelays();
...@@ -84,6 +87,9 @@ class WizardController : public BaseScreenDelegate, ...@@ -84,6 +87,9 @@ class WizardController : public BaseScreenDelegate,
// Terms of Service, user image selection). // Terms of Service, user image selection).
static void SkipPostLoginScreensForTesting(); static void SkipPostLoginScreensForTesting();
// Skips any enrollment prompts that may be normally shown.
static void SkipEnrollmentPromptsForTesting();
// Returns true if OOBE is operating under the // Returns true if OOBE is operating under the
// Zero-Touch Hands-Off Enrollment Flow. // Zero-Touch Hands-Off Enrollment Flow.
static bool UsingHandsOffEnrollment(); static bool UsingHandsOffEnrollment();
...@@ -336,6 +342,8 @@ class WizardController : public BaseScreenDelegate, ...@@ -336,6 +342,8 @@ class WizardController : public BaseScreenDelegate,
static bool zero_delay_enabled_; static bool zero_delay_enabled_;
static bool skip_enrollment_prompts_;
// Screen that's currently active. // Screen that's currently active.
BaseScreen* current_screen_ = nullptr; BaseScreen* current_screen_ = nullptr;
......
...@@ -341,7 +341,6 @@ cr.define('cr.ui', function() { ...@@ -341,7 +341,6 @@ cr.define('cr.ui', function() {
waitForOobeScreen('oauth-enrollment', function() { waitForOobeScreen('oauth-enrollment', function() {
chrome.send('oauthEnrollCompleteLogin', [username, 'authcode']); chrome.send('oauthEnrollCompleteLogin', [username, 'authcode']);
chrome.send('completeLogin', [gaia_id, username, password, false]);
}); });
} }
}; };
......
...@@ -342,7 +342,6 @@ cr.define('cr.ui', function() { ...@@ -342,7 +342,6 @@ cr.define('cr.ui', function() {
waitForOobeScreen('oauth-enrollment', function() { waitForOobeScreen('oauth-enrollment', function() {
chrome.send('oauthEnrollCompleteLogin', [username, 'authcode']); chrome.send('oauthEnrollCompleteLogin', [username, 'authcode']);
chrome.send('completeLogin', [gaia_id, username, password, false]);
}); });
} }
}; };
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "chrome/browser/chromeos/login/help_app_launcher.h" #include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/chromeos/login/oobe_screen.h" #include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/network_error.h" #include "chrome/browser/chromeos/login/screens/network_error.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
...@@ -535,7 +536,9 @@ void EnrollmentScreenHandler::HideOfflineMessage( ...@@ -535,7 +536,9 @@ void EnrollmentScreenHandler::HideOfflineMessage(
// EnrollmentScreenHandler, private ----------------------------- // EnrollmentScreenHandler, private -----------------------------
void EnrollmentScreenHandler::HandleToggleFakeEnrollment() { void EnrollmentScreenHandler::HandleToggleFakeEnrollment() {
VLOG(1) << "HandleToggleFakeEnrollment";
policy::PolicyOAuth2TokenFetcher::UseFakeTokensForTesting(); policy::PolicyOAuth2TokenFetcher::UseFakeTokensForTesting();
WizardController::SkipEnrollmentPromptsForTesting();
} }
void EnrollmentScreenHandler::HandleClose(const std::string& reason) { void EnrollmentScreenHandler::HandleClose(const std::string& reason) {
...@@ -555,6 +558,7 @@ void EnrollmentScreenHandler::HandleClose(const std::string& reason) { ...@@ -555,6 +558,7 @@ void EnrollmentScreenHandler::HandleClose(const std::string& reason) {
void EnrollmentScreenHandler::HandleCompleteLogin( void EnrollmentScreenHandler::HandleCompleteLogin(
const std::string& user, const std::string& user,
const std::string& auth_code) { const std::string& auth_code) {
VLOG(1) << "HandleCompleteLogin";
observe_network_failure_ = false; observe_network_failure_ = false;
DCHECK(controller_); DCHECK(controller_);
controller_->OnLoginDone(gaia::SanitizeEmail(user), auth_code); controller_->OnLoginDone(gaia::SanitizeEmail(user), auth_code);
......
...@@ -665,6 +665,7 @@ void GaiaScreenHandler::HandleCompleteLogin(const std::string& gaia_id, ...@@ -665,6 +665,7 @@ void GaiaScreenHandler::HandleCompleteLogin(const std::string& gaia_id,
const std::string& typed_email, const std::string& typed_email,
const std::string& password, const std::string& password,
bool using_saml) { bool using_saml) {
VLOG(1) << "HandleCompleteLogin";
DoCompleteLogin(gaia_id, typed_email, password, using_saml); DoCompleteLogin(gaia_id, typed_email, password, using_saml);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment