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

Side by Side Diff: content/common/quarantine/quarantine_win_unittest.cc

Issue 2124373002: [PPAPI] Quarantine files that are writeable by a Pepper plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@consolidate-file-metadata
Patch Set: Address comments. Created 4 years 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
« no previous file with comments | « content/common/quarantine/quarantine_win.cc ('k') | content/public/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <windows.h> 5 #include <windows.h>
6 6
7 #include <wininet.h> 7 #include <wininet.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/test/histogram_tester.h" 13 #include "base/test/histogram_tester.h"
14 #include "base/test/test_file_util.h" 14 #include "base/test/test_file_util.h"
15 #include "content/browser/download/quarantine.h" 15 #include "content/public/common/quarantine.h"
16 #include "net/base/filename_util.h" 16 #include "net/base/filename_util.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 namespace { 22 namespace {
23 23
24 const char kDummySourceUrl[] = "https://example.com/foo"; 24 const char kDummySourceUrl[] = "https://example.com/foo";
25 const char kDummyReferrerUrl[] = "https://example.com/referrer"; 25 const char kDummyReferrerUrl[] = "https://example.com/referrer";
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // trustworthy. Hence they aren't annotated with source information. This test 58 // trustworthy. Hence they aren't annotated with source information. This test
59 // verifies this behavior since the other tests in this suite would pass with a 59 // verifies this behavior since the other tests in this suite would pass with a
60 // false positive if local files are being annotated with the MOTW for the 60 // false positive if local files are being annotated with the MOTW for the
61 // internet zone. 61 // internet zone.
62 TEST(QuarantineWinTest, LocalFile_DependsOnLocalConfig) { 62 TEST(QuarantineWinTest, LocalFile_DependsOnLocalConfig) {
63 base::HistogramTester histogram_tester; 63 base::HistogramTester histogram_tester;
64 base::ScopedTempDir test_dir; 64 base::ScopedTempDir test_dir;
65 ASSERT_TRUE(test_dir.CreateUniqueTempDir()); 65 ASSERT_TRUE(test_dir.CreateUniqueTempDir());
66 base::FilePath test_file = test_dir.GetPath().AppendASCII("foo.exe"); 66 base::FilePath test_file = test_dir.GetPath().AppendASCII("foo.exe");
67 67
68 const char* const kLocalSourceURLs[] = { 68 const char* const kLocalSourceURLs[] = {"http://localhost/foo",
69 "http://localhost/foo", 69 "file:///C:/some-local-dir/foo.exe"};
70 "file:///C:/some-local-dir/foo.exe"
71 };
72 70
73 for (const auto source_url : kLocalSourceURLs) { 71 for (const auto source_url : kLocalSourceURLs) {
74 SCOPED_TRACE(::testing::Message() << "Trying URL " << source_url); 72 SCOPED_TRACE(::testing::Message() << "Trying URL " << source_url);
75 ASSERT_EQ(static_cast<int>(arraysize(kTestData)), 73 ASSERT_EQ(static_cast<int>(arraysize(kTestData)),
76 base::WriteFile(test_file, kTestData, arraysize(kTestData))); 74 base::WriteFile(test_file, kTestData, arraysize(kTestData)));
77 75
78 EXPECT_EQ( 76 EXPECT_EQ(
79 QuarantineFileResult::OK, 77 QuarantineFileResult::OK,
80 QuarantineFile(test_file, GURL(source_url), GURL(), kDummyClientGuid)); 78 QuarantineFile(test_file, GURL(source_url), GURL(), kDummyClientGuid));
81 79
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 EXPECT_EQ(QuarantineFileResult::OK, 254 EXPECT_EQ(QuarantineFileResult::OK,
257 QuarantineFile(test_file, GURL(source_url), GURL(), std::string())); 255 QuarantineFile(test_file, GURL(source_url), GURL(), std::string()));
258 256
259 std::string motw_contents; 257 std::string motw_contents;
260 ASSERT_TRUE(base::ReadFileToString( 258 ASSERT_TRUE(base::ReadFileToString(
261 base::FilePath(test_file.value() + kMotwStreamSuffix), &motw_contents)); 259 base::FilePath(test_file.value() + kMotwStreamSuffix), &motw_contents));
262 EXPECT_STREQ(kMotwForInternetZone, motw_contents.c_str()); 260 EXPECT_STREQ(kMotwForInternetZone, motw_contents.c_str());
263 } 261 }
264 262
265 } // content 263 } // content
OLDNEW
« no previous file with comments | « content/common/quarantine/quarantine_win.cc ('k') | content/public/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698