chromium/third_party/lzma_sdk/google/seven_zip_reader_unittest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Test files were generated with the following commands (commands for each test
// file given independently, even though many share the same contents)
//   echo "This is not an exe" > file.exe
//   7z a compressed_exe.7z file.exe
//
//   touch empty_file
//   7z a empty_file.7z empty_file
//
//   echo "This is not an exe" > file.exe
//   mkdir folder
//   cp file.exe file2.exe
//   7z a file_folder_file.7z file.exe folder file2.exe
//
//   mkdir folder
//   7z a folder.7z folder
//
//   echo "This is a text file!" > not_a_seven_zip.7z
//
//   echo "This is not an exe" > file.exe
//   7z a bad_crc.7z file.exe
//   grep --byte-offset --only-matching --text "This is not an exe" \
//     bad_crc.7z | sed 's/:.*$//' | while read -r match; do \
//     printf 'This is not an exe' | dd conv=notrunc of=bad_crc.7z \
//     bs=1 seek=$match done
//
//   fake_crc_table.7z was created with a hex editor, replacing the three CRC
//   values with 0.
//
//   echo "This is not an exe" > file.exe
//   7z a -p encrypted.7z file.exe  # Provided 1234 as the password
//
//   echo "This is not an exe" > file.exe
//   7z a  -mhe=on -p encrypted_header.7z file.exe
//   Provided 1234 as the password

#include "third_party/lzma_sdk/google/seven_zip_reader.h"

#include <array>
#include <string>
#include <utility>

#include "base/base_paths.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

extern "C" {
#include "third_party/lzma_sdk/C/7zCrc.h"
}

namespace seven_zip {

namespace {

_;
ByMove;
DoAll;
Field;
Matcher;
Return;
SetArgReferee;
StrictMock;

base::File OpenTestFile(base::FilePath::StringPieceType file_name) {}

base::File OpenTemporaryFile() {}

}  // namespace

class MockSevenZipDelegate : public Delegate {};

TEST(SevenZipReaderTest, ReportsOpenErrorForInvalidArchive) {}

TEST(SevenZipReaderTest, ReportsFilePath) {}

TEST(SevenZipReaderTest, ReportsFileSize) {}

TEST(SevenZipReaderTest, ReportsFileModifiedTime) {}

TEST(SevenZipReaderTest, ReportsDirectoryPath) {}

TEST(SevenZipReaderTest, ReportsDirectoryModifiedTime) {}

TEST(SevenZipReaderTest, StopsExtractionOnDirectory) {}

TEST(SevenZipReaderTest, StopsExtractionOnEntry) {}

TEST(SevenZipReaderTest, StopsExtractionOnEntryDone) {}

TEST(SevenZipReaderTest, ExtractsInTempBuffer) {}

TEST(SevenZipReaderTest, ExtractsNoTempBuffer) {}

TEST(SevenZipReaderTest, BadCrc) {}

TEST(SevenZipReaderTest, EmptyFile) {}

class SevenZipReaderFakeCrcTableTest : public testing::Test {};

// This is useful functionality for the fuzzer, so we test it here.
TEST_F(SevenZipReaderFakeCrcTableTest, EmptyCrcWithFakeTable) {}

TEST(SevenZipReaderTest, EncryptedFile) {}

TEST(SevenZipReaderTest, UnencryptedFile) {}

TEST(SevenZipReaderTest, EncryptedHeaders) {}

}  // namespace seven_zip