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

Side by Side Diff: chrome/common/mac/cfbundle_blocker_unittest.mm

Issue 8226026: Allow whitelisted bundles to load in Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/common/mac/cfbundle_blocker.h"
6
7 #import <Foundation/Foundation.h>
8
9 #include "base/basictypes.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace chrome {
13 namespace common {
14 namespace mac {
15 namespace {
16
17 struct IsBundleAllowedTestcase {
18 NSString* bundle_id;
19 NSString* version;
20 bool allowed;
21 };
22
23 TEST(CFBundleBlockerTest, IsBundleAllowed) {
24 const IsBundleAllowedTestcase kTestcases[] = {
25 // Block things without a bundle ID.
26 { nil, nil, false },
27
28 // Block bundle IDs that aren't in the whitelist.
29 { @"org.chromium.Chromium.evil", nil, false },
30
31 // The AllowedBundle structure for Google Authetnicator BT doesn't
32 // require a version, so this should work equally well with any version
33 // including no version at all.
34 { @"com.google.osax.Google_Authenticator_BT", nil, true },
35 { @"com.google.osax.Google_Authenticator_BT", @"0.5.0.0", true },
36
37 // Typos should be blocked.
38 { @"com.google.osax.Google_Authenticator_B", nil, false },
39 { @"com.google.osax.Google_Authenticator_BQ", nil, false },
40 { @"com.google.osax.Google_Authenticator_BTQ", nil, false },
41 { @"com.google.osax", nil, false },
42 { @"com.google", nil, false },
43 { @"com", nil, false },
44 { @"", nil, false },
45
46 // MySpeed requires a version, so make sure that versions below don't work
47 // and versions above do.
48 { @"com.enounce.MySpeed.osax", nil, false },
49 { @"com.enounce.MySpeed.osax", @"", false },
50 { @"com.enounce.MySpeed.osax", @"1200", false },
51 { @"com.enounce.MySpeed.osax", @"1201", true },
52 { @"com.enounce.MySpeed.osax", @"1202", true },
53
54 // DefaultFolderX is whitelisted as com.stclairsoft.DefaultFolderX. Make
55 // sure that "child" IDs such as com.stclairsoft.DefaultFolderX.osax work.
56 // It uses a dotted versioning scheme, so test the version comparator out.
57 { @"com.stclairsoft.DefaultFolderX.osax", nil, false },
58 { @"com.stclairsoft.DefaultFolderX.osax", @"", false },
59 { @"com.stclairsoft.DefaultFolderX.osax", @"3.5.4", false },
60 { @"com.stclairsoft.DefaultFolderX.osax", @"4.3.4", false },
61 { @"com.stclairsoft.DefaultFolderX.osax", @"4.4.2", false },
62 { @"com.stclairsoft.DefaultFolderX.osax", @"4.4.3", true },
63 { @"com.stclairsoft.DefaultFolderX.osax", @"4.4.4", true },
64 { @"com.stclairsoft.DefaultFolderX.osax", @"4.4.10", true },
65 { @"com.stclairsoft.DefaultFolderX.osax", @"4.5", true },
66 { @"com.stclairsoft.DefaultFolderX.osax", @"4.5.2", true },
67 { @"com.stclairsoft.DefaultFolderX.osax", @"4.10", true },
68 { @"com.stclairsoft.DefaultFolderX.osax", @"4.10.2", true },
69 { @"com.stclairsoft.DefaultFolderX.osax", @"5", true },
70 { @"com.stclairsoft.DefaultFolderX.osax", @"5.3", true },
71 { @"com.stclairsoft.DefaultFolderX.osax", @"5.3.2", true },
72
73 // Other "child" IDs that might want to load.
74 { @"com.stclairsoft.DefaultFolderX.CarbonPatcher", @"4.4.3", true },
75 { @"com.stclairsoft.DefaultFolderX.CocoaPatcher", @"4.4.3", true },
76 };
77
78 for (size_t index = 0; index < arraysize(kTestcases); ++index) {
79 const IsBundleAllowedTestcase& testcase = kTestcases[index];
80 NSString* bundle_id = testcase.bundle_id;
81 NSString* version = testcase.version;
82 NSString* version_print = version ? version : @"(nil)";
83 EXPECT_EQ(testcase.allowed, IsBundleAllowed(bundle_id, version))
84 << "index " << index
85 << ", bundle_id " << [bundle_id UTF8String]
86 << ", version " << [version_print UTF8String];
87 }
88 }
Scott Hess - ex-Googler 2011/10/13 00:05:54 Thank you for writing the test! I think IsBundleA
Mark Mentovai 2011/10/13 03:23:15 shess wrote:
89
90 } // namespace
91 } // namespace mac
92 } // namespace common
93 } // namespace chrome
OLDNEW
« chrome/common/mac/cfbundle_blocker.mm ('K') | « chrome/common/mac/cfbundle_blocker.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698