[network/ruqola] src/core/autotests: Improve autotest
Laurent Montel <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 181c2f13b371b2f5b0ed0ec136d07779840c66d8 by Laurent Montel.
Committed on 03/08/2026 at 05:41.
Pushed by mlaurent into branch 'master'.
Improve autotest
M +24 -2 src/core/autotests/encryptionutilstest.cpp
M +1 -0 src/core/autotests/encryptionutilstest.h
https://invent.kde.org/network/ruqola/-/commit/181c2f13b371b2f5b0ed0ec136d07779840c66d8
diff --git a/src/core/autotests/encryptionutilstest.cpp b/src/core/autotests/encryptionutilstest.cpp
index 761bf133cf..55157bdccd 100644
--- a/src/core/autotests/encryptionutilstest.cpp
+++ b/src/core/autotests/encryptionutilstest.cpp
@@ -23,8 +23,20 @@ void EncryptionUtilsTest::shouldSplitVectorAndEcryptedData_data()
QTest::addColumn<QByteArray>("encryptedData");
QTest::addColumn<EncryptionUtils::EncryptionInfo>("encryptionInfo");
- EncryptionUtils::EncryptionInfo info;
- QTest::addRow("empty") << QByteArray() << info;
+ {
+ EncryptionUtils::EncryptionInfo info;
+ QTest::addRow("empty") << QByteArray() << info;
+ }
+ {
+ EncryptionUtils::EncryptionInfo info;
+ QTest::addRow("too-short") << QByteArray("1234567890123456") << info;
+ }
+ {
+ EncryptionUtils::EncryptionInfo info;
+ info.vector = QByteArray("1234567890abcdef");
+ info.encryptedData = QByteArray("cipher-payload");
+ QTest::addRow("iv-and-payload") << QByteArray(info.vector + info.encryptedData) << info;
+ }
}
void EncryptionUtilsTest::shouldSplitVectorAndEcryptedData()
@@ -58,4 +70,14 @@ void EncryptionUtilsTest::shouldJoinVectorAndEcryptedData()
QCOMPARE(EncryptionUtils::joinVectorAndEcryptedData(encryptionInfo), encryptedData);
}
+void EncryptionUtilsTest::shouldGenerateRandomPassword()
+{
+ const QString password1 = EncryptionUtils::generateRandomPassword();
+ const QString password2 = EncryptionUtils::generateRandomPassword();
+
+ QCOMPARE(password1.size(), 30);
+ QCOMPARE(password2.size(), 30);
+ QVERIFY(password1 != password2);
+}
+
#include "moc_encryptionutilstest.cpp"
diff --git a/src/core/autotests/encryptionutilstest.h b/src/core/autotests/encryptionutilstest.h
index 9aa94603ff..978d13736b 100644
--- a/src/core/autotests/encryptionutilstest.h
+++ b/src/core/autotests/encryptionutilstest.h
@@ -22,4 +22,5 @@ private Q_SLOTS:
void shouldSplitVectorAndEcryptedData();
void shouldJoinVectorAndEcryptedData_data();
void shouldJoinVectorAndEcryptedData();
+ void shouldGenerateRandomPassword();
};