diff options
author | Jonathan White <support@dmapps.us> | 2020-08-26 22:17:31 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2020-12-06 19:16:49 +0300 |
commit | 7ac651763c05daf0d4871abe52aeff903c664178 (patch) | |
tree | 7ad3b3665fc6d30dc45d03b76da88a4042e64fde /tests/TestCsvExporter.cpp | |
parent | 3f7e79cdf33876506c4c169828bcfd177a4c97eb (diff) |
Improve CSV export and import capability
* Fixes #3541
* CSV export now includes TOTP settings, Entry Icon (database icon number only), Modified Time, and Created Time.
* CSV import properly understands time in ISO 8601 format and Unix Timestamp.
* CSV import will set the TOTP settings and entry icon based on the chosen column.
Diffstat (limited to 'tests/TestCsvExporter.cpp')
-rw-r--r-- | tests/TestCsvExporter.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/TestCsvExporter.cpp b/tests/TestCsvExporter.cpp index 63ba11488..8e7e6021d 100644 --- a/tests/TestCsvExporter.cpp +++ b/tests/TestCsvExporter.cpp @@ -23,11 +23,13 @@ #include "crypto/Crypto.h" #include "format/CsvExporter.h" +#include "totp/totp.h" QTEST_GUILESS_MAIN(TestCsvExporter) const QString TestCsvExporter::ExpectedHeaderLine = - QString("\"Group\",\"Title\",\"Username\",\"Password\",\"URL\",\"Notes\"\n"); + QString("\"Group\",\"Title\",\"Username\",\"Password\",\"URL\",\"Notes\",\"TOTP\",\"Icon\",\"Last " + "Modified\",\"Created\"\n"); void TestCsvExporter::init() { @@ -57,17 +59,23 @@ void TestCsvExporter::testExport() entry->setPassword("Test Password"); entry->setUrl("http://test.url"); entry->setNotes("Test Notes"); + entry->setTotp(Totp::createSettings("DFDF", Totp::DEFAULT_DIGITS, Totp::DEFAULT_STEP)); + entry->setIcon(5); QBuffer buffer; QVERIFY(buffer.open(QIODevice::ReadWrite)); m_csvExporter->exportDatabase(&buffer, m_db); + auto exported = QString::fromUtf8(buffer.buffer()); QString expectedResult = QString() .append(ExpectedHeaderLine) .append("\"Passwords/Test Group Name\",\"Test Entry Title\",\"Test Username\",\"Test " - "Password\",\"http://test.url\",\"Test Notes\"\n"); + "Password\",\"http://test.url\",\"Test Notes\""); - QCOMPARE(QString::fromUtf8(buffer.buffer().constData()), expectedResult); + QVERIFY(exported.startsWith(expectedResult)); + exported.remove(expectedResult); + QVERIFY(exported.contains("otpauth://")); + QVERIFY(exported.contains(",\"5\",")); } void TestCsvExporter::testEmptyDatabase() @@ -95,10 +103,9 @@ void TestCsvExporter::testNestedGroups() QBuffer buffer; QVERIFY(buffer.open(QIODevice::ReadWrite)); m_csvExporter->exportDatabase(&buffer, m_db); - - QCOMPARE( - QString::fromUtf8(buffer.buffer().constData()), + auto exported = QString::fromUtf8(buffer.buffer()); + QVERIFY(exported.startsWith( QString() .append(ExpectedHeaderLine) - .append("\"Passwords/Test Group Name/Test Sub Group Name\",\"Test Entry Title\",\"\",\"\",\"\",\"\"\n")); + .append("\"Passwords/Test Group Name/Test Sub Group Name\",\"Test Entry Title\",\"\",\"\",\"\",\"\""))); } |