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

Unified Diff: chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc

Issue 60113002: Add a flag to skip robot token fetching for testing device enrollments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | « no previous file | chrome/common/chrome_switches.h » ('j') | chrome/common/chrome_switches.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
diff --git a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
index 49f97a8bbda6bc1442bdd9efaa97f9ba8f2ef80d..248956622e7761b64f4f398d9ec107de738835dc 100644
--- a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
+++ b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.h"
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/browser_process.h"
@@ -14,6 +15,7 @@
#include "chrome/browser/policy/cloud/cloud_policy_constants.h"
#include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h"
#include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
+#include "chrome/common/chrome_switches.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/http/http_status_code.h"
@@ -28,6 +30,11 @@ const int kLockRetryIntervalMs = 500;
// Maximum time to retry InstallAttrs initialization before we give up.
const int kLockRetryTimeoutMs = 10 * 60 * 1000; // 10 minutes.
+// Testing token used when the enrollment-skip-robot-auth is set to skip talking
+// to GAIA for an actual token. This is needed to be able to run against the
+// testing DMServer implementations.
+const char kTestingRobotToken[] = "test-token";
+
} // namespace
EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS(
@@ -187,6 +194,16 @@ void EnrollmentHandlerChromeOS::PolicyValidated(
username_ = validator->policy_data()->username();
device_id_ = validator->policy_data()->device_id();
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnrollmentSkipRobotAuth)) {
+ // For test purposes we allow enrollment to succeed without proper robot
+ // account and use the provided value as a token.
+ refresh_token_ = kTestingRobotToken;
+ enrollment_step_ = STEP_LOCK_DEVICE,
+ StartLockDevice(username_, device_mode_, device_id_);
+ return;
+ }
+
enrollment_step_ = STEP_ROBOT_AUTH_FETCH;
client_->FetchRobotAuthCodes(auth_token_);
} else {
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | chrome/common/chrome_switches.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698