mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-03 04:38:39 +01:00
test(Zip): add archive consistency tests
This commit is contained in:
parent
af3613447d
commit
8d4ec98052
BIN
Zip/testsuite/data/consistency-crc32.zip
Normal file
BIN
Zip/testsuite/data/consistency-crc32.zip
Normal file
Binary file not shown.
BIN
Zip/testsuite/data/consistency-uncompressed.zip
Normal file
BIN
Zip/testsuite/data/consistency-uncompressed.zip
Normal file
Binary file not shown.
@ -11,6 +11,7 @@
|
|||||||
#include "ZipTest.h"
|
#include "ZipTest.h"
|
||||||
#include "Poco/Zip/SkipCallback.h"
|
#include "Poco/Zip/SkipCallback.h"
|
||||||
#include "Poco/Zip/ZipLocalFileHeader.h"
|
#include "Poco/Zip/ZipLocalFileHeader.h"
|
||||||
|
#include "Poco/Zip/ZipException.h"
|
||||||
#include "Poco/Zip/ZipArchive.h"
|
#include "Poco/Zip/ZipArchive.h"
|
||||||
#include "Poco/Zip/ZipStream.h"
|
#include "Poco/Zip/ZipStream.h"
|
||||||
#include "Poco/Zip/Decompress.h"
|
#include "Poco/Zip/Decompress.h"
|
||||||
@ -287,6 +288,60 @@ void ZipTest::testDecompressZip64()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ZipTest::testDecompressConsistency()
|
||||||
|
{
|
||||||
|
// test archives with borked file headers, but correct directory
|
||||||
|
const std::string testArchives[] =
|
||||||
|
{
|
||||||
|
"consistency-crc32.zip",
|
||||||
|
"consistency-uncompressed.zip"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
for (const std::string &archive : testArchives)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// test decompressing all files
|
||||||
|
//
|
||||||
|
{
|
||||||
|
Poco::FileInputStream inputStream(getTestFile("data", archive));
|
||||||
|
assertTrue (inputStream.good());
|
||||||
|
|
||||||
|
Decompress dec(inputStream, Poco::Path::temp());
|
||||||
|
|
||||||
|
try {
|
||||||
|
dec.decompressAllFiles();
|
||||||
|
assertTrue (false);
|
||||||
|
}
|
||||||
|
catch (const ZipException &e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// test decompressing single file
|
||||||
|
//
|
||||||
|
{
|
||||||
|
Poco::FileInputStream inputStream(getTestFile("data", archive));
|
||||||
|
assertTrue (inputStream.good());
|
||||||
|
|
||||||
|
ZipArchive archive(inputStream);
|
||||||
|
|
||||||
|
// File decompression code is skipped since
|
||||||
|
// we are not expecting archive to be processed further
|
||||||
|
try
|
||||||
|
{
|
||||||
|
archive.checkConsistency();
|
||||||
|
assertTrue (false);
|
||||||
|
}
|
||||||
|
catch (const ZipException &e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void ZipTest::testValidPath()
|
void ZipTest::testValidPath()
|
||||||
{
|
{
|
||||||
assertTrue (ZipCommon::isValidPath("."));
|
assertTrue (ZipCommon::isValidPath("."));
|
||||||
@ -357,6 +412,7 @@ CppUnit::Test* ZipTest::suite()
|
|||||||
CppUnit_addTest(pSuite, ZipTest, testCrcAndSizeAfterDataEncapsulated);
|
CppUnit_addTest(pSuite, ZipTest, testCrcAndSizeAfterDataEncapsulated);
|
||||||
CppUnit_addTest(pSuite, ZipTest, testDecompressZip64);
|
CppUnit_addTest(pSuite, ZipTest, testDecompressZip64);
|
||||||
CppUnit_addTest(pSuite, ZipTest, testValidPath);
|
CppUnit_addTest(pSuite, ZipTest, testValidPath);
|
||||||
|
CppUnit_addTest(pSuite, ZipTest, testDecompressConsistency);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
void testDecompressSingleFile();
|
void testDecompressSingleFile();
|
||||||
void testDecompressSingleFileInDir();
|
void testDecompressSingleFileInDir();
|
||||||
void testDecompress();
|
void testDecompress();
|
||||||
|
void testDecompressConsistency();
|
||||||
void testDecompressFlat();
|
void testDecompressFlat();
|
||||||
void testDecompressVuln();
|
void testDecompressVuln();
|
||||||
void testDecompressFlatVuln();
|
void testDecompressFlatVuln();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user