TestKdbx4.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_TEST_KDBX4_H
  18. #define KEEPASSXC_TEST_KDBX4_H
  19. #include "TestKeePass2Format.h"
  20. class TestKdbx4Argon2 : public TestKeePass2Format
  21. {
  22. Q_OBJECT
  23. protected:
  24. void initTestCaseImpl() override;
  25. QSharedPointer<Database> readXml(QBuffer* buf, bool strictMode, bool& hasError, QString& errorString) override;
  26. QSharedPointer<Database>
  27. readXml(const QString& path, bool strictMode, bool& hasError, QString& errorString) override;
  28. void writeXml(QBuffer* buf, Database* db, bool& hasError, QString& errorString) override;
  29. void readKdbx(QIODevice* device,
  30. QSharedPointer<const CompositeKey> key,
  31. QSharedPointer<Database> db,
  32. bool& hasError,
  33. QString& errorString) override;
  34. void writeKdbx(QIODevice* device, Database* db, bool& hasError, QString& errorString) override;
  35. };
  36. class TestKdbx4AesKdf : public TestKdbx4Argon2
  37. {
  38. Q_OBJECT
  39. protected:
  40. void initTestCaseImpl() override;
  41. };
  42. /**
  43. * KDF-independent KDBX4 format tests.
  44. */
  45. class TestKdbx4Format : public QObject
  46. {
  47. Q_OBJECT
  48. private slots:
  49. void init();
  50. void cleanup();
  51. void testFormat400();
  52. void testFormat400Upgrade();
  53. void testFormat400Upgrade_data();
  54. void testFormat410Upgrade();
  55. void testUpgradeMasterKeyIntegrity();
  56. void testUpgradeMasterKeyIntegrity_data();
  57. void testAttachmentIndexStability();
  58. void testCustomData();
  59. };
  60. #endif // KEEPASSXC_TEST_KDBX4_H