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

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

Issue 20794003: Fix a bug where packing an extension with bad private key causes crash. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_creator.cc ('k') | chrome/test/data/extensions/bad_private_key.crx » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/pack_extension_unittest.cc
diff --git a/chrome/browser/extensions/pack_extension_unittest.cc b/chrome/browser/extensions/pack_extension_unittest.cc
index dac4608553cd26ad25b5c1ae170c931fb3fff57b..be50727930f409d0478c4bfa0453f9ae16db26d5 100644
--- a/chrome/browser/extensions/pack_extension_unittest.cc
+++ b/chrome/browser/extensions/pack_extension_unittest.cc
@@ -38,6 +38,19 @@ class PackExtensionTest : public testing::Test {
return startup_helper_.PackExtension(command_line);
}
+ bool TestPackExtensionKey(const base::FilePath& path,
+ const base::FilePath& key_path) {
+ base::ScopedTempDir temp_dir;
+ EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
+ EXPECT_TRUE(base::CopyDirectory(path, temp_dir.path(), true));
+ CommandLine command_line(CommandLine::NO_PROGRAM);
+ command_line.AppendSwitchPath(switches::kPackExtension,
+ temp_dir.path().Append(path.BaseName()));
+ command_line.AppendSwitchPath(switches::kPackExtensionKey,
+ temp_dir.path().Append(key_path.BaseName()));
+ return startup_helper_.PackExtension(command_line);
+ }
+
base::MessageLoop message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
@@ -61,4 +74,11 @@ TEST_F(PackExtensionTest, PlatformApp) {
.AppendASCII("minimal")));
}
+TEST_F(PackExtensionTest, ExtensionWithInvalidKey) {
zhchbin 2013/07/27 00:33:24 Why don't you put this code to the ExtensionServic
+ ASSERT_FALSE(TestPackExtensionKey(test_data_dir_.
+ AppendASCII("bad_private_key"),
+ test_data_dir_.
+ AppendASCII("bad_private_key.pem")));
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/extension_creator.cc ('k') | chrome/test/data/extensions/bad_private_key.crx » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698