Commit cea9e0d5 authored by mnissler@chromium.org's avatar mnissler@chromium.org

Revert 98987 - Pass user_affiliation request parameter on user cloud policy requests.

BUG=chromium-os:17809
TEST=Enroll device, login as an enterprise user, check user_affiliation parameter in policy requests.

Review URL: http://codereview.chromium.org/7810025

TBR=mnissler@chromium.org
Review URL: http://codereview.chromium.org/7785032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98989 0039d316-1c4b-4281-b951-d872f2087c98
parent bd1a1a4b
......@@ -213,8 +213,6 @@ void BrowserPolicyConnector::InitializeUserPolicy(const std::string& user_name,
user_policy_token_cache_->Load();
user_data_store_->set_user_name(user_name);
user_data_store_->set_user_affiliation(GetUserAffiliation(user_name));
if (token_service_ &&
token_service_->HasTokenForService(
GaiaConstants::kDeviceManagementService)) {
......@@ -339,21 +337,6 @@ void BrowserPolicyConnector::InitializeDevicePolicySubsystem() {
#endif
}
CloudPolicyDataStore::UserAffiliation
BrowserPolicyConnector::GetUserAffiliation(const std::string& user_name) {
#if defined(OS_CHROMEOS)
if (install_attributes_.get()) {
size_t pos = user_name.find('@');
if (pos != std::string::npos &&
user_name.substr(pos + 1) == install_attributes_->GetDomain()) {
return CloudPolicyDataStore::USER_AFFILIATION_MANAGED;
}
}
#endif
return CloudPolicyDataStore::USER_AFFILIATION_NONE;
}
// static
BrowserPolicyConnector* BrowserPolicyConnector::CreateForTests() {
const ConfigurationPolicyProvider::PolicyDefinitionList*
......
......@@ -12,7 +12,6 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/task.h"
#include "chrome/browser/policy/cloud_policy_data_store.h"
#include "chrome/browser/policy/enterprise_install_attributes.h"
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
......@@ -135,11 +134,6 @@ class BrowserPolicyConnector : public NotificationObserver {
// be running.
void InitializeDevicePolicySubsystem();
// Works out the user affiliation by checking the given |user_name| against
// the installation attributes.
policy::CloudPolicyDataStore::UserAffiliation GetUserAffiliation(
const std::string& user_name);
static BrowserPolicyConnector* CreateForTests();
static ConfigurationPolicyProvider* CreateManagedPlatformProvider();
static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider();
......
......@@ -257,7 +257,6 @@ void CloudPolicyController::SendPolicyRequest() {
backend_->ProcessPolicyRequest(data_store_->device_token(),
data_store_->device_id(),
data_store_->user_affiliation(),
policy_request, this);
}
......
......@@ -20,12 +20,12 @@
namespace policy {
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::AtLeast;
using ::testing::InSequence;
using ::testing::Mock;
using ::testing::Return;
using ::testing::_;
class MockDeviceTokenFetcher : public DeviceTokenFetcher {
public:
......@@ -104,7 +104,7 @@ class CloudPolicyControllerTest : public testing::Test {
TEST_F(CloudPolicyControllerTest, StartupWithDeviceToken) {
data_store_->SetupForTesting("fake_device_token", "device_id", "", "",
true);
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce(DoAll(
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(DoAll(
InvokeWithoutArgs(this, &CloudPolicyControllerTest::StopMessageLoop),
MockDeviceManagementBackendSucceedSpdyCloudPolicy()));
CreateNewController();
......@@ -140,9 +140,9 @@ TEST_F(CloudPolicyControllerTest, RefreshAfterSuccessfulPolicy) {
"auth_token", true);
{
InSequence s;
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce(
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
MockDeviceManagementBackendSucceedSpdyCloudPolicy());
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce(DoAll(
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(DoAll(
InvokeWithoutArgs(this, &CloudPolicyControllerTest::StopMessageLoop),
MockDeviceManagementBackendFailPolicy(
DeviceManagementBackend::kErrorRequestFailed)));
......@@ -159,10 +159,10 @@ TEST_F(CloudPolicyControllerTest, RefreshAfterError) {
"auth_token", true);
{
InSequence s;
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce(
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
MockDeviceManagementBackendFailPolicy(
DeviceManagementBackend::kErrorRequestFailed));
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce(DoAll(
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(DoAll(
InvokeWithoutArgs(this,
&CloudPolicyControllerTest::StopMessageLoop),
MockDeviceManagementBackendSucceedSpdyCloudPolicy()));
......@@ -177,7 +177,7 @@ TEST_F(CloudPolicyControllerTest, RefreshAfterError) {
TEST_F(CloudPolicyControllerTest, InvalidToken) {
data_store_->SetupForTesting("device_token", "device_id",
"standup@ten.am", "auth", true);
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce(
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
MockDeviceManagementBackendFailPolicy(
DeviceManagementBackend::kErrorServiceManagementTokenInvalid));
EXPECT_CALL(*token_fetcher_.get(), FetchToken()).Times(1);
......@@ -190,7 +190,7 @@ TEST_F(CloudPolicyControllerTest, InvalidToken) {
TEST_F(CloudPolicyControllerTest, DeviceNotFound) {
data_store_->SetupForTesting("device_token", "device_id",
"me@you.com", "auth", true);
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce(
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
MockDeviceManagementBackendFailPolicy(
DeviceManagementBackend::kErrorServiceDeviceNotFound));
EXPECT_CALL(*token_fetcher_.get(), FetchToken()).Times(1);
......@@ -204,7 +204,7 @@ TEST_F(CloudPolicyControllerTest, DeviceNotFound) {
TEST_F(CloudPolicyControllerTest, NoLongerManaged) {
data_store_->SetupForTesting("device_token", "device_id",
"who@what.com", "auth", true);
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce(
EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
MockDeviceManagementBackendFailPolicy(
DeviceManagementBackend::kErrorServiceManagementNotSupported));
EXPECT_CALL(*token_fetcher_.get(), SetUnmanagedState()).Times(1);
......
......@@ -83,8 +83,7 @@ CloudPolicyDataStore::CloudPolicyDataStore(
const std::string& policy_type,
const std::string& machine_model,
const std::string& machine_id)
: user_affiliation_(USER_AFFILIATION_NONE),
policy_register_type_(policy_register_type),
: policy_register_type_(policy_register_type),
policy_type_(policy_type),
machine_model_(machine_model),
machine_id_(machine_id),
......@@ -149,11 +148,6 @@ void CloudPolicyDataStore::set_user_name(const std::string& user_name) {
user_name_ = user_name;
}
void CloudPolicyDataStore::set_user_affiliation(
UserAffiliation user_affiliation) {
user_affiliation_ = user_affiliation;
}
const std::string& CloudPolicyDataStore::device_token() const {
return device_token_;
}
......@@ -195,11 +189,6 @@ const std::string& CloudPolicyDataStore::user_name() const {
return user_name_;
}
const CloudPolicyDataStore::UserAffiliation
CloudPolicyDataStore::user_affiliation() const {
return user_affiliation_;
}
void CloudPolicyDataStore::AddObserver(
CloudPolicyDataStore::Observer* observer) {
observer_list_.AddObserver(observer);
......
......@@ -34,15 +34,6 @@ class CloudPolicyDataStore {
virtual void OnCredentialsChanged() = 0;
};
// Describes the affilitation of a user w.r.t. the managed state of the
// device.
enum UserAffiliation {
// User is on the same domain the device was registered with.
USER_AFFILIATION_MANAGED,
// No affiliation between device and user user.
USER_AFFILIATION_NONE,
};
~CloudPolicyDataStore();
// Create CloudPolicyData with constants initialized for fetching user
......@@ -77,7 +68,6 @@ class CloudPolicyDataStore {
void set_device_id(const std::string& device_id);
void set_user_name(const std::string& user_name);
void set_user_affiliation(UserAffiliation user_affiliation);
const std::string& device_id() const;
const std::string& device_token() const;
......@@ -90,7 +80,6 @@ class CloudPolicyDataStore {
const std::string& policy_type() const;
bool token_cache_loaded() const;
const std::string& user_name() const;
const UserAffiliation user_affiliation() const;
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
......@@ -112,7 +101,6 @@ class CloudPolicyDataStore {
// Data necessary for constructing policy requests.
std::string device_token_;
UserAffiliation user_affiliation_;
// Constants that won't change over the life-time of a cloud policy
// subsystem.
......
......@@ -10,7 +10,6 @@
#include "base/basictypes.h"
#include "base/threading/non_thread_safe.h"
#include "chrome/browser/policy/cloud_policy_data_store.h"
#include "chrome/browser/policy/proto/device_management_backend.pb.h"
namespace policy {
......@@ -107,7 +106,6 @@ class DeviceManagementBackend : base::NonThreadSafe {
virtual void ProcessPolicyRequest(
const std::string& device_management_token,
const std::string& device_id,
CloudPolicyDataStore::UserAffiliation user_affiliation,
const em::DevicePolicyRequest& request,
DevicePolicyResponseDelegate* delegate) = 0;
......
......@@ -34,8 +34,6 @@ const char DeviceManagementBackendImpl::kParamDeviceType[] = "devicetype";
const char DeviceManagementBackendImpl::kParamOAuthToken[] = "oauth_token";
const char DeviceManagementBackendImpl::kParamPlatform[] = "platform";
const char DeviceManagementBackendImpl::kParamRequest[] = "request";
const char DeviceManagementBackendImpl::kParamUserAffiliation[] =
"user_affiliation";
// String constants for the device and app type we report to the server.
const char DeviceManagementBackendImpl::kValueAppType[] = "Chrome";
......@@ -44,9 +42,6 @@ const char DeviceManagementBackendImpl::kValueRequestPolicy[] = "policy";
const char DeviceManagementBackendImpl::kValueRequestRegister[] = "register";
const char DeviceManagementBackendImpl::kValueRequestUnregister[] =
"unregister";
const char DeviceManagementBackendImpl::kValueUserAffiliationManaged[] =
"managed";
const char DeviceManagementBackendImpl::kValueUserAffiliationNone[] = "none";
namespace {
......@@ -76,6 +71,7 @@ const int kPolicyNotFound = 902; // This error is not sent as HTTP status code.
const int kPendingApprovalLegacy = 491;
const int kDeviceNotFoundLegacy = 901;
#if defined(OS_CHROMEOS)
// Machine info keys.
const char kMachineInfoHWClass[] = "hardware_class";
......@@ -388,7 +384,6 @@ class DeviceManagementPolicyJob : public DeviceManagementJobBase {
DeviceManagementBackendImpl* backend_impl,
const std::string& device_management_token,
const std::string& device_id,
const std::string& user_affiliation,
const em::DevicePolicyRequest& request,
DeviceManagementBackend::DevicePolicyResponseDelegate* delegate)
: DeviceManagementJobBase(
......@@ -397,8 +392,6 @@ class DeviceManagementPolicyJob : public DeviceManagementJobBase {
device_id),
delegate_(delegate) {
SetDeviceManagementToken(device_management_token);
SetQueryParam(DeviceManagementBackendImpl::kParamUserAffiliation,
user_affiliation);
em::DeviceManagementRequest request_wrapper;
request_wrapper.mutable_policy_request()->CopyFrom(request);
SetPayload(request_wrapper);
......@@ -545,27 +538,12 @@ void DeviceManagementBackendImpl::ProcessUnregisterRequest(
void DeviceManagementBackendImpl::ProcessPolicyRequest(
const std::string& device_management_token,
const std::string& device_id,
CloudPolicyDataStore::UserAffiliation affiliation,
const em::DevicePolicyRequest& request,
DevicePolicyResponseDelegate* delegate) {
UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchRequested,
kMetricPolicySize);
AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id,
UserAffiliationToString(affiliation),
request, delegate));
}
// static
const char* DeviceManagementBackendImpl::UserAffiliationToString(
CloudPolicyDataStore::UserAffiliation affiliation) {
switch (affiliation) {
case CloudPolicyDataStore::USER_AFFILIATION_MANAGED:
return kValueUserAffiliationManaged;
case CloudPolicyDataStore::USER_AFFILIATION_NONE:
return kValueUserAffiliationNone;
}
NOTREACHED();
return kValueUserAffiliationNone;
}
} // namespace policy
......@@ -35,7 +35,6 @@ class DeviceManagementBackendImpl : public DeviceManagementBackend {
static const char kParamOAuthToken[];
static const char kParamPlatform[];
static const char kParamRequest[];
static const char kParamUserAffiliation[];
// String constants for the device and app type we report to the server.
static const char kValueAppType[];
......@@ -43,8 +42,6 @@ class DeviceManagementBackendImpl : public DeviceManagementBackend {
static const char kValueRequestPolicy[];
static const char kValueRequestRegister[];
static const char kValueRequestUnregister[];
static const char kValueUserAffiliationManaged[];
static const char kValueUserAffiliationNone[];
private:
friend class DeviceManagementJobBase;
......@@ -73,14 +70,9 @@ class DeviceManagementBackendImpl : public DeviceManagementBackend {
virtual void ProcessPolicyRequest(
const std::string& device_management_token,
const std::string& device_id,
CloudPolicyDataStore::UserAffiliation affiliation,
const em::DevicePolicyRequest& request,
DevicePolicyResponseDelegate* response_delegate);
// Converts a user affiliation to the appropriate query parameter value.
static const char* UserAffiliationToString(
CloudPolicyDataStore::UserAffiliation affiliation);
// Keeps track of the jobs currently in flight.
JobSet pending_jobs_;
......
......@@ -119,9 +119,7 @@ IN_PROC_BROWSER_TEST_F(DeviceManagementServiceIntegrationTest,
em::DevicePolicySettingRequest* setting_request =
request.add_setting_request();
setting_request->set_key(kChromeDevicePolicySettingKey);
backend->ProcessPolicyRequest(token_, "testid",
CloudPolicyDataStore::USER_AFFILIATION_NONE,
request, &delegate);
backend->ProcessPolicyRequest(token_, "testid", request, &delegate);
MessageLoop::current()->Run();
}
......@@ -172,9 +170,7 @@ IN_PROC_BROWSER_TEST_F(DeviceManagementServiceIntegrationTest,
em::PolicyFetchRequest* fetch_request = request.add_request();
fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA);
fetch_request->set_policy_type(kChromeUserPolicyType);
backend->ProcessPolicyRequest(token_, "testid",
CloudPolicyDataStore::USER_AFFILIATION_NONE,
request, &delegate);
backend->ProcessPolicyRequest(token_, "testid", request, &delegate);
MessageLoop::current()->Run();
}
......
......@@ -143,9 +143,7 @@ TEST_P(DeviceManagementServiceFailedRequestTest, PolicyRequest) {
em::DevicePolicySettingRequest* setting_request =
request.add_setting_request();
setting_request->set_key(kChromeDevicePolicySettingKey);
backend_->ProcessPolicyRequest(kDMToken, kDeviceId,
CloudPolicyDataStore::USER_AFFILIATION_NONE,
request, &mock);
backend_->ProcessPolicyRequest(kDMToken, kDeviceId, request, &mock);
TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
ASSERT_TRUE(fetcher);
......@@ -413,9 +411,7 @@ TEST_F(DeviceManagementServiceTest, CancelPolicyRequest) {
request.add_setting_request();
setting_request->set_key(kChromeDevicePolicySettingKey);
setting_request->set_watermark("stale");
backend_->ProcessPolicyRequest(kDMToken, kDeviceId,
CloudPolicyDataStore::USER_AFFILIATION_NONE,
request, &mock);
backend_->ProcessPolicyRequest(kDMToken, kDeviceId, request, &mock);
TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
ASSERT_TRUE(fetcher);
......@@ -467,9 +463,7 @@ TEST_F(DeviceManagementServiceTest, CancelRequestAfterShutdown) {
request.add_setting_request();
setting_request->set_key(kChromeDevicePolicySettingKey);
setting_request->set_watermark("stale");
backend_->ProcessPolicyRequest(kDMToken, kDeviceId,
CloudPolicyDataStore::USER_AFFILIATION_NONE,
request, &mock);
backend_->ProcessPolicyRequest(kDMToken, kDeviceId, request, &mock);
TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
ASSERT_TRUE(fetcher);
......
......@@ -76,9 +76,7 @@ class DeviceManagementBackendTestHelper {
DevicePolicyResponseDelegateMock delegate;
EXPECT_CALL(delegate, OnError(_)).Times(AnyNumber());
EXPECT_CALL(delegate, HandlePolicyResponse(_)).Times(AnyNumber());
backend_->ProcessPolicyRequest("token", "testid",
CloudPolicyDataStore::USER_AFFILIATION_NONE,
request, &delegate);
backend_->ProcessPolicyRequest("token", "testid", request, &delegate);
}
void UnmockCreateBackend() {
......
......@@ -44,10 +44,9 @@ class MockDeviceManagementBackend : public DeviceManagementBackend {
const em::DeviceUnregisterRequest& request,
DeviceUnregisterResponseDelegate* delegate));
MOCK_METHOD5(ProcessPolicyRequest, void(
MOCK_METHOD4(ProcessPolicyRequest, void(
const std::string& device_management_token,
const std::string& device_id,
CloudPolicyDataStore::UserAffiliation affiliation,
const em::DevicePolicyRequest& request,
DevicePolicyResponseDelegate* delegate));
......@@ -84,7 +83,7 @@ ACTION(MockDeviceManagementBackendSucceedSpdyCloudPolicy) {
// implementing support for signature verification).
fetch_response->set_policy_data_signature("TODO");
fetch_response->set_new_public_key("TODO");
arg4->HandlePolicyResponse(response);
arg3->HandlePolicyResponse(response);
}
ACTION_P(MockDeviceManagementBackendFailRegister, error) {
......@@ -92,7 +91,7 @@ ACTION_P(MockDeviceManagementBackendFailRegister, error) {
}
ACTION_P(MockDeviceManagementBackendFailPolicy, error) {
arg4->OnError(error);
arg3->OnError(error);
}
} // namespace policy
......
......@@ -30,15 +30,13 @@ void ProxyDeviceManagementBackend::ProcessUnregisterRequest(
backend_->ProcessUnregisterRequest(device_management_token, device_id,
request, delegate);
}
void ProxyDeviceManagementBackend::ProcessPolicyRequest(
const std::string& device_management_token,
const std::string& device_id,
CloudPolicyDataStore::UserAffiliation affiliation,
const em::DevicePolicyRequest& request,
DevicePolicyResponseDelegate* delegate) {
backend_->ProcessPolicyRequest(device_management_token, device_id,
affiliation, request, delegate);
request, delegate);
}
MockDeviceManagementService::MockDeviceManagementService()
......
......@@ -39,7 +39,6 @@ class ProxyDeviceManagementBackend : public DeviceManagementBackend {
virtual void ProcessPolicyRequest(
const std::string& device_management_token,
const std::string& device_id,
CloudPolicyDataStore::UserAffiliation affiliation,
const em::DevicePolicyRequest& request,
DevicePolicyResponseDelegate* delegate) OVERRIDE;
......
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