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

Unified Diff: chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc

Issue 985093002: Fix up Owner settings on first load (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: has_pending_changes -> HasPendingChanges Created 5 years, 9 months 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/ownership/owner_settings_service_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/ownership/owner_settings_service_chromeos_unittest.cc
diff --git a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc
index a06337e392af313fa0a01d4d4800c38b49a320ff..aa4d68909d788b970ec2f9686fbda4d0d03de51f 100644
--- a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc
+++ b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc
@@ -45,7 +45,7 @@ class PrefsChecker : public ownership::OwnerSettingsService::Observer {
// OwnerSettingsService::Observer implementation:
void OnSignedPolicyStored(bool success) override {
- if (service_->has_pending_changes())
+ if (service_->HasPendingChanges())
return;
while (!set_requests_.empty()) {
@@ -78,6 +78,13 @@ class PrefsChecker : public ownership::OwnerSettingsService::Observer {
DISALLOW_COPY_AND_ASSIGN(PrefsChecker);
};
+bool FindInListValue(const std::string& needle, const base::Value* haystack) {
+ const base::ListValue* list;
+ if (!haystack->GetAsList(&list))
+ return false;
+ return list->end() != list->Find(base::StringValue(needle));
+}
+
} // namespace
class OwnerSettingsServiceChromeOSTest : public DeviceSettingsTestBase {
@@ -123,6 +130,7 @@ class OwnerSettingsServiceChromeOSTest : public DeviceSettingsTestBase {
management_settings_set_ = success;
}
+ protected:
OwnerSettingsServiceChromeOS* service_;
ScopedTestingLocalState local_state_;
scoped_ptr<DeviceSettingsProvider> provider_;
@@ -294,6 +302,15 @@ TEST_F(OwnerSettingsServiceChromeOSTest, SetManagementSettingsSuccess) {
EXPECT_EQ("fake_device_id", policy_data->device_id());
}
+TEST_F(OwnerSettingsServiceChromeOSTest, ForceWhitelist) {
+ EXPECT_FALSE(FindInListValue(device_policy_.policy_data().username(),
+ provider_->Get(kAccountsPrefUsers)));
+ // Force a settings write.
+ TestSingleSet(service_, kReleaseChannel, base::StringValue("dev-channel"));
+ EXPECT_TRUE(FindInListValue(device_policy_.policy_data().username(),
+ provider_->Get(kAccountsPrefUsers)));
+}
+
class OwnerSettingsServiceChromeOSNoOwnerTest
: public OwnerSettingsServiceChromeOSTest {
public:
@@ -321,4 +338,16 @@ TEST_F(OwnerSettingsServiceChromeOSNoOwnerTest, SingleSetTest) {
ASSERT_FALSE(service_->SetBoolean(kAccountsPrefAllowGuest, false));
}
+TEST_F(OwnerSettingsServiceChromeOSNoOwnerTest, TakeOwnershipForceWhitelist) {
+ EXPECT_FALSE(FindInListValue(device_policy_.policy_data().username(),
+ provider_->Get(kAccountsPrefUsers)));
+ owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey());
+ InitOwner(device_policy_.policy_data().username(), true);
+ ReloadDeviceSettings();
+ ASSERT_TRUE(service_->IsOwner());
+
+ EXPECT_TRUE(FindInListValue(device_policy_.policy_data().username(),
+ provider_->Get(kAccountsPrefUsers)));
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698