Skip to content

Commit

Permalink
TestKdbx4Format: use MockClock
Browse files Browse the repository at this point in the history
Otherwise, assertions in TestKdbx4::testCustomData() may fail on rare
occasions, because the customData in a cloned entry won't be identical
to its original, because of its potentially-updated LastModified
property.

Originally noticed in
keepassxreboot#7783 (comment).
  • Loading branch information
c4rlo authored and droidmonkey committed Apr 18, 2022
1 parent 9bf61bf commit f15ee90
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/TestKdbx4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "keys/FileKey.h"
#include "keys/PasswordKey.h"
#include "mock/MockChallengeResponseKey.h"
#include "mock/MockClock.h"
#include <QTest>

int main(int argc, char* argv[])
Expand Down Expand Up @@ -113,6 +114,17 @@ void TestKdbx4AesKdf::initTestCaseImpl()
}

Q_DECLARE_METATYPE(QUuid)

void TestKdbx4Format::init()
{
MockClock::setup(new MockClock());
}

void TestKdbx4Format::cleanup()
{
MockClock::teardown();
}

void TestKdbx4Format::testFormat400()
{
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/Format400.kdbx");
Expand Down
2 changes: 2 additions & 0 deletions tests/TestKdbx4.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class TestKdbx4Format : public QObject
Q_OBJECT

private slots:
void init();
void cleanup();
void testFormat400();
void testFormat400Upgrade();
void testFormat400Upgrade_data();
Expand Down

0 comments on commit f15ee90

Please sign in to comment.