diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 2f4105fc6..d30adeeca 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -350,6 +350,7 @@ QString Entry::totp() const void Entry::setTotp(const QString& seed, quint8& step, quint8& digits) { + beginUpdate(); if (step == 0) { step = Totp::defaultStep; } @@ -376,6 +377,7 @@ void Entry::setTotp(const QString& seed, quint8& step, quint8& digits) } m_attributes->set("TOTP Settings", data); } + endUpdate(); } QString Entry::totpSeed() const diff --git a/tests/TestTotp.cpp b/tests/TestTotp.cpp index dd69a076d..02af663a1 100644 --- a/tests/TestTotp.cpp +++ b/tests/TestTotp.cpp @@ -164,3 +164,15 @@ void TestTotp::testSteamTotp() time = 1511200714; QCOMPARE(Totp::generateTotp(seed, time, Totp::ENCODER_STEAM, 30), QString("9P3VP")); } + +void TestTotp::testEntryHistory() +{ + Entry entry; + quint8 step = 16; + quint8 digits = 6; + QCOMPARE(entry.historyItems().size(), 0); + entry.setTotp("GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ", step, digits); + QCOMPARE(entry.historyItems().size(), 1); + entry.setTotp("foo", step, digits); + QCOMPARE(entry.historyItems().size(), 2); +} diff --git a/tests/TestTotp.h b/tests/TestTotp.h index 3bf2de93f..784eb8f22 100644 --- a/tests/TestTotp.h +++ b/tests/TestTotp.h @@ -33,6 +33,7 @@ private slots: void testTotpCode(); void testEncoderData(); void testSteamTotp(); + void testEntryHistory(); }; #endif // KEEPASSX_TESTTOTP_H