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

Side by Side Diff: chrome/browser/chromeos/extensions/device_local_account_management_policy_provider_unittest.cc

Issue 24261010: Allow explicitly whitelisted apps/extensions in public sessions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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/browser/chromeos/extensions/device_local_account_management_pol icy_provider.h"
6
7 #include <string>
8
9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/values.h"
12 #include "chrome/common/extensions/extension.h"
13 #include "extensions/common/manifest.h"
14 #include "extensions/common/manifest_constants.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace chromeos {
18
19 namespace {
20
21 const char kWhitelistedId[] = "bpmcpldpdmajfigpchkicefoigmkfalc";
22
23 scoped_refptr<const extensions::Extension> CreateExtensionFromValues(
24 const std::string& id,
25 base::DictionaryValue* values) {
26 values->SetString(extensions::manifest_keys::kName, "test");
27 values->SetString(extensions::manifest_keys::kVersion, "0.1");
28 std::string error;
29 return extensions::Extension::Create(base::FilePath(),
30 extensions::Manifest::INTERNAL,
31 *values,
32 extensions::Extension::NO_FLAGS,
33 id,
34 &error);
35 }
36
37 scoped_refptr<const extensions::Extension> CreateExtension(
38 const std::string& id) {
39 base::DictionaryValue values;
40 return CreateExtensionFromValues(id, &values);
41 }
42
43 scoped_refptr<const extensions::Extension> CreateHostedApp() {
44 base::DictionaryValue values;
45 values.Set(extensions::manifest_keys::kApp, new base::DictionaryValue);
46 values.Set(extensions::manifest_keys::kWebURLs, new base::ListValue);
47 return CreateExtensionFromValues(std::string(), &values);
48 }
49
50 } // namespace
51
52 typedef testing::Test DeviceLocalAccountManagementPolicyProviderTest;
53
54 TEST_F(DeviceLocalAccountManagementPolicyProviderTest, CheckPolicy) {
55 DeviceLocalAccountManagementPolicyProvider provider;
56
57 // Verify that if an extension's type has been whitelisted for use in
58 // device-local accounts, the extension can be installed.
59 scoped_refptr<const extensions::Extension> extension = CreateHostedApp();
60 ASSERT_TRUE(extension);
61 string16 error;
62 EXPECT_TRUE(provider.UserMayLoad(extension.get(), &error));
63 EXPECT_EQ(string16(), error);
64 error.clear();
65
66 // Verify that if an extension's ID has been explicitly whitelisted for use in
67 // device-local accounts, the extension can be installed.
68 extension = CreateExtension(kWhitelistedId);
69 ASSERT_TRUE(extension);
70 EXPECT_TRUE(provider.UserMayLoad(extension.get(), &error));
71 EXPECT_EQ(string16(), error);
72 error.clear();
73
74 // Verify that if neither the type nor the ID of an extension have been
75 // whitelisted for use in device-local accounts, the extension cannot be
76 // installed.
77 extension = CreateExtension(std::string());
78 ASSERT_TRUE(extension);
79 EXPECT_FALSE(provider.UserMayLoad(extension.get(), &error));
80 EXPECT_NE(string16(), error);
81 error.clear();
82 }
83
84 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698