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

Side by Side Diff: chrome/browser/prefs/tracked/pref_hash_browsertest.cc

Issue 550343004: Do not allow values to be migrated without MACs if the destination already has a MAC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/prefs/tracked/tracked_preferences_migration.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 GetTrackedPrefHistogramCount( 769 GetTrackedPrefHistogramCount(
770 "Settings.TrackedPreferenceTrustedInitialized", ALLOW_NONE)); 770 "Settings.TrackedPreferenceTrustedInitialized", ALLOW_NONE));
771 EXPECT_EQ( 771 EXPECT_EQ(
772 0, 772 0,
773 GetTrackedPrefHistogramCount( 773 GetTrackedPrefHistogramCount(
774 "Settings.TrackedPreferenceMigratedLegacyDeviceId", ALLOW_NONE)); 774 "Settings.TrackedPreferenceMigratedLegacyDeviceId", ALLOW_NONE));
775 } 775 }
776 }; 776 };
777 777
778 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedSplitPref, ChangedSplitPref); 778 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedSplitPref, ChangedSplitPref);
779
780 // Verifies that adding a value to unprotected preferences for a key which is
781 // still using the default (i.e. has no value stored in protected preferences)
782 // doesn't allow that value to slip in with no valid MAC (regression test for
783 // http://crbug.com/414554)
784 class PrefHashBrowserTestUntrustedAdditionToPrefs
785 : public PrefHashBrowserTestBase {
786 public:
787 virtual void SetupPreferences() OVERRIDE {
788 // Ensure there is no user-selected value for kRestoreOnStartup.
789 EXPECT_FALSE(
790 profile()->GetPrefs()->GetUserPrefValue(prefs::kRestoreOnStartup));
791 }
792
793 virtual void AttackPreferencesOnDisk(
Bernhard Bauer 2014/09/16 08:10:54 Does this need an OVERRIDE?
gab 2014/09/16 12:14:22 Yep, and it already has it, see two lines below af
794 base::DictionaryValue* unprotected_preferences,
795 base::DictionaryValue* protected_preferences) OVERRIDE {
796 unprotected_preferences->SetInteger(prefs::kRestoreOnStartup,
797 SessionStartupPref::LAST);
798 }
799
800 virtual void VerifyReactionToPrefAttack() OVERRIDE {
801 // Expect a single Changed event for tracked pref #3 (kRestoreOnStartup) if
802 // not protecting; if protection is enabled the change should be a no-op.
803 int changed_expected =
804 protection_level_ == PROTECTION_DISABLED_FOR_GROUP ? 1 : 0;
805 EXPECT_EQ(
806 (protection_level_ > PROTECTION_DISABLED_ON_PLATFORM &&
807 protection_level_ < PROTECTION_ENABLED_BASIC) ? changed_expected : 0,
808 GetTrackedPrefHistogramCount("Settings.TrackedPreferenceChanged",
809 BEGIN_ALLOW_SINGLE_BUCKET + 3));
810 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM
811 ? num_tracked_prefs() - changed_expected : 0,
812 GetTrackedPrefHistogramCount(
813 "Settings.TrackedPreferenceUnchanged", ALLOW_ANY));
814
815 EXPECT_EQ(
816 (protection_level_ > PROTECTION_DISABLED_ON_PLATFORM &&
817 protection_level_ < PROTECTION_ENABLED_BASIC) ? 1 : 0,
818 GetTrackedPrefHistogramCount("Settings.TrackedPreferenceWantedReset",
819 BEGIN_ALLOW_SINGLE_BUCKET + 3));
820 EXPECT_EQ(0,
821 GetTrackedPrefHistogramCount("Settings.TrackedPreferenceReset",
822 ALLOW_NONE));
823
824 // Nothing else should have triggered.
825 EXPECT_EQ(0,
826 GetTrackedPrefHistogramCount("Settings.TrackedPreferenceCleared",
827 ALLOW_NONE));
828 EXPECT_EQ(0,
829 GetTrackedPrefHistogramCount(
830 "Settings.TrackedPreferenceInitialized", ALLOW_NONE));
831 EXPECT_EQ(0,
832 GetTrackedPrefHistogramCount(
833 "Settings.TrackedPreferenceTrustedInitialized", ALLOW_NONE));
834 EXPECT_EQ(
835 0,
836 GetTrackedPrefHistogramCount(
837 "Settings.TrackedPreferenceMigratedLegacyDeviceId", ALLOW_NONE));
838 }
839 };
840
841 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefs,
842 UntrustedAdditionToPrefs);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prefs/tracked/tracked_preferences_migration.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698