TestKeePass2Format.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 or (at your option)
  7. * version 3 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef KEEPASSXC_TESTKEEPASS2FORMAT_H
  18. #define KEEPASSXC_TESTKEEPASS2FORMAT_H
  19. #include <QBuffer>
  20. #include "core/Database.h"
  21. /**
  22. * Abstract base class for version-dependent KDBX file format tests.
  23. */
  24. class TestKeePass2Format : public QObject
  25. {
  26. Q_OBJECT
  27. private slots:
  28. void initTestCase();
  29. /**
  30. * XML Reader / writer tests.
  31. */
  32. void testXmlMetadata();
  33. void testXmlCustomIcons();
  34. void testXmlGroupRoot();
  35. void testXmlGroup1();
  36. void testXmlGroup2();
  37. void testXmlEntry1();
  38. void testXmlEntry2();
  39. void testXmlEntryHistory();
  40. void testXmlDeletedObjects();
  41. void testXmlBroken();
  42. void testXmlBroken_data();
  43. void testXmlEmptyUuids();
  44. void testXmlInvalidXmlChars();
  45. void testXmlRepairUuidHistoryItem();
  46. /**
  47. * KDBX binary format tests.
  48. */
  49. void testReadBackTargetDb();
  50. void testKdbxBasic();
  51. void testKdbxProtectedAttributes();
  52. void testKdbxAttachments();
  53. void testKdbxNonAsciiPasswords();
  54. void testKdbxDeviceFailure();
  55. void testKdbxKeyChange();
  56. void testKdbxKeyChange_data();
  57. void testDuplicateAttachments();
  58. protected:
  59. virtual void initTestCaseImpl() = 0;
  60. virtual QSharedPointer<Database> readXml(QBuffer* buf, bool strictMode, bool& hasError, QString& errorString) = 0;
  61. virtual QSharedPointer<Database>
  62. readXml(const QString& path, bool strictMode, bool& hasError, QString& errorString) = 0;
  63. virtual void writeXml(QBuffer* buf, Database* db, bool& hasError, QString& errorString) = 0;
  64. virtual void readKdbx(QIODevice* device,
  65. QSharedPointer<const CompositeKey> key,
  66. QSharedPointer<Database> db,
  67. bool& hasError,
  68. QString& errorString) = 0;
  69. virtual void writeKdbx(QIODevice* device, Database* db, bool& hasError, QString& errorString) = 0;
  70. QSharedPointer<Database> m_xmlDb;
  71. QSharedPointer<Database> m_kdbxSourceDb;
  72. QSharedPointer<Database> m_kdbxTargetDb;
  73. private:
  74. QBuffer m_kdbxTargetBuffer;
  75. };
  76. QSharedPointer<Kdf> fastKdf(QSharedPointer<Kdf> kdf);
  77. #endif // KEEPASSXC_TESTKEEPASS2FORMAT_H