mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
[DatabaseEncryptedPasswordBackend] Added tests.
This commit is contained in:
parent
05755158f9
commit
2abf37ed37
|
@ -48,6 +48,7 @@ int main(int argc, char *argv[])
|
||||||
RUN_TEST(PacTest)
|
RUN_TEST(PacTest)
|
||||||
|
|
||||||
RUN_TEST(DatabasePasswordBackendTest)
|
RUN_TEST(DatabasePasswordBackendTest)
|
||||||
|
RUN_TEST(DatabaseEncryptedPasswordBackendTest)
|
||||||
RUN_TEST(KWalletPasswordBackendTest)
|
RUN_TEST(KWalletPasswordBackendTest)
|
||||||
RUN_TEST(GnomeKeyringPasswordBackendTest)
|
RUN_TEST(GnomeKeyringPasswordBackendTest)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "passwordbackendtest.h"
|
#include "passwordbackendtest.h"
|
||||||
|
#include "aesinterface.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
|
@ -225,6 +226,38 @@ void DatabasePasswordBackendTest::cleanup()
|
||||||
QSqlDatabase::removeDatabase(QSqlDatabase::database().databaseName());
|
QSqlDatabase::removeDatabase(QSqlDatabase::database().databaseName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DatabaseEncryptedPasswordBackendTest
|
||||||
|
void DatabaseEncryptedPasswordBackendTest::reloadBackend()
|
||||||
|
{
|
||||||
|
delete m_backend;
|
||||||
|
DatabaseEncryptedPasswordBackend* backend = new DatabaseEncryptedPasswordBackend;
|
||||||
|
|
||||||
|
if (m_testMasterPassword.isEmpty()) {
|
||||||
|
m_testMasterPassword = AesInterface::passwordToHash(QString::fromUtf8(AesInterface::createRandomData(8)));
|
||||||
|
backend->updateSampleData(m_testMasterPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
// a trick for setting masterPassword without gui interactions
|
||||||
|
backend->isPasswordVerified(m_testMasterPassword);
|
||||||
|
backend->setAskMasterPasswordState(false);
|
||||||
|
|
||||||
|
m_backend = backend;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseEncryptedPasswordBackendTest::init()
|
||||||
|
{
|
||||||
|
QSqlDatabase db = QSqlDatabase::database();
|
||||||
|
if (!db.isValid()) {
|
||||||
|
db = QSqlDatabase::addDatabase("QSQLITE");
|
||||||
|
db.setDatabaseName(":memory:");
|
||||||
|
}
|
||||||
|
db.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseEncryptedPasswordBackendTest::cleanup()
|
||||||
|
{
|
||||||
|
QSqlDatabase::removeDatabase(QSqlDatabase::database().databaseName());
|
||||||
|
}
|
||||||
|
|
||||||
// KWalletPassswordBackendTest
|
// KWalletPassswordBackendTest
|
||||||
void KWalletPasswordBackendTest::reloadBackend()
|
void KWalletPasswordBackendTest::reloadBackend()
|
||||||
|
|
|
@ -60,6 +60,21 @@ protected:
|
||||||
void cleanup();
|
void cleanup();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include "passwordbackends/databaseencryptedpasswordbackend.h"
|
||||||
|
|
||||||
|
class DatabaseEncryptedPasswordBackendTest : public PasswordBackendTest
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
QByteArray m_testMasterPassword;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void reloadBackend();
|
||||||
|
void init();
|
||||||
|
void cleanup();
|
||||||
|
};
|
||||||
|
|
||||||
#include "../../src/plugins/KWalletPasswords/kwalletpasswordbackend.h"
|
#include "../../src/plugins/KWalletPasswords/kwalletpasswordbackend.h"
|
||||||
|
|
||||||
class KWalletPasswordBackendTest : public PasswordBackendTest
|
class KWalletPasswordBackendTest : public PasswordBackendTest
|
||||||
|
|
Loading…
Reference in New Issue
Block a user