#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/test/bind.h"
#include "base/values.h"
#include "base/version.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/url_loader_interceptor.h"
#include "extensions/browser/content_verifier/content_verifier.h"
#include "extensions/browser/content_verifier/test_utils.h"
#include "extensions/browser/extensions_test.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/file_util.h"
#include "extensions/test/test_extension_dir.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/zlib/google/zip.h"
namespace extensions {
namespace {
enum ContentVerifyJobAsyncRunMode { … };
std::string GetVerifiedContents(const Extension& extension) { … }
void WriteManifest(TestExtensionDir* dir) { … }
void WriteComputedHashes(
const base::FilePath& extension_root,
const std::map<base::FilePath, std::string>& contents) { … }
}
class ContentVerifyJobUnittest : public ExtensionsTest { … };
TEST_F(ContentVerifyJobUnittest, DeletedAndMissingFiles) { … }
TEST_F(ContentVerifyJobUnittest, MultipleReadErrors) { … }
namespace {
void WriteIncorrectComputedHashes(const base::FilePath& extension_path,
const base::FilePath& resource_path) { … }
void WriteEmptyComputedHashes(const base::FilePath& extension_path) { … }
}
TEST_F(ContentVerifyJobUnittest, DeletedResourceAndCorruptedComputedHashes) { … }
TEST_F(ContentVerifyJobUnittest, DeletedResourceAndCleanedComputedHashes) { … }
TEST_F(ContentVerifyJobUnittest, LegitimateZeroByteFile) { … }
TEST_F(ContentVerifyJobUnittest, DifferentSizedFiles) { … }
TEST_F(ContentVerifyJobUnittest, ModifiedComputedHashes) { … }
ContentVerifyJobWithoutSignedHashesUnittest;
TEST_F(ContentVerifyJobWithoutSignedHashesUnittest, ComputedHashesLoad) { … }
TEST_F(ContentVerifyJobWithoutSignedHashesUnittest, UnverifiedExtension) { … }
TEST_F(ContentVerifyJobWithoutSignedHashesUnittest, ExtensionWithoutHashes) { … }
class ContentMismatchUnittest
: public ContentVerifyJobUnittest,
public testing::WithParamInterface<ContentVerifyJobAsyncRunMode> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(ContentMismatchUnittest, ContentMismatch) { … }
TEST_P(ContentMismatchUnittest, ContentMismatchWithLargeFile) { … }
class ContentVerifyJobWithHashFetchUnittest : public ContentVerifyJobUnittest { … };
TEST_F(ContentVerifyJobWithHashFetchUnittest, ReadErrorBeforeHashReady) { … }
TEST_F(ContentVerifyJobWithHashFetchUnittest,
ReadFileWithoutHashesBeforeHashReady) { … }
}