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

Unified Diff: extensions/utility/unpacker_unittest.cc

Issue 2321823002: Exclude exe files while unzipping CRXes (Closed)
Patch Set: Ignore case Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/utility/unpacker.cc ('k') | extensions/utility/utility_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/utility/unpacker_unittest.cc
diff --git a/extensions/utility/unpacker_unittest.cc b/extensions/utility/unpacker_unittest.cc
index 8954b1846bcd41cc2435017c7b46fb93b305b907..25dc87946688194f2f01a0a2ddbb9ce8d6ad73d1 100644
--- a/extensions/utility/unpacker_unittest.cc
+++ b/extensions/utility/unpacker_unittest.cc
@@ -195,4 +195,38 @@ TEST_F(UnpackerTest, ImageDecodingError) {
<< unpacker_->error_message() << "\"";
}
+base::FilePath CreateEmptyTestFile(const base::FilePath& test_dir,
+ const base::FilePath& file_path) {
+ base::FilePath test_file(test_dir.Append(file_path));
+ base::FilePath temp_file;
+ EXPECT_TRUE(base::CreateTemporaryFileInDir(test_dir, &temp_file));
+ EXPECT_TRUE(base::Move(temp_file, test_file));
+ return test_file;
+}
+
+TEST_F(UnpackerTest, BlockedFileTypes) {
+ const struct {
+ const base::FilePath::CharType* input;
+ bool expected;
+ } cases[] = {
+ {FILE_PATH_LITERAL("foo"), true},
+ {FILE_PATH_LITERAL("foo.nexe"), true},
+ {FILE_PATH_LITERAL("foo.dll"), true},
+ {FILE_PATH_LITERAL("foo.jpg.exe"), false},
+ {FILE_PATH_LITERAL("foo.exe"), false},
+ {FILE_PATH_LITERAL("foo.EXE"), false},
+ };
+
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ base::FilePath input(cases[i].input);
+ base::FilePath test_file(CreateEmptyTestFile(temp_dir.path(), input));
+ bool observed = Unpacker::ShouldExtractFile(test_file);
+ EXPECT_EQ(cases[i].expected, observed) << "i: " << i
+ << ", input: " << test_file.value();
+ }
+}
+
} // namespace extensions
« no previous file with comments | « extensions/utility/unpacker.cc ('k') | extensions/utility/utility_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698