TestCli.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2019 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_TESTCLI_H
  18. #define KEEPASSXC_TESTCLI_H
  19. #include <QBuffer>
  20. #include "util/TemporaryFile.h"
  21. class Command;
  22. class Database;
  23. class TestCli : public QObject
  24. {
  25. Q_OBJECT
  26. private:
  27. QSharedPointer<Database>
  28. readDatabase(const QString& filename = {}, const QString& pw = {}, const QString& keyfile = {});
  29. int execCmd(Command& cmd, const QStringList& args) const;
  30. bool isTotp(const QString& value);
  31. void setInput(const QString& input);
  32. void setInput(const QStringList& input);
  33. private slots:
  34. void initTestCase();
  35. void init();
  36. void cleanup();
  37. void cleanupTestCase();
  38. void testBatchCommands();
  39. void testAdd();
  40. void testAddGroup();
  41. void testAnalyze();
  42. void testAttachmentExport();
  43. void testAttachmentImport();
  44. void testAttachmentRemove();
  45. void testClip();
  46. void testCommandParsing_data();
  47. void testCommandParsing();
  48. void testCreate();
  49. void testDatabaseEdit();
  50. void testDiceware();
  51. void testEdit();
  52. void testEstimate_data();
  53. void testEstimate();
  54. void testExport();
  55. void testGenerate_data();
  56. void testGenerate();
  57. void testImport();
  58. void testInfo();
  59. void testKeyFileOption();
  60. void testNoPasswordOption();
  61. void testHelp();
  62. void testInteractiveCommands();
  63. void testList();
  64. void testMerge();
  65. void testMergeWithKeys();
  66. void testMove();
  67. void testOpen();
  68. void testRemove();
  69. void testRemoveGroup();
  70. void testRemoveQuiet();
  71. void testSearch();
  72. void testShow();
  73. void testInvalidDbFiles();
  74. void testYubiKeyOption();
  75. void testNonAscii();
  76. private:
  77. QScopedPointer<QFile> m_devNull;
  78. QScopedPointer<TemporaryFile> m_dbFile;
  79. QScopedPointer<TemporaryFile> m_dbFile2;
  80. QScopedPointer<TemporaryFile> m_dbFileMulti;
  81. QScopedPointer<TemporaryFile> m_xmlFile;
  82. QScopedPointer<TemporaryFile> m_keyFileProtectedDbFile;
  83. QScopedPointer<TemporaryFile> m_keyFileProtectedNoPasswordDbFile;
  84. QScopedPointer<TemporaryFile> m_yubiKeyProtectedDbFile;
  85. QScopedPointer<TemporaryFile> m_nonAsciiDbFile;
  86. QScopedPointer<QBuffer> m_stdout;
  87. QScopedPointer<QBuffer> m_stderr;
  88. QScopedPointer<QBuffer> m_stdin;
  89. };
  90. #endif // KEEPASSXC_TESTCLI_H