Commit 346b5074 authored by tnagel's avatar tnagel Committed by Commit bot

Delete obsolete AllowedDeviceModes enrollment parameter.

Also remove (apparently obsolete) code to tolerate unset device mode in
registration responses.

BUG=none

Review-Url: https://codereview.chromium.org/2329303002
Cr-Commit-Position: refs/heads/master@{#417977}
parent c16476de
...@@ -157,16 +157,12 @@ void EnterpriseEnrollmentHelperImpl::DoEnroll(const std::string& token) { ...@@ -157,16 +157,12 @@ void EnterpriseEnrollmentHelperImpl::DoEnroll(const std::string& token) {
return; return;
} }
policy::DeviceCloudPolicyInitializer::AllowedDeviceModes device_modes;
device_modes[policy::DEVICE_MODE_ENTERPRISE] = true;
connector->ScheduleServiceInitialization(0); connector->ScheduleServiceInitialization(0);
policy::DeviceCloudPolicyInitializer* dcp_initializer = policy::DeviceCloudPolicyInitializer* dcp_initializer =
connector->GetDeviceCloudPolicyInitializer(); connector->GetDeviceCloudPolicyInitializer();
CHECK(dcp_initializer); CHECK(dcp_initializer);
dcp_initializer->StartEnrollment( dcp_initializer->StartEnrollment(
connector->device_management_service(), enrollment_config_, token, connector->device_management_service(), enrollment_config_, token,
device_modes,
base::Bind(&EnterpriseEnrollmentHelperImpl::OnEnrollmentFinished, base::Bind(&EnterpriseEnrollmentHelperImpl::OnEnrollmentFinished,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
......
...@@ -110,7 +110,6 @@ void DeviceCloudPolicyInitializer::StartEnrollment( ...@@ -110,7 +110,6 @@ void DeviceCloudPolicyInitializer::StartEnrollment(
DeviceManagementService* device_management_service, DeviceManagementService* device_management_service,
const EnrollmentConfig& enrollment_config, const EnrollmentConfig& enrollment_config,
const std::string& auth_token, const std::string& auth_token,
const AllowedDeviceModes& allowed_device_modes,
const EnrollmentCallback& enrollment_callback) { const EnrollmentCallback& enrollment_callback) {
DCHECK(is_initialized_); DCHECK(is_initialized_);
DCHECK(!enrollment_handler_); DCHECK(!enrollment_handler_);
...@@ -121,7 +120,6 @@ void DeviceCloudPolicyInitializer::StartEnrollment( ...@@ -121,7 +120,6 @@ void DeviceCloudPolicyInitializer::StartEnrollment(
attestation_flow_.get(), CreateClient(device_management_service), attestation_flow_.get(), CreateClient(device_management_service),
background_task_runner_, enrollment_config, auth_token, background_task_runner_, enrollment_config, auth_token,
install_attributes_->GetDeviceId(), manager_->GetDeviceRequisition(), install_attributes_->GetDeviceId(), manager_->GetDeviceRequisition(),
allowed_device_modes,
base::Bind(&DeviceCloudPolicyInitializer::EnrollmentCompleted, base::Bind(&DeviceCloudPolicyInitializer::EnrollmentCompleted,
base::Unretained(this), enrollment_callback))); base::Unretained(this), enrollment_callback)));
enrollment_handler_->StartEnrollment(); enrollment_handler_->StartEnrollment();
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_ #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_INITIALIZER_H_
#include <bitset>
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -50,7 +49,6 @@ class EnterpriseInstallAttributes; ...@@ -50,7 +49,6 @@ class EnterpriseInstallAttributes;
// handles the enrollment process. // handles the enrollment process.
class DeviceCloudPolicyInitializer : public CloudPolicyStore::Observer { class DeviceCloudPolicyInitializer : public CloudPolicyStore::Observer {
public: public:
typedef std::bitset<32> AllowedDeviceModes;
typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback; typedef base::Callback<void(EnrollmentStatus)> EnrollmentCallback;
// |background_task_runner| is used to execute long-running background tasks // |background_task_runner| is used to execute long-running background tasks
...@@ -74,13 +72,10 @@ class DeviceCloudPolicyInitializer : public CloudPolicyStore::Observer { ...@@ -74,13 +72,10 @@ class DeviceCloudPolicyInitializer : public CloudPolicyStore::Observer {
// Starts enrollment or re-enrollment. Once the enrollment process completes, // Starts enrollment or re-enrollment. Once the enrollment process completes,
// |enrollment_callback| is invoked and gets passed the status of the // |enrollment_callback| is invoked and gets passed the status of the
// operation. // operation.
// |allowed_modes| specifies acceptable DEVICE_MODE_* constants for
// enrollment.
virtual void StartEnrollment( virtual void StartEnrollment(
DeviceManagementService* device_management_service, DeviceManagementService* device_management_service,
const EnrollmentConfig& enrollment_config, const EnrollmentConfig& enrollment_config,
const std::string& auth_token, const std::string& auth_token,
const AllowedDeviceModes& allowed_modes,
const EnrollmentCallback& enrollment_callback); const EnrollmentCallback& enrollment_callback);
// Get the enrollment configuration that has been set up via signals such as // Get the enrollment configuration that has been set up via signals such as
......
...@@ -428,6 +428,8 @@ class DeviceCloudPolicyManagerChromeOSEnrollmentTest ...@@ -428,6 +428,8 @@ class DeviceCloudPolicyManagerChromeOSEnrollmentTest
register_response_.mutable_register_response()->set_device_management_token( register_response_.mutable_register_response()->set_device_management_token(
PolicyBuilder::kFakeToken); PolicyBuilder::kFakeToken);
register_response_.mutable_register_response()->set_enrollment_type(
em::DeviceRegisterResponse::ENTERPRISE);
policy_fetch_response_.mutable_policy_response()->add_response()->CopyFrom( policy_fetch_response_.mutable_policy_response()->add_response()->CopyFrom(
device_policy_.policy()); device_policy_.policy());
robot_auth_fetch_response_.mutable_service_api_access_response() robot_auth_fetch_response_.mutable_service_api_access_response()
...@@ -481,8 +483,6 @@ class DeviceCloudPolicyManagerChromeOSEnrollmentTest ...@@ -481,8 +483,6 @@ class DeviceCloudPolicyManagerChromeOSEnrollmentTest
.Times(AtMost(1)) .Times(AtMost(1))
.WillOnce( .WillOnce(
DoAll(SaveArg<4>(&client_id_), SaveArg<5>(&register_request_))); DoAll(SaveArg<4>(&client_id_), SaveArg<5>(&register_request_)));
DeviceCloudPolicyInitializer::AllowedDeviceModes modes;
modes[DEVICE_MODE_ENTERPRISE] = true;
chromeos::OwnerSettingsServiceChromeOS* owner_settings_service = chromeos::OwnerSettingsServiceChromeOS* owner_settings_service =
chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(
...@@ -496,7 +496,7 @@ class DeviceCloudPolicyManagerChromeOSEnrollmentTest ...@@ -496,7 +496,7 @@ class DeviceCloudPolicyManagerChromeOSEnrollmentTest
: EnrollmentConfig::MODE_MANUAL; : EnrollmentConfig::MODE_MANUAL;
std::string token = with_cert ? "" : "auth token"; std::string token = with_cert ? "" : "auth token";
initializer_->StartEnrollment( initializer_->StartEnrollment(
&device_management_service_, enrollment_config, token, modes, &device_management_service_, enrollment_config, token,
base::Bind(&DeviceCloudPolicyManagerChromeOSEnrollmentTest::Done, base::Bind(&DeviceCloudPolicyManagerChromeOSEnrollmentTest::Done,
base::Unretained(this))); base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
......
...@@ -79,7 +79,6 @@ EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS( ...@@ -79,7 +79,6 @@ EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS(
const std::string& auth_token, const std::string& auth_token,
const std::string& client_id, const std::string& client_id,
const std::string& requisition, const std::string& requisition,
const AllowedDeviceModes& allowed_device_modes,
const EnrollmentCallback& completion_callback) const EnrollmentCallback& completion_callback)
: store_(store), : store_(store),
install_attributes_(install_attributes), install_attributes_(install_attributes),
...@@ -91,7 +90,6 @@ EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS( ...@@ -91,7 +90,6 @@ EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS(
auth_token_(auth_token), auth_token_(auth_token),
client_id_(client_id), client_id_(client_id),
requisition_(requisition), requisition_(requisition),
allowed_device_modes_(allowed_device_modes),
completion_callback_(completion_callback), completion_callback_(completion_callback),
device_mode_(DEVICE_MODE_NOT_SET), device_mode_(DEVICE_MODE_NOT_SET),
skip_robot_auth_(false), skip_robot_auth_(false),
...@@ -184,9 +182,7 @@ void EnrollmentHandlerChromeOS::OnRegistrationStateChanged( ...@@ -184,9 +182,7 @@ void EnrollmentHandlerChromeOS::OnRegistrationStateChanged(
if (enrollment_step_ == STEP_REGISTRATION && client_->is_registered()) { if (enrollment_step_ == STEP_REGISTRATION && client_->is_registered()) {
enrollment_step_ = STEP_POLICY_FETCH, enrollment_step_ = STEP_POLICY_FETCH,
device_mode_ = client_->device_mode(); device_mode_ = client_->device_mode();
if (device_mode_ == DEVICE_MODE_NOT_SET) if (device_mode_ != policy::DEVICE_MODE_ENTERPRISE) {
device_mode_ = DEVICE_MODE_ENTERPRISE;
if (!allowed_device_modes_.test(device_mode_)) {
LOG(ERROR) << "Bad device mode " << device_mode_; LOG(ERROR) << "Bad device mode " << device_mode_;
ReportResult(EnrollmentStatus::ForStatus( ReportResult(EnrollmentStatus::ForStatus(
EnrollmentStatus::STATUS_REGISTRATION_BAD_MODE)); EnrollmentStatus::STATUS_REGISTRATION_BAD_MODE));
......
...@@ -52,16 +52,11 @@ class EnrollmentHandlerChromeOS : public CloudPolicyClient::Observer, ...@@ -52,16 +52,11 @@ class EnrollmentHandlerChromeOS : public CloudPolicyClient::Observer,
public CloudPolicyStore::Observer, public CloudPolicyStore::Observer,
public gaia::GaiaOAuthClient::Delegate { public gaia::GaiaOAuthClient::Delegate {
public: public:
typedef DeviceCloudPolicyInitializer::AllowedDeviceModes
AllowedDeviceModes;
typedef DeviceCloudPolicyInitializer::EnrollmentCallback typedef DeviceCloudPolicyInitializer::EnrollmentCallback
EnrollmentCallback; EnrollmentCallback;
// |store| and |install_attributes| must remain valid for the life time of the // |store| and |install_attributes| must remain valid for the life time of the
// enrollment handler. |allowed_device_modes| determines what device modes // enrollment handler.
// are acceptable. If the mode specified by the server is not acceptable,
// enrollment will fail with an EnrollmentStatus indicating
// STATUS_REGISTRATION_BAD_MODE.
EnrollmentHandlerChromeOS( EnrollmentHandlerChromeOS(
DeviceCloudPolicyStoreChromeOS* store, DeviceCloudPolicyStoreChromeOS* store,
EnterpriseInstallAttributes* install_attributes, EnterpriseInstallAttributes* install_attributes,
...@@ -73,7 +68,6 @@ class EnrollmentHandlerChromeOS : public CloudPolicyClient::Observer, ...@@ -73,7 +68,6 @@ class EnrollmentHandlerChromeOS : public CloudPolicyClient::Observer,
const std::string& auth_token, const std::string& auth_token,
const std::string& client_id, const std::string& client_id,
const std::string& requisition, const std::string& requisition,
const AllowedDeviceModes& allowed_device_modes,
const EnrollmentCallback& completion_callback); const EnrollmentCallback& completion_callback);
~EnrollmentHandlerChromeOS() override; ~EnrollmentHandlerChromeOS() override;
...@@ -177,7 +171,6 @@ class EnrollmentHandlerChromeOS : public CloudPolicyClient::Observer, ...@@ -177,7 +171,6 @@ class EnrollmentHandlerChromeOS : public CloudPolicyClient::Observer,
std::string auth_token_; std::string auth_token_;
std::string client_id_; std::string client_id_;
std::string requisition_; std::string requisition_;
AllowedDeviceModes allowed_device_modes_;
EnrollmentCallback completion_callback_; EnrollmentCallback completion_callback_;
// The current state key provided by |state_keys_broker_|. // The current state key provided by |state_keys_broker_|.
......
...@@ -38,7 +38,6 @@ void FakeDeviceCloudPolicyInitializer::StartEnrollment( ...@@ -38,7 +38,6 @@ void FakeDeviceCloudPolicyInitializer::StartEnrollment(
DeviceManagementService* device_management_service, DeviceManagementService* device_management_service,
const EnrollmentConfig& enrollment_config, const EnrollmentConfig& enrollment_config,
const std::string& auth_token, const std::string& auth_token,
const AllowedDeviceModes& allowed_modes,
const EnrollmentCallback& enrollment_callback) { const EnrollmentCallback& enrollment_callback) {
was_start_enrollment_called_ = true; was_start_enrollment_called_ = true;
enrollment_callback.Run(enrollment_status_); enrollment_callback.Run(enrollment_status_);
......
...@@ -28,7 +28,6 @@ class FakeDeviceCloudPolicyInitializer : public DeviceCloudPolicyInitializer { ...@@ -28,7 +28,6 @@ class FakeDeviceCloudPolicyInitializer : public DeviceCloudPolicyInitializer {
DeviceManagementService* device_management_service, DeviceManagementService* device_management_service,
const EnrollmentConfig& enrollment_config, const EnrollmentConfig& enrollment_config,
const std::string& auth_token, const std::string& auth_token,
const AllowedDeviceModes& allowed_modes,
const EnrollmentCallback& enrollment_callback) override; const EnrollmentCallback& enrollment_callback) override;
bool was_start_enrollment_called() { bool was_start_enrollment_called() {
......
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