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

Unified Diff: chrome/browser/chromeos/login/signed_settings_cache_unittest.cc

Issue 8727037: Signed settings refactoring: Proper caching and more tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Next round of comments. All bots meanwhile good and manual testing seems fine as well. Created 9 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
Index: chrome/browser/chromeos/login/signed_settings_cache_unittest.cc
diff --git a/chrome/browser/chromeos/login/signed_settings_cache_unittest.cc b/chrome/browser/chromeos/login/signed_settings_cache_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9683b4777fa62053f9d1450285509d694d526b73
--- /dev/null
+++ b/chrome/browser/chromeos/login/signed_settings_cache_unittest.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/signed_settings_cache.h"
+
+#include "chrome/browser/policy/proto/chrome_device_policy.pb.h"
+#include "chrome/browser/policy/proto/device_management_backend.pb.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/base/testing_pref_service.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace em = enterprise_management;
+
+namespace chromeos {
+
+class SignedSettingsCacheTest : public testing::Test {
+ protected:
+ virtual void SetUp() {
+ // prepare some data.
+ policy_.set_policy_type("google/chromeos/device");
+ em::ChromeDeviceSettingsProto pol;
+ pol.mutable_allow_new_users()->set_allow_new_users(false);
+ policy_.set_policy_value(pol.SerializeAsString());
+
+ signed_settings_cache::RegisterPrefs(&local_state_);
+ }
+
+ TestingPrefService local_state_;
+ em::PolicyData policy_;
+};
+
+TEST_F(SignedSettingsCacheTest, Basic) {
+ EXPECT_TRUE(signed_settings_cache::Store(policy_, &local_state_));
+
+ em::PolicyData policy_out;
+ EXPECT_TRUE(signed_settings_cache::Retrieve(&policy_out, &local_state_));
+
+ EXPECT_TRUE(policy_out.has_policy_type());
+ EXPECT_TRUE(policy_out.has_policy_value());
+
+ em::ChromeDeviceSettingsProto pol;
+ pol.ParseFromString(policy_out.policy_value());
+ EXPECT_TRUE(pol.has_allow_new_users());
+ EXPECT_FALSE(pol.allow_new_users().allow_new_users());
+}
+
+TEST_F(SignedSettingsCacheTest, CorruptData) {
+ EXPECT_TRUE(signed_settings_cache::Store(policy_, &local_state_));
+
+ local_state_.SetString(prefs::kSignedSettingsCache, "blaaa");
+
+ em::PolicyData policy_out;
+ EXPECT_FALSE(signed_settings_cache::Retrieve(&policy_out, &local_state_));
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698