Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek Bevendorff <janek@jbev.net>2018-01-17 20:15:37 +0300
committerJanek Bevendorff <janek@jbev.net>2018-01-18 03:51:34 +0300
commitcdefc7ea9bdfe89e86d57d3155ce35ac2347d719 (patch)
tree003522b990f499aee0d1e623fe76630dcc1e6431 /tests/TestKdbx4.cpp
parent92dd4c0d99babb4d08adefdf01e0bed7ab8afe3d (diff)
Fix KDBX reader tests not being executed
Diffstat (limited to 'tests/TestKdbx4.cpp')
-rw-r--r--tests/TestKdbx4.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/TestKdbx4.cpp b/tests/TestKdbx4.cpp
new file mode 100644
index 000000000..e67274cbd
--- /dev/null
+++ b/tests/TestKdbx4.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 or (at your option)
+ * version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "TestKdbx4.h"
+#include "core/Metadata.h"
+#include "crypto/Crypto.h"
+#include "format/KeePass2.h"
+#include "format/KdbxXmlReader.h"
+#include "format/KdbxXmlWriter.h"
+#include "config-keepassx-tests.h"
+
+#include <QTest>
+
+QTEST_GUILESS_MAIN(TestKdbx4)
+
+void TestKdbx4::initTestCase()
+{
+ QVERIFY(Crypto::init());
+
+ KdbxXmlReader reader(KeePass2::FILE_VERSION_3);
+ reader.setStrictMode(true);
+ QString xmlFile = QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.xml");
+ m_db.reset(reader.readDatabase(xmlFile));
+ QVERIFY(m_db.data());
+ QVERIFY(!reader.hasError());
+}
+
+Database* TestKdbx4::readDatabase(QString path, bool strictMode, bool& hasError, QString& errorString)
+{
+ KdbxXmlReader reader(KeePass2::FILE_VERSION_3);
+ reader.setStrictMode(strictMode);
+ auto db = reader.readDatabase(path);
+ hasError = reader.hasError();
+ errorString = reader.errorString();
+ return db;
+}
+
+Database* TestKdbx4::readDatabase(QBuffer* buf, bool strictMode, bool& hasError, QString& errorString)
+{
+ KdbxXmlReader reader(KeePass2::FILE_VERSION_3);
+ reader.setStrictMode(strictMode);
+ auto db = reader.readDatabase(buf);
+ hasError = reader.hasError();
+ errorString = reader.errorString();
+ return db;
+}
+
+void TestKdbx4::writeDatabase(QBuffer* buf, Database* db, bool& hasError, QString& errorString)
+{
+ KdbxXmlWriter writer(KeePass2::FILE_VERSION_3);
+ writer.writeDatabase(buf, db);
+ hasError = writer.hasError();
+ errorString = writer.errorString();
+}