| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/chromeos/extensions/device_local_account_management_pol
icy_provider.h" | 5 #include "chrome/browser/chromeos/extensions/device_local_account_management_pol
icy_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
| 16 #include "extensions/common/manifest.h" | 16 #include "extensions/common/manifest.h" |
| 17 #include "extensions/common/manifest_constants.h" | 17 #include "extensions/common/manifest_constants.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace chromeos { | 20 namespace chromeos { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const char kWhitelistedId[] = "cbkkbcmdlboombapidmoeolnmdacpkch"; | 24 const char kWhitelistedId[] = "cbkkbcmdlboombapidmoeolnmdacpkch"; |
| 25 const char kBogusId[] = "bogus"; |
| 25 | 26 |
| 26 scoped_refptr<const extensions::Extension> CreateExtensionFromValues( | 27 scoped_refptr<const extensions::Extension> CreateExtensionFromValues( |
| 27 const std::string& id, | 28 const std::string& id, |
| 28 extensions::Manifest::Location location, | 29 extensions::Manifest::Location location, |
| 29 base::DictionaryValue* values, | 30 base::DictionaryValue* values, |
| 30 int flags) { | 31 int flags) { |
| 31 values->SetString(extensions::manifest_keys::kName, "test"); | 32 values->SetString(extensions::manifest_keys::kName, "test"); |
| 32 values->SetString(extensions::manifest_keys::kVersion, "0.1"); | 33 values->SetString(extensions::manifest_keys::kVersion, "0.1"); |
| 33 std::string error; | 34 std::string error; |
| 34 return extensions::Extension::Create(base::FilePath(), | 35 return extensions::Extension::Create(base::FilePath(), |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 // Verify that an extension whose ID has been whitelisted for use in other | 605 // Verify that an extension whose ID has been whitelisted for use in other |
| 605 // types of device-local accounts cannot be installed in a single-app kiosk | 606 // types of device-local accounts cannot be installed in a single-app kiosk |
| 606 // session. | 607 // session. |
| 607 extension = CreateRegularExtension(kWhitelistedId); | 608 extension = CreateRegularExtension(kWhitelistedId); |
| 608 ASSERT_TRUE(extension.get()); | 609 ASSERT_TRUE(extension.get()); |
| 609 EXPECT_TRUE(provider.UserMayLoad(extension.get(), &error)); | 610 EXPECT_TRUE(provider.UserMayLoad(extension.get(), &error)); |
| 610 EXPECT_EQ(base::string16(), error); | 611 EXPECT_EQ(base::string16(), error); |
| 611 error.clear(); | 612 error.clear(); |
| 612 } | 613 } |
| 613 | 614 |
| 615 TEST(DeviceLocalAccountManagementPolicyProviderTest, IsWhitelisted) { |
| 616 // Whitelisted extension, Chrome Remote Desktop. |
| 617 auto extension = CreateRegularExtension(kWhitelistedId); |
| 618 EXPECT_TRUE(DeviceLocalAccountManagementPolicyProvider::IsWhitelisted( |
| 619 extension.get())); |
| 620 |
| 621 // Bogus extension ID (never true). |
| 622 extension = CreateRegularExtension(kBogusId); |
| 623 EXPECT_FALSE(DeviceLocalAccountManagementPolicyProvider::IsWhitelisted( |
| 624 extension.get())); |
| 625 } |
| 626 |
| 614 } // namespace chromeos | 627 } // namespace chromeos |
| OLD | NEW |