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

Unified Diff: chrome/browser/extensions/extensions_service_unittest.cc

Issue 414070: Merge 32163 - Add validation to extension packaging.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
Patch Set: Created 11 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
« no previous file with comments | « chrome/browser/extensions/extension_creator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extensions_service_unittest.cc
===================================================================
--- chrome/browser/extensions/extensions_service_unittest.cc (revision 32741)
+++ chrome/browser/extensions/extensions_service_unittest.cc (working copy)
@@ -740,7 +740,6 @@
}
// Test Packaging and installing an extension.
-// TODO(rafaelw): add more tests for failure cases.
TEST_F(ExtensionsServiceTest, PackExtension) {
InitializeEmptyExtensionsService();
FilePath extensions_path;
@@ -765,6 +764,27 @@
ASSERT_TRUE(file_util::PathExists(privkey_path));
InstallExtension(crx_path, true);
+
+ // Try packing with invalid paths.
+ creator.reset(new ExtensionCreator());
+ ASSERT_FALSE(creator->Run(FilePath(), FilePath(), FilePath(), FilePath()));
+
+ // Try packing an empty directory. Should fail because an empty directory is
+ // not a valid extension.
+ ScopedTempDir temp_dir2;
+ ASSERT_TRUE(temp_dir2.CreateUniqueTempDir());
+ creator.reset(new ExtensionCreator());
+ ASSERT_FALSE(creator->Run(temp_dir2.path(), crx_path, privkey_path,
+ FilePath()));
+
+ // Try packing with an invalid manifest.
+ std::string invalid_manifest_content = "I am not a manifest.";
+ ASSERT_TRUE(file_util::WriteFile(
+ temp_dir2.path().AppendASCII(Extension::kManifestFilename),
+ invalid_manifest_content.c_str(), invalid_manifest_content.size()));
+ creator.reset(new ExtensionCreator());
+ ASSERT_FALSE(creator->Run(temp_dir2.path(), crx_path, privkey_path,
+ FilePath()));
}
// Test Packaging and installing an extension using an openssl generated key.
« no previous file with comments | « chrome/browser/extensions/extension_creator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698