#include <algorithm>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "build/config/chromebox_for_meetings/buildflags.h"
#include "chrome/browser/extensions/chrome_content_verifier_delegate.h"
#include "chrome/browser/extensions/extension_service_test_with_install.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/testing_profile.h"
#include "extensions/browser/content_verifier/test_utils.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/file_util.h"
#include "extensions/common/switches.h"
namespace extensions {
namespace {
constexpr char kCaseSensitiveManifestPathsCrx[] = …;
std::set<base::FilePath> ToFilePaths(const std::set<std::string>& paths) { … }
bool IsSuperset(const std::set<base::FilePath>& container,
const std::set<base::FilePath>& candidates) { … }
}
class ChromeContentVerifierTest : public ExtensionServiceTestWithInstall { … };
TEST_F(ChromeContentVerifierTest, CaseSensitivityInManifestPaths) { … }
TEST_F(ChromeContentVerifierTest, VerifyFailedOnLoad) { … }
#if BUILDFLAG(PLATFORM_CFM)
TEST_F(ChromeContentVerifierTest, CfmChecksHashWithoutForceFlag) {
ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableAppContentVerification));
InitContentVerifier();
ASSERT_TRUE(InstallExtension(kCaseSensitiveManifestPathsCrx));
EXPECT_EQ(ChromeContentVerifierDelegate::VerifierSourceType::SIGNED_HASHES,
GetVerifierSourceType(extension()));
}
TEST_F(ChromeContentVerifierTest, CfmDoesNotCheckHashWithForceFlag) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableAppContentVerification);
InitContentVerifier();
ASSERT_TRUE(InstallExtension(kCaseSensitiveManifestPathsCrx));
EXPECT_EQ(ChromeContentVerifierDelegate::VerifierSourceType::NONE,
GetVerifierSourceType(extension()));
}
#else
TEST_F(ChromeContentVerifierTest, NonCfmChecksHashEvenWithForceFlag) { … }
#endif
}