aboutsummaryrefslogtreecommitdiff
path: root/autotests
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2022-03-08 00:06:36 +0100
committerTobias Fella <fella@posteo.de>2022-05-16 20:47:17 +0200
commitefa450920e5fc338e771e653ca0889e948d04ee7 (patch)
tree215efb53d0e06ed660a97593d56ffb4868dbc2e2 /autotests
parent6f5ac9b7315d75692960e5eac7b1eb6867c0d203 (diff)
downloadlibquotient-efa450920e5fc338e771e653ca0889e948d04ee7.tar.gz
libquotient-efa450920e5fc338e771e653ca0889e948d04ee7.zip
Implement sending encrypted files
Diffstat (limited to 'autotests')
-rw-r--r--autotests/CMakeLists.txt1
-rw-r--r--autotests/testfilecrypto.cpp17
-rw-r--r--autotests/testfilecrypto.h12
3 files changed, 30 insertions, 0 deletions
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 671d6c08..c11901bf 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -18,4 +18,5 @@ if(${PROJECT_NAME}_ENABLE_E2EE)
quotient_add_test(NAME testgroupsession)
quotient_add_test(NAME testolmsession)
quotient_add_test(NAME testolmutility)
+ quotient_add_test(NAME testfilecrypto)
endif()
diff --git a/autotests/testfilecrypto.cpp b/autotests/testfilecrypto.cpp
new file mode 100644
index 00000000..e6bec1fe
--- /dev/null
+++ b/autotests/testfilecrypto.cpp
@@ -0,0 +1,17 @@
+// SPDX-FileCopyrightText: 2022 Tobias Fella <fella@posteo.de>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#include "testfilecrypto.h"
+#include "events/encryptedfile.h"
+#include <qtest.h>
+
+using namespace Quotient;
+void TestFileCrypto::encryptDecryptData()
+{
+ QByteArray data = "ABCDEF";
+ auto [file, cipherText] = EncryptedFile::encryptFile(data);
+ auto decrypted = file.decryptFile(cipherText);
+ QCOMPARE(data, decrypted);
+}
+QTEST_APPLESS_MAIN(TestFileCrypto)
diff --git a/autotests/testfilecrypto.h b/autotests/testfilecrypto.h
new file mode 100644
index 00000000..9096a8c7
--- /dev/null
+++ b/autotests/testfilecrypto.h
@@ -0,0 +1,12 @@
+// SPDX-FileCopyrightText: 2022 Tobias Fella <fella@posteo.de>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#include <QtTest/QtTest>
+
+class TestFileCrypto : public QObject
+{
+ Q_OBJECT
+private Q_SLOTS:
+ void encryptDecryptData();
+};