Create history item when setting up a TOTP seed, resolves #1445

This commit is contained in:
Janek Bevendorff 2018-02-01 17:58:15 +01:00
parent 9c51e1af18
commit 17e3f1c21f
3 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -33,6 +33,7 @@ private slots:
void testTotpCode();
void testEncoderData();
void testSteamTotp();
void testEntryHistory();
};
#endif // KEEPASSX_TESTTOTP_H