mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-06-19 12:14:37 -04:00
Fix OPVault import when there are multiple OTP fields
* Fix #8371 - store multiple OTP fields as `otp_#` instead of silently discarding them.
This commit is contained in:
parent
28328a7080
commit
f3d448485a
2 changed files with 20 additions and 1 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "format/OpVaultReader.h"
|
||||
#include "totp/totp.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
#include <QTest>
|
||||
|
@ -110,6 +111,15 @@ void TestOpVaultReader::testReadIntoDatabase()
|
|||
QCOMPARE(totpSettings->digits, static_cast<unsigned int>(8));
|
||||
QCOMPARE(totpSettings->step, static_cast<unsigned int>(45));
|
||||
|
||||
// Add another OTP to this entry to confirm it doesn't overwrite the existing one
|
||||
auto field = QJsonObject::fromVariantMap({{"n", "TOTP_SETTINGS"}, {"v", "otpauth://test.url?digits=6"}});
|
||||
reader.fillFromSectionField(entry, "", field);
|
||||
QVERIFY(entry->hasTotp());
|
||||
totpSettings = entry->totpSettings();
|
||||
QCOMPARE(totpSettings->digits, static_cast<unsigned int>(8));
|
||||
QCOMPARE(totpSettings->step, static_cast<unsigned int>(45));
|
||||
QVERIFY(entry->attributes()->contains("otp_1"));
|
||||
|
||||
// Confirm trashed entries are sent to the recycle bin
|
||||
auto recycleBin = db->metadata()->recycleBin();
|
||||
QVERIFY(recycleBin);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue