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

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

Issue 782483002: DeviceCloudPolicyStore should load consumer policies so that other classes may function normally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/policy/device_cloud_policy_store_chromeos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc
diff --git a/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc b/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc
index e6e47a7adacd418e882020b83ebc99f477322eb6..d047b2ea310a2cb8f8c0b95c8f178506faacc943 100644
--- a/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc
+++ b/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc
@@ -20,10 +20,14 @@
#include "chromeos/cryptohome/cryptohome_util.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_cryptohome_client.h"
+#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "content/public/test/test_utils.h"
#include "policy/policy_constants.h"
+#include "policy/proto/device_management_backend.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace em = enterprise_management;
+
namespace policy {
namespace {
@@ -68,6 +72,16 @@ class DeviceCloudPolicyStoreChromeOSTest
ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, result);
}
+ void SetManagementModeAndLoad(em::PolicyData::ManagementMode mode) {
+ device_policy_.policy_data().set_management_mode(mode);
+ device_policy_.Build();
+ device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob());
+ device_settings_service_.Load();
+ FlushDeviceSettings();
+ EXPECT_EQ(chromeos::DeviceSettingsService::STORE_SUCCESS,
+ device_settings_service_.status());
+ }
+
void ExpectFailure(CloudPolicyStore::Status expected_status) {
EXPECT_EQ(expected_status, store_->status());
EXPECT_TRUE(store_->is_initialized());
@@ -75,6 +89,17 @@ class DeviceCloudPolicyStoreChromeOSTest
EXPECT_FALSE(store_->is_managed());
}
+ void ExpectSuccessWithManagementMode(ManagementMode mode) {
+ EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status());
+ EXPECT_TRUE(store_->is_initialized());
+ EXPECT_TRUE(store_->has_policy());
+ EXPECT_TRUE(store_->is_managed());
+ EXPECT_TRUE(store_->policy());
+ EXPECT_TRUE(store_->policy_map().empty());
+ if (store_->policy())
+ EXPECT_EQ(mode, GetManagementMode(*store_->policy()));
+ }
+
void ExpectSuccess() {
EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status());
EXPECT_TRUE(store_->is_initialized());
@@ -153,6 +178,17 @@ TEST_F(DeviceCloudPolicyStoreChromeOSTest, LoadSuccess) {
ExpectSuccess();
}
+TEST_F(DeviceCloudPolicyStoreChromeOSTest, UpdateFromServiceOnConsumerDevices) {
+ ResetToNonEnterprise();
+
+ SetManagementModeAndLoad(em::PolicyData::CONSUMER_MANAGED);
+ ExpectSuccessWithManagementMode(MANAGEMENT_MODE_CONSUMER_MANAGED);
+
+ // Unenroll from consumer management.
+ SetManagementModeAndLoad(em::PolicyData::LOCAL_OWNER);
+ ExpectSuccessWithManagementMode(MANAGEMENT_MODE_LOCAL_OWNER);
+}
+
TEST_F(DeviceCloudPolicyStoreChromeOSTest, StoreSuccess) {
PrepareExistingPolicy();
store_->Store(device_policy_.policy());
« no previous file with comments | « chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698