diff --git a/autotests/plugins/clirarplugin/clirartest.cpp b/autotests/plugins/clirarplugin/clirartest.cpp index 74d77ccf..0b603872 100644 --- a/autotests/plugins/clirarplugin/clirartest.cpp +++ b/autotests/plugins/clirarplugin/clirartest.cpp @@ -1,305 +1,213 @@ /* * Copyright (c) 2011,2014 Raphael Kubo da Costa + * Copyright (c) 2015,2016 Ragnar Thomsen * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "clirartest.h" -#include - #include +#include +#include #include +#include + QTEST_GUILESS_MAIN(CliRarTest) using namespace Kerfuffle; -/* - * Check that the plugin will not crash when reading corrupted archives, which - * have lines such as "Unexpected end of archive" or "??? - the file header is - * corrupt" instead of a file name and the header string after it. - * - * See bug 262857 and commit 2042997013432cdc6974f5b26d39893a21e21011. - */ -void CliRarTest::testReadCorruptedArchive() +void CliRarTest::initTestCase() { qRegisterMetaType(); - QVariantList args; - args.append(QStringLiteral("DummyArchive.rar")); - - CliPlugin *rarPlugin = new CliPlugin(this, args); - QVERIFY(rarPlugin->open()); - - QSignalSpy spy(rarPlugin, SIGNAL(entry(ArchiveEntry))); - - QFile unrarOutput(QFINDTESTDATA("data/testReadCorruptedArchive.txt")); - QVERIFY(unrarOutput.open(QIODevice::ReadOnly)); - - QTextStream unrarStream(&unrarOutput); - while (!unrarStream.atEnd()) { - const QString line(unrarStream.readLine()); - QVERIFY(rarPlugin->readListLine(line)); + const auto plugins = KPluginLoader::findPluginsById(QStringLiteral("kerfuffle"), QStringLiteral("kerfuffle_clirar")); + if (plugins.size() == 1) { + m_pluginMetadata = plugins.at(0); } - - qDebug() << "Entries found:" << spy.count(); - QCOMPARE(spy.count(), 1); - - // Check if the first entry's name is correctly parsed. - ArchiveEntry entry = qvariant_cast(spy.at(0).at(0)); - QCOMPARE(entry[FileName].toString(), QStringLiteral("some-file.ext")); - - rarPlugin->deleteLater(); } -void CliRarTest::testUnrar4Normal() +void CliRarTest::testArchive_data() { - QVariantList args; - args.append(QStringLiteral("DummyArchive.rar")); - - CliPlugin *rarPlugin = new CliPlugin(this, args); - QVERIFY(rarPlugin->open()); - - QSignalSpy spy(rarPlugin, SIGNAL(entry(ArchiveEntry))); - - QFile unrarOutput(QFINDTESTDATA("data/testUnrar4Normal.txt")); - QVERIFY(unrarOutput.open(QIODevice::ReadOnly)); - - QTextStream unrarStream(&unrarOutput); - while (!unrarStream.atEnd()) { - const QString line(unrarStream.readLine()); - QVERIFY(rarPlugin->readListLine(line)); - } - - qDebug() << "Entries found:" << spy.count(); - QCOMPARE(spy.count(), 8); - - // Check if the sixth entry's name is correctly parsed. - ArchiveEntry entry = qvariant_cast(spy.at(5).at(0)); - QCOMPARE(entry[FileName].toString(), QStringLiteral("dir2/file2.txt")); - - rarPlugin->deleteLater(); + QTest::addColumn("archivePath"); + QTest::addColumn("expectedFileName"); + QTest::addColumn("isReadOnly"); + QTest::addColumn("isSingleFolder"); + QTest::addColumn("expectedEncryptionType"); + QTest::addColumn("expectedSubfolderName"); + + QString archivePath = QFINDTESTDATA("data/one_toplevel_folder.rar"); + QTest::newRow("archive with one top-level folder") + << archivePath + << QFileInfo(archivePath).fileName() + << false << true << Archive::Unencrypted + << QStringLiteral("A"); } -void CliRarTest::testUnrar5Normal() +void CliRarTest::testArchive() { - QVariantList args; - args.append(QStringLiteral("DummyArchive.rar")); - - CliPlugin *rarPlugin = new CliPlugin(this, args); - QVERIFY(rarPlugin->open()); - - QSignalSpy spy(rarPlugin, SIGNAL(entry(ArchiveEntry))); - - QFile unrarOutput(QFINDTESTDATA("data/testUnrar5Normal.txt")); - QVERIFY(unrarOutput.open(QIODevice::ReadOnly)); - - QTextStream unrarStream(&unrarOutput); - while (!unrarStream.atEnd()) { - const QString line(unrarStream.readLine()); - QVERIFY(rarPlugin->readListLine(line)); + if (!m_pluginMetadata.isValid()) { + QSKIP("Could not find the clirar plugin. Skipping test.", SkipSingle); } - qDebug() << "Entries found:" << spy.count(); - QCOMPARE(spy.count(), 8); - - // Check if the sixth entry's name is correctly parsed. - ArchiveEntry entry = qvariant_cast(spy.at(5).at(0)); - QCOMPARE(entry[FileName].toString(), QStringLiteral("dir2/file2.txt")); - - rarPlugin->deleteLater(); -} - -void CliRarTest::testUnrar4Symlink() -{ - QVariantList args; - args.append(QStringLiteral("DummyArchive.rar")); - - CliPlugin *rarPlugin = new CliPlugin(this, args); - QVERIFY(rarPlugin->open()); + QFETCH(QString, archivePath); + Archive *archive = Archive::create(archivePath, m_pluginMetadata, this); + QVERIFY(archive); - QSignalSpy spy(rarPlugin, SIGNAL(entry(ArchiveEntry))); - - QFile unrarOutput(QFINDTESTDATA("data/testUnrar4Symlink.txt")); - QVERIFY(unrarOutput.open(QIODevice::ReadOnly)); - - QTextStream unrarStream(&unrarOutput); - while (!unrarStream.atEnd()) { - const QString line(unrarStream.readLine()); - QVERIFY(rarPlugin->readListLine(line)); + if (!archive->isValid()) { + QSKIP("Could not load the clirar plugin. Skipping test.", SkipSingle); } - qDebug() << "Entries found:" << spy.count(); - QCOMPARE(spy.count(), 3); + QFETCH(QString, expectedFileName); + QCOMPARE(QFileInfo(archive->fileName()).fileName(), expectedFileName); - // Check if the second entry's name is correctly parsed. - ArchiveEntry entry = qvariant_cast(spy.at(1).at(0)); - QCOMPARE(entry[FileName].toString(), QStringLiteral("foo/hello2")); + QFETCH(bool, isReadOnly); + QCOMPARE(archive->isReadOnly(), isReadOnly); - rarPlugin->deleteLater(); -} + QFETCH(bool, isSingleFolder); + QCOMPARE(archive->isSingleFolderArchive(), isSingleFolder); -void CliRarTest::testUnrar5Symlink() -{ - QVariantList args; - args.append(QStringLiteral("DummyArchive.rar")); - - CliPlugin *rarPlugin = new CliPlugin(this, args); - QVERIFY(rarPlugin->open()); - - QSignalSpy spy(rarPlugin, SIGNAL(entry(ArchiveEntry))); - - QFile unrarOutput(QFINDTESTDATA("data/testUnrar5Symlink.txt")); - QVERIFY(unrarOutput.open(QIODevice::ReadOnly)); - - QTextStream unrarStream(&unrarOutput); - while (!unrarStream.atEnd()) { - const QString line(unrarStream.readLine()); - QVERIFY(rarPlugin->readListLine(line)); - } - - qDebug() << "Entries found:" << spy.count(); - QCOMPARE(spy.count(), 3); - - // Check if the first entry's name is correctly parsed. - ArchiveEntry entry = qvariant_cast(spy.at(0).at(0)); - QCOMPARE(entry[FileName].toString(), QStringLiteral("foo/hello2")); - - rarPlugin->deleteLater(); -} - -void CliRarTest::testUnrar4EncryptedFiles() -{ - QVariantList args; - args.append(QStringLiteral("DummyArchive.rar")); - - CliPlugin *rarPlugin = new CliPlugin(this, args); - QVERIFY(rarPlugin->open()); - - QSignalSpy spy(rarPlugin, SIGNAL(entry(ArchiveEntry))); - - QFile unrarOutput(QFINDTESTDATA("data/testUnrar4EncryptedFiles.txt")); - QVERIFY(unrarOutput.open(QIODevice::ReadOnly)); - - QTextStream unrarStream(&unrarOutput); - while (!unrarStream.atEnd()) { - const QString line(unrarStream.readLine()); - QVERIFY(rarPlugin->readListLine(line)); - } + QFETCH(Archive::EncryptionType, expectedEncryptionType); + QCOMPARE(archive->encryptionType(), expectedEncryptionType); - qDebug() << "Entries found:" << spy.count(); - QCOMPARE(spy.count(), 4); - - // Check if the fourth entry's name is correctly parsed. - ArchiveEntry entry = qvariant_cast(spy.at(3).at(0)); - QCOMPARE(entry[FileName].toString(), QStringLiteral("file4.txt")); - - rarPlugin->deleteLater(); + QFETCH(QString, expectedSubfolderName); + QCOMPARE(archive->subfolderName(), expectedSubfolderName); } -void CliRarTest::testUnrar5EncryptedFiles() +void CliRarTest::testList_data() { - QVariantList args; - args.append(QStringLiteral("DummyArchive.rar")); - - CliPlugin *rarPlugin = new CliPlugin(this, args); - QVERIFY(rarPlugin->open()); - - QSignalSpy spy(rarPlugin, SIGNAL(entry(ArchiveEntry))); - - QFile unrarOutput(QFINDTESTDATA("data/testUnrar5EncryptedFiles.txt")); - QVERIFY(unrarOutput.open(QIODevice::ReadOnly)); - - QTextStream unrarStream(&unrarOutput); - while (!unrarStream.atEnd()) { - const QString line(unrarStream.readLine()); - QVERIFY(rarPlugin->readListLine(line)); - } - - qDebug() << "Entries found:" << spy.count(); - QCOMPARE(spy.count(), 4); - - // Check if the fourth entry's name is correctly parsed. - ArchiveEntry entry = qvariant_cast(spy.at(3).at(0)); - QCOMPARE(entry[FileName].toString(), QStringLiteral("file4.txt")); - - rarPlugin->deleteLater(); + QTest::addColumn("outputTextFile"); + QTest::addColumn("expectedEntriesCount"); + // Index of some entry to be tested. + QTest::addColumn("someEntryIndex"); + // Entry metadata. + QTest::addColumn("expectedName"); + QTest::addColumn("isDirectory"); + QTest::addColumn("isPasswordProtected"); + QTest::addColumn("symlinkTarget"); + QTest::addColumn("expectedSize"); + QTest::addColumn("expectedCompressedSize"); + QTest::addColumn("expectedTimestamp"); + + // Unrar 5 tests + + QTest::newRow("normal-file-unrar5") + << QFINDTESTDATA("data/archive-with-symlink-unrar5.txt") << 8 + << 2 << QStringLiteral("rartest/file2.txt") << false << false << QString() << (qulonglong) 14 << (qulonglong) 23 << QStringLiteral("2016-03-21T08:57:36"); + + QTest::newRow("symlink-unrar5") + << QFINDTESTDATA("data/archive-with-symlink-unrar5.txt") << 8 + << 3 << QStringLiteral("rartest/linktofile1.txt") << false << false << QStringLiteral("file1.txt") << (qulonglong) 9 << (qulonglong) 9 << QStringLiteral("2016-03-21T08:58:16"); + + QTest::newRow("encrypted-unrar5") + << QFINDTESTDATA("data/archive-encrypted-unrar5.txt") << 7 + << 2 << QStringLiteral("rartest/file2.txt") << false << true << QString() << (qulonglong) 14 << (qulonglong) 32 << QStringLiteral("2016-03-21T17:03:36"); + + QTest::newRow("recovery-record-unrar5") + << QFINDTESTDATA("data/archive-recovery-record-unrar5.txt") << 3 + << 0 << QStringLiteral("file1.txt") << false << false << QString() << (qulonglong) 32 << (qulonglong) 33 << QStringLiteral("2015-07-26T19:04:38"); + + QTest::newRow("corrupt-archive-unrar5") + << QFINDTESTDATA("data/archive-corrupt-file-header-unrar5.txt") << 8 + << 6 << QStringLiteral("dir1/") << true << false << QString() << (qulonglong) 0 << (qulonglong) 0 << QStringLiteral("2015-05-14T01:45:24"); + + // Unrar 4 tests + + QTest::newRow("normal-file-unrar4") + << QFINDTESTDATA("data/archive-with-symlink-unrar4.txt") << 8 + << 2 << QStringLiteral("rartest/file2.txt") << false << false << QString() << (qulonglong) 14 << (qulonglong) 23 << QStringLiteral("2016-03-21T08:57:00"); + + QTest::newRow("symlink-unrar4") + << QFINDTESTDATA("data/archive-with-symlink-unrar4.txt") << 8 + << 3 << QStringLiteral("rartest/linktofile1.txt") << false << false << QStringLiteral("file1.txt") << (qulonglong) 9 << (qulonglong) 9 << QStringLiteral("2016-03-21T08:58:00"); + + QTest::newRow("encrypted-unrar4") + << QFINDTESTDATA("data/archive-encrypted-unrar4.txt") << 7 + << 2 << QStringLiteral("rartest/file2.txt") << false << true << QString() << (qulonglong) 14 << (qulonglong) 32 << QStringLiteral("2016-03-21T17:03:00"); + + QTest::newRow("recovery-record-unrar4") + << QFINDTESTDATA("data/archive-recovery-record-unrar4.txt") << 3 + << 0 << QStringLiteral("file1.txt") << false << false << QString() << (qulonglong) 32 << (qulonglong) 33 << QStringLiteral("2015-07-26T19:04:00"); + + QTest::newRow("corrupt-archive-unrar4") + << QFINDTESTDATA("data/archive-corrupt-file-header-unrar4.txt") << 8 + << 6 << QStringLiteral("dir1/") << true << false << QString() << (qulonglong) 0 << (qulonglong) 0 << QStringLiteral("2015-05-14T01:45:00"); + + /* + * Check that the plugin will not crash when reading corrupted archives, which + * have lines such as "Unexpected end of archive" or "??? - the file header is + * corrupt" instead of a file name and the header string after it. + * + * See bug 262857 and commit 2042997013432cdc6974f5b26d39893a21e21011. + */ + QTest::newRow("corrupt-archive-unrar3") + << QFINDTESTDATA("data/archive-corrupt-file-header-unrar3.txt") << 1 + << 0 << QStringLiteral("some-file.ext") << false << false << QString() << (qulonglong) 732522496 << (qulonglong) 14851208 << QStringLiteral("2010-10-29T20:47:00"); } -void CliRarTest::testUnrar4RecoveryRecord() +void CliRarTest::testList() { - QVariantList args; - args.append(QStringLiteral("DummyArchive.rar")); + CliPlugin *rarPlugin = new CliPlugin(this, {QStringLiteral("dummy.rar")}); + QSignalSpy signalSpy(rarPlugin, SIGNAL(entry(ArchiveEntry))); - CliPlugin *rarPlugin = new CliPlugin(this, args); - QVERIFY(rarPlugin->open()); + QFETCH(QString, outputTextFile); + QFETCH(int, expectedEntriesCount); - QSignalSpy spy(rarPlugin, SIGNAL(entry(ArchiveEntry))); + QFile outputText(outputTextFile); + QVERIFY(outputText.open(QIODevice::ReadOnly)); - QFile unrarOutput(QFINDTESTDATA("data/testUnrar4RecoveryRecord.txt")); - QVERIFY(unrarOutput.open(QIODevice::ReadOnly)); - - QTextStream unrarStream(&unrarOutput); - while (!unrarStream.atEnd()) { - const QString line(unrarStream.readLine()); + QTextStream outputStream(&outputText); + while (!outputStream.atEnd()) { + const QString line(outputStream.readLine()); QVERIFY(rarPlugin->readListLine(line)); } - qDebug() << "Entries found:" << spy.count(); - QCOMPARE(spy.count(), 3); - - // Check if the third entry's name is correctly parsed. - ArchiveEntry entry = qvariant_cast(spy.at(2).at(0)); - QCOMPARE(entry[FileName].toString(), QStringLiteral("file3.txt")); + QCOMPARE(signalSpy.count(), expectedEntriesCount); - rarPlugin->deleteLater(); -} + QFETCH(int, someEntryIndex); + QVERIFY(someEntryIndex < signalSpy.count()); + ArchiveEntry entry = qvariant_cast(signalSpy.at(someEntryIndex).at(0)); -void CliRarTest::testUnrar5RecoveryRecord() -{ - QVariantList args; - args.append(QStringLiteral("DummyArchive.rar")); + QFETCH(QString, expectedName); + QCOMPARE(entry[FileName].toString(), expectedName); - CliPlugin *rarPlugin = new CliPlugin(this, args); - QVERIFY(rarPlugin->open()); + QFETCH(bool, isDirectory); + QCOMPARE(entry[IsDirectory].toBool(), isDirectory); - QSignalSpy spy(rarPlugin, SIGNAL(entry(ArchiveEntry))); + QFETCH(bool, isPasswordProtected); + QCOMPARE(entry[IsPasswordProtected].toBool(), isPasswordProtected); - QFile unrarOutput(QFINDTESTDATA("data/testUnrar5RecoveryRecord.txt")); - QVERIFY(unrarOutput.open(QIODevice::ReadOnly)); + QFETCH(QString, symlinkTarget); + QCOMPARE(entry[Link].toString(), symlinkTarget); - QTextStream unrarStream(&unrarOutput); - while (!unrarStream.atEnd()) { - const QString line(unrarStream.readLine()); - QVERIFY(rarPlugin->readListLine(line)); - } + QFETCH(qulonglong, expectedSize); + QCOMPARE(entry[Size].toULongLong(), expectedSize); - qDebug() << "Entries found:" << spy.count(); - QCOMPARE(spy.count(), 3); + QFETCH(qulonglong, expectedCompressedSize); + QCOMPARE(entry[CompressedSize].toULongLong(), expectedCompressedSize); - // Check if the third entry's name is correctly parsed. - ArchiveEntry entry = qvariant_cast(spy.at(2).at(0)); - QCOMPARE(entry[FileName].toString(), QStringLiteral("file3.txt")); + QFETCH(QString, expectedTimestamp); + QCOMPARE(entry[Timestamp].toString(), expectedTimestamp); rarPlugin->deleteLater(); } diff --git a/autotests/plugins/clirarplugin/clirartest.h b/autotests/plugins/clirarplugin/clirartest.h index 34642fc3..3ea9eab6 100644 --- a/autotests/plugins/clirarplugin/clirartest.h +++ b/autotests/plugins/clirarplugin/clirartest.h @@ -1,52 +1,52 @@ /* * Copyright (c) 2011 Raphael Kubo da Costa + * Copyright (c) 2015,2016 Ragnar Thomsen * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef CLIRARTEST_H #define CLIRARTEST_H #include "cliplugin.h" #include using namespace Kerfuffle; class CliRarTest : public QObject { Q_OBJECT private Q_SLOTS: - void testReadCorruptedArchive(); - void testUnrar4Normal(); - void testUnrar5Normal(); - void testUnrar4Symlink(); - void testUnrar5Symlink(); - void testUnrar4EncryptedFiles(); - void testUnrar5EncryptedFiles(); - void testUnrar4RecoveryRecord(); - void testUnrar5RecoveryRecord(); + void initTestCase(); + void testArchive_data(); + void testArchive(); + void testList_data(); + void testList(); + +private: + KPluginMetaData m_pluginMetadata; }; Q_DECLARE_METATYPE(ArchiveEntry) #endif diff --git a/autotests/plugins/clirarplugin/data/testReadCorruptedArchive.txt b/autotests/plugins/clirarplugin/data/archive-corrupt-file-header-unrar3.txt similarity index 100% rename from autotests/plugins/clirarplugin/data/testReadCorruptedArchive.txt rename to autotests/plugins/clirarplugin/data/archive-corrupt-file-header-unrar3.txt diff --git a/autotests/plugins/clirarplugin/data/testUnrar4Normal.txt b/autotests/plugins/clirarplugin/data/archive-corrupt-file-header-unrar4.txt similarity index 92% rename from autotests/plugins/clirarplugin/data/testUnrar4Normal.txt rename to autotests/plugins/clirarplugin/data/archive-corrupt-file-header-unrar4.txt index 269fbb42..c78d0aea 100644 --- a/autotests/plugins/clirarplugin/data/testUnrar4Normal.txt +++ b/autotests/plugins/clirarplugin/data/archive-corrupt-file-header-unrar4.txt @@ -1,36 +1,38 @@ UNRAR 4.20 freeware Copyright (c) 1993-2012 Alexander Roshal -Archive testarchive.rar +file1.txt - the file header is corrupt +Archive testarchive-corrupt.rar +file1.txt - the file header is corrupt Pathname/Comment Size Packed Ratio Date Time Attr CRC Meth Ver Host OS Solid Old ------------------------------------------------------------------------------- file1.txt 32 33 103% 26-07-15 19:04 -rw-rw-r-- 034EE5C7 m3b 2.9 Unix No No file2.txt 32 32 100% 18-05-15 14:57 -rw-rw-r-- D49ECBCA m3b 2.9 Unix No No file3.txt 32 32 100% 13-05-15 17:26 -rw-rw-r-- 99D12E31 m3b 2.9 Unix No No file4.txt 32 33 103% 26-07-15 18:53 -rw-rw-r-- A04F9191 m3b 2.9 Unix No No dir1/file1.txt 32 33 103% 17-05-15 20:41 -rw-rw-r-- 034EE5C7 m3b 2.9 Unix No No dir2/file2.txt 32 32 100% 17-05-15 20:41 -rw-rw-r-- D49ECBCA m3b 2.9 Unix No No dir1 0 0 0% 14-05-15 01:45 drwxrwxr-x 00000000 m0 2.0 Unix No No dir2 0 0 0% 14-05-15 01:43 drwxrwxr-x 00000000 m0 2.0 Unix No No ------------------------------------------------------------------------------- 8 192 195 101% diff --git a/autotests/plugins/clirarplugin/data/testUnrar5Normal.txt b/autotests/plugins/clirarplugin/data/archive-corrupt-file-header-unrar5.txt similarity index 91% rename from autotests/plugins/clirarplugin/data/testUnrar5Normal.txt rename to autotests/plugins/clirarplugin/data/archive-corrupt-file-header-unrar5.txt index a8282fcd..df11d13d 100644 --- a/autotests/plugins/clirarplugin/data/testUnrar5Normal.txt +++ b/autotests/plugins/clirarplugin/data/archive-corrupt-file-header-unrar5.txt @@ -1,88 +1,90 @@ -UNRAR 5.30 beta 2 freeware Copyright (c) 1993-2015 Alexander Roshal +UNRAR 5.31 freeware Copyright (c) 1993-2016 Alexander Roshal -Archive: testarchive.rar +file1.txt - the file header is corrupt +Archive: testarchive-corrupt.rar Details: RAR 4 +file1.txt - the file header is corrupt Name: file1.txt Type: File Size: 32 Packed size: 33 Ratio: 103% mtime: 2015-07-26 19:04:38,000 Attributes: -rw-rw-r-- CRC32: 034EE5C7 Host OS: Unix Compression: RAR 3.0(v29) -m3 -md=128K Name: file2.txt Type: File Size: 32 Packed size: 32 Ratio: 100% mtime: 2015-05-18 14:57:37,000 Attributes: -rw-rw-r-- CRC32: D49ECBCA Host OS: Unix Compression: RAR 3.0(v29) -m3 -md=128K Name: file3.txt Type: File Size: 32 Packed size: 32 Ratio: 100% mtime: 2015-05-13 17:26:42,000 Attributes: -rw-rw-r-- CRC32: 99D12E31 Host OS: Unix Compression: RAR 3.0(v29) -m3 -md=128K Name: file4.txt Type: File Size: 32 Packed size: 33 Ratio: 103% mtime: 2015-07-26 18:53:21,000 Attributes: -rw-rw-r-- CRC32: A04F9191 Host OS: Unix Compression: RAR 3.0(v29) -m3 -md=128K Name: dir1/file1.txt Type: File Size: 32 Packed size: 33 Ratio: 103% mtime: 2015-05-17 20:41:48,000 Attributes: -rw-rw-r-- CRC32: 034EE5C7 Host OS: Unix Compression: RAR 3.0(v29) -m3 -md=128K Name: dir2/file2.txt Type: File Size: 32 Packed size: 32 Ratio: 100% mtime: 2015-05-17 20:41:48,000 Attributes: -rw-rw-r-- CRC32: D49ECBCA Host OS: Unix Compression: RAR 3.0(v29) -m3 -md=128K Name: dir1 Type: Directory mtime: 2015-05-14 01:45:24,000 Attributes: drwxrwxr-x CRC32: 00000000 Host OS: Unix Compression: RAR 3.0(v20) -m0 -md=0K Name: dir2 Type: Directory mtime: 2015-05-14 01:43:41,000 Attributes: drwxrwxr-x CRC32: 00000000 Host OS: Unix Compression: RAR 3.0(v20) -m0 -md=0K diff --git a/autotests/plugins/clirarplugin/data/archive-encrypted-unrar4.txt b/autotests/plugins/clirarplugin/data/archive-encrypted-unrar4.txt new file mode 100644 index 00000000..52d7faec --- /dev/null +++ b/autotests/plugins/clirarplugin/data/archive-encrypted-unrar4.txt @@ -0,0 +1,33 @@ + +UNRAR 4.20 freeware Copyright (c) 1993-2012 Alexander Roshal + +Archive rartestenc.rar + +Pathname/Comment + Size Packed Ratio Date Time Attr CRC Meth Ver + Host OS Solid Old +------------------------------------------------------------------------------- +*rartest/file4.txt + 32 48 150% 21-03-16 17:03 -rw-rw-r-- A04F9191 m3b 2.9 + Unix No No +*rartest/file1.txt + 32 48 150% 21-03-16 17:03 -rw-rw-r-- 034EE5C7 m3b 2.9 + Unix No No +*rartest/file2.txt + 14 32 228% 21-03-16 17:03 -rw-rw-r-- A5BA4A7B m3b 2.9 + Unix No No +*rartest/dir1/file11.txt + 32 48 150% 21-03-16 17:03 -rw-rw-r-- 034EE5C7 m3b 2.9 + Unix No No +*rartest/file3.txt + 32 32 100% 21-03-16 17:03 -rw-rw-r-- 99D12E31 m3b 2.9 + Unix No No + rartest/dir1 + 0 0 0% 21-03-16 17:03 drwxrwxr-x 00000000 m0 2.9 + Unix No No + rartest + 0 0 0% 21-03-16 17:03 drwxrwxr-x 00000000 m0 2.9 + Unix No No +------------------------------------------------------------------------------- + 7 142 208 146% + diff --git a/autotests/plugins/clirarplugin/data/archive-encrypted-unrar5.txt b/autotests/plugins/clirarplugin/data/archive-encrypted-unrar5.txt new file mode 100644 index 00000000..6c644795 --- /dev/null +++ b/autotests/plugins/clirarplugin/data/archive-encrypted-unrar5.txt @@ -0,0 +1,82 @@ + +UNRAR 5.31 freeware Copyright (c) 1993-2016 Alexander Roshal + +Archive: rartestenc.rar +Details: RAR 4 + + Name: rartest/file4.txt + Type: File + Size: 32 + Packed size: 48 + Ratio: 150% + mtime: 2016-03-21 17:03:36,000 + Attributes: -rw-rw-r-- + CRC32: A04F9191 + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=128K + Flags: encrypted + + Name: rartest/file1.txt + Type: File + Size: 32 + Packed size: 48 + Ratio: 150% + mtime: 2016-03-21 17:03:36,000 + Attributes: -rw-rw-r-- + CRC32: 034EE5C7 + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=128K + Flags: encrypted + + Name: rartest/file2.txt + Type: File + Size: 14 + Packed size: 32 + Ratio: 228% + mtime: 2016-03-21 17:03:36,000 + Attributes: -rw-rw-r-- + CRC32: A5BA4A7B + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=128K + Flags: encrypted + + Name: rartest/dir1/file11.txt + Type: File + Size: 32 + Packed size: 48 + Ratio: 150% + mtime: 2016-03-21 17:03:36,000 + Attributes: -rw-rw-r-- + CRC32: 034EE5C7 + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=128K + Flags: encrypted + + Name: rartest/file3.txt + Type: File + Size: 32 + Packed size: 32 + Ratio: 100% + mtime: 2016-03-21 17:03:36,000 + Attributes: -rw-rw-r-- + CRC32: 99D12E31 + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=128K + Flags: encrypted + + Name: rartest/dir1 + Type: Directory + mtime: 2016-03-21 17:03:36,000 + Attributes: drwxrwxr-x + CRC32: 00000000 + Host OS: Unix + Compression: RAR 3.0(v29) -m0 -md=0K + + Name: rartest + Type: Directory + mtime: 2016-03-21 17:03:44,000 + Attributes: drwxrwxr-x + CRC32: 00000000 + Host OS: Unix + Compression: RAR 3.0(v29) -m0 -md=0K + diff --git a/autotests/plugins/clirarplugin/data/testUnrar4RecoveryRecord.txt b/autotests/plugins/clirarplugin/data/archive-recovery-record-unrar4.txt similarity index 100% rename from autotests/plugins/clirarplugin/data/testUnrar4RecoveryRecord.txt rename to autotests/plugins/clirarplugin/data/archive-recovery-record-unrar4.txt diff --git a/autotests/plugins/clirarplugin/data/testUnrar5RecoveryRecord.txt b/autotests/plugins/clirarplugin/data/archive-recovery-record-unrar5.txt similarity index 100% rename from autotests/plugins/clirarplugin/data/testUnrar5RecoveryRecord.txt rename to autotests/plugins/clirarplugin/data/archive-recovery-record-unrar5.txt diff --git a/autotests/plugins/clirarplugin/data/archive-with-symlink-unrar4.txt b/autotests/plugins/clirarplugin/data/archive-with-symlink-unrar4.txt new file mode 100644 index 00000000..721f916d --- /dev/null +++ b/autotests/plugins/clirarplugin/data/archive-with-symlink-unrar4.txt @@ -0,0 +1,37 @@ + +UNRAR 4.20 freeware Copyright (c) 1993-2012 Alexander Roshal + +Archive rartest.rar + +Pathname/Comment + Size Packed Ratio Date Time Attr CRC Meth Ver + Host OS Solid Old +------------------------------------------------------------------------------- + rartest/file4.txt + 32 33 103% 21-03-16 08:57 -rw-rw-r-- A04F9191 m3g 2.9 + Unix No No + rartest/file1.txt + 32 33 103% 21-03-16 08:57 -rw-rw-r-- 034EE5C7 m3g 2.9 + Unix No No + rartest/file2.txt + 14 23 164% 21-03-16 08:57 -rw-rw-r-- A5BA4A7B m3g 2.9 + Unix No No + rartest/linktofile1.txt + 9 9 100% 21-03-16 08:58 lrwxrwxrwx 2D212004 m0g 2.0 + Unix No No + --> file1.txt + rartest/dir1/file11.txt + 32 33 103% 21-03-16 08:58 -rw-rw-r-- 034EE5C7 m3g 2.9 + Unix No No + rartest/file3.txt + 32 32 100% 21-03-16 08:57 -rw-rw-r-- 99D12E31 m3g 2.9 + Unix No No + rartest/dir1 + 0 0 0% 21-03-16 08:58 drwxrwxr-x 00000000 m0 2.0 + Unix No No + rartest + 0 0 0% 21-03-16 08:58 drwxrwxr-x 00000000 m0 2.0 + Unix No No +------------------------------------------------------------------------------- + 8 151 163 107% + diff --git a/autotests/plugins/clirarplugin/data/archive-with-symlink-unrar5.txt b/autotests/plugins/clirarplugin/data/archive-with-symlink-unrar5.txt new file mode 100644 index 00000000..1dfc7033 --- /dev/null +++ b/autotests/plugins/clirarplugin/data/archive-with-symlink-unrar5.txt @@ -0,0 +1,89 @@ + +UNRAR 5.31 freeware Copyright (c) 1993-2016 Alexander Roshal + +Archive: rartest.rar +Details: RAR 4 + + Name: rartest/file4.txt + Type: File + Size: 32 + Packed size: 33 + Ratio: 103% + mtime: 2016-03-21 08:57:36,000 + Attributes: -rw-rw-r-- + CRC32: A04F9191 + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=4M + + Name: rartest/file1.txt + Type: File + Size: 32 + Packed size: 33 + Ratio: 103% + mtime: 2016-03-21 08:57:36,000 + Attributes: -rw-rw-r-- + CRC32: 034EE5C7 + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=4M + + Name: rartest/file2.txt + Type: File + Size: 14 + Packed size: 23 + Ratio: 164% + mtime: 2016-03-21 08:57:36,000 + Attributes: -rw-rw-r-- + CRC32: A5BA4A7B + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=4M + + Name: rartest/linktofile1.txt + Type: Unix symbolic link + Target: file1.txt + Size: 9 + Packed size: 9 + Ratio: 100% + mtime: 2016-03-21 08:58:16,000 + Attributes: lrwxrwxrwx + CRC32: 2D212004 + Host OS: Unix + Compression: RAR 3.0(v20) -m0 -md=4M + + Name: rartest/dir1/file11.txt + Type: File + Size: 32 + Packed size: 33 + Ratio: 103% + mtime: 2016-03-21 08:58:40,000 + Attributes: -rw-rw-r-- + CRC32: 034EE5C7 + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=4M + + Name: rartest/file3.txt + Type: File + Size: 32 + Packed size: 32 + Ratio: 100% + mtime: 2016-03-21 08:57:36,000 + Attributes: -rw-rw-r-- + CRC32: 99D12E31 + Host OS: Unix + Compression: RAR 3.0(v29) -m3 -md=4M + + Name: rartest/dir1 + Type: Directory + mtime: 2016-03-21 08:58:40,000 + Attributes: drwxrwxr-x + CRC32: 00000000 + Host OS: Unix + Compression: RAR 3.0(v20) -m0 -md=0K + + Name: rartest + Type: Directory + mtime: 2016-03-21 08:58:24,000 + Attributes: drwxrwxr-x + CRC32: 00000000 + Host OS: Unix + Compression: RAR 3.0(v20) -m0 -md=0K + diff --git a/autotests/plugins/clirarplugin/data/one_toplevel_folder.rar b/autotests/plugins/clirarplugin/data/one_toplevel_folder.rar new file mode 100644 index 00000000..c1824c26 Binary files /dev/null and b/autotests/plugins/clirarplugin/data/one_toplevel_folder.rar differ diff --git a/autotests/plugins/clirarplugin/data/testUnrar4EncryptedFiles.txt b/autotests/plugins/clirarplugin/data/testUnrar4EncryptedFiles.txt deleted file mode 100644 index 3b5f52df..00000000 --- a/autotests/plugins/clirarplugin/data/testUnrar4EncryptedFiles.txt +++ /dev/null @@ -1,24 +0,0 @@ - -UNRAR 4.20 freeware Copyright (c) 1993-2012 Alexander Roshal - -Archive testpassfiles.rar - -Pathname/Comment - Size Packed Ratio Date Time Attr CRC Meth Ver - Host OS Solid Old -------------------------------------------------------------------------------- -*file1.txt - 32 48 150% 26-07-15 19:04 -rw-rw-r-- 034EE5C7 m3b 2.9 - Unix No No -*file2.txt - 32 32 100% 18-05-15 14:57 -rw-rw-r-- D49ECBCA m3b 2.9 - Unix No No -*file3.txt - 32 32 100% 13-05-15 17:26 -rw-rw-r-- 99D12E31 m3b 2.9 - Unix No No -*file4.txt - 32 48 150% 26-07-15 18:53 -rw-rw-r-- A04F9191 m3b 2.9 - Unix No No -------------------------------------------------------------------------------- - 4 128 160 125% - diff --git a/autotests/plugins/clirarplugin/data/testUnrar4Symlink.txt b/autotests/plugins/clirarplugin/data/testUnrar4Symlink.txt deleted file mode 100644 index e6db584d..00000000 --- a/autotests/plugins/clirarplugin/data/testUnrar4Symlink.txt +++ /dev/null @@ -1,22 +0,0 @@ - -UNRAR 4.20 (iconv) freeware Copyright (c) 1993-2012 Alexander Roshal - -Archive foo.rar - -Pathname/Comment - Size Packed Ratio Date Time Attr CRC Meth Ver - Host OS Solid Old -------------------------------------------------------------------------------- - foo/hello1 - 6 16 266% 12-02-14 23:15 -rw-r--r-- 363A3020 m3b 2.9 - Unix No No - foo/hello2 - 6 6 100% 12-02-14 23:15 lrwxr-xr-x 8731D904 m0b 2.0 - Unix No No - --> hello1 - foo - 0 0 0% 12-02-14 23:15 drwxr-xr-x 00000000 m0 2.0 - Unix No No -------------------------------------------------------------------------------- - 3 12 22 183% - diff --git a/autotests/plugins/clirarplugin/data/testUnrar5EncryptedFiles.txt b/autotests/plugins/clirarplugin/data/testUnrar5EncryptedFiles.txt deleted file mode 100644 index 54257e8b..00000000 --- a/autotests/plugins/clirarplugin/data/testUnrar5EncryptedFiles.txt +++ /dev/null @@ -1,54 +0,0 @@ - -UNRAR 5.30 beta 2 freeware Copyright (c) 1993-2015 Alexander Roshal - -Archive: testpassfiles.rar -Details: RAR 4 - - Name: file1.txt - Type: File - Size: 32 - Packed size: 48 - Ratio: 150% - mtime: 2015-07-26 19:04:38,000 - Attributes: -rw-rw-r-- - CRC32: 034EE5C7 - Host OS: Unix - Compression: RAR 3.0(v29) -m3 -md=128K - Flags: encrypted - - Name: file2.txt - Type: File - Size: 32 - Packed size: 32 - Ratio: 100% - mtime: 2015-05-18 14:57:37,000 - Attributes: -rw-rw-r-- - CRC32: D49ECBCA - Host OS: Unix - Compression: RAR 3.0(v29) -m3 -md=128K - Flags: encrypted - - Name: file3.txt - Type: File - Size: 32 - Packed size: 32 - Ratio: 100% - mtime: 2015-05-13 17:26:42,000 - Attributes: -rw-rw-r-- - CRC32: 99D12E31 - Host OS: Unix - Compression: RAR 3.0(v29) -m3 -md=128K - Flags: encrypted - - Name: file4.txt - Type: File - Size: 32 - Packed size: 48 - Ratio: 150% - mtime: 2015-07-26 18:53:21,000 - Attributes: -rw-rw-r-- - CRC32: A04F9191 - Host OS: Unix - Compression: RAR 3.0(v29) -m3 -md=128K - Flags: encrypted - diff --git a/autotests/plugins/clirarplugin/data/testUnrar5Symlink.txt b/autotests/plugins/clirarplugin/data/testUnrar5Symlink.txt deleted file mode 100644 index bce49e77..00000000 --- a/autotests/plugins/clirarplugin/data/testUnrar5Symlink.txt +++ /dev/null @@ -1,37 +0,0 @@ - -UNRAR 5.30 beta 2 freeware Copyright (c) 1993-2015 Alexander Roshal - -Archive: foo.rar -Details: RAR 4 - - Name: foo/hello2 - Type: Unix symbolic link - Target: hello1 - Size: 6 - Packed size: 6 - Ratio: 100% - mtime: 2015-08-08 21:45:43,000 - Attributes: lrwxrwxrwx - CRC32: 8731D904 - Host OS: Unix - Compression: RAR 3.0(v20) -m0 -md=4M - - Name: foo/hello1 - Type: File - Size: 32 - Packed size: 33 - Ratio: 103% - mtime: 2015-08-08 21:45:21,000 - Attributes: -rw-rw-r-- - CRC32: 034EE5C7 - Host OS: Unix - Compression: RAR 3.0(v29) -m3 -md=4M - - Name: foo - Type: Directory - mtime: 2015-08-08 21:45:43,000 - Attributes: drwxrwxr-x - CRC32: 00000000 - Host OS: Unix - Compression: RAR 3.0(v20) -m0 -md=0K -