mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-06-20 12:44:47 -04:00
Fixed issues detected by test suite and ci
Fixed serialization for KeeShareSettings::ScopedCertificate Fixed tests for KeeShareSettings serialization Fixed tests Cli features - tests translation for recycle bin since the tests are executed with the system locale Fixed initialization issue in ShareObserver
This commit is contained in:
parent
ba604390d2
commit
6e25da6a19
4 changed files with 20 additions and 23 deletions
|
@ -308,15 +308,14 @@ namespace KeeShareSettings
|
||||||
void ScopedCertificate::serialize(QXmlStreamWriter& writer, const ScopedCertificate& scopedCertificate)
|
void ScopedCertificate::serialize(QXmlStreamWriter& writer, const ScopedCertificate& scopedCertificate)
|
||||||
{
|
{
|
||||||
writer.writeAttribute("Path", scopedCertificate.path);
|
writer.writeAttribute("Path", scopedCertificate.path);
|
||||||
|
QString trust = "Ask";
|
||||||
if(scopedCertificate.trust == KeeShareSettings::Trust::Trusted) {
|
if(scopedCertificate.trust == KeeShareSettings::Trust::Trusted) {
|
||||||
writer.writeAttribute("Trust", "Trusted");
|
trust = "Trusted";
|
||||||
}
|
}
|
||||||
else if(scopedCertificate.trust == KeeShareSettings::Trust::Untrusted){
|
if(scopedCertificate.trust == KeeShareSettings::Trust::Untrusted){
|
||||||
writer.writeAttribute("Trust", "Untrusted");
|
trust = "Untrusted";
|
||||||
}
|
|
||||||
else {
|
|
||||||
writer.writeAttribute("Trust", "Ask");
|
|
||||||
}
|
}
|
||||||
|
writer.writeAttribute("Trust", trust);
|
||||||
Certificate::serialize(writer, scopedCertificate.certificate);
|
Certificate::serialize(writer, scopedCertificate.certificate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,16 +323,14 @@ namespace KeeShareSettings
|
||||||
{
|
{
|
||||||
ScopedCertificate scopedCertificate;
|
ScopedCertificate scopedCertificate;
|
||||||
scopedCertificate.path = reader.attributes().value("Path").toString();
|
scopedCertificate.path = reader.attributes().value("Path").toString();
|
||||||
auto trust = reader.attributes().value("Trusted").toString();
|
scopedCertificate.trust = KeeShareSettings::Trust::Ask;
|
||||||
if(trust.compare("Trusted", Qt::CaseInsensitive)) {
|
auto trust = reader.attributes().value("Trust").toString();
|
||||||
|
if(trust.compare("Trusted", Qt::CaseInsensitive) == 0) {
|
||||||
scopedCertificate.trust = KeeShareSettings::Trust::Trusted;
|
scopedCertificate.trust = KeeShareSettings::Trust::Trusted;
|
||||||
}
|
}
|
||||||
if(trust.compare("Unrusted", Qt::CaseInsensitive)) {
|
if(trust.compare("Untrusted", Qt::CaseInsensitive) == 0) {
|
||||||
scopedCertificate.trust = KeeShareSettings::Trust::Untrusted;
|
scopedCertificate.trust = KeeShareSettings::Trust::Untrusted;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
scopedCertificate.trust = KeeShareSettings::Trust::Ask;
|
|
||||||
}
|
|
||||||
scopedCertificate.certificate = Certificate::deserialize(reader);
|
scopedCertificate.certificate = Certificate::deserialize(reader);
|
||||||
return scopedCertificate;
|
return scopedCertificate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ QPair<Trust, KeeShareSettings::Certificate> check(QByteArray& data,
|
||||||
certificate = sign.certificate;
|
certificate = sign.certificate;
|
||||||
auto key = sign.certificate.sshKey();
|
auto key = sign.certificate.sshKey();
|
||||||
key.openKey(QString());
|
key.openKey(QString());
|
||||||
const Signature signer;
|
const auto signer = Signature{};
|
||||||
if (!signer.verify(data, sign.signature, key)) {
|
if (!signer.verify(data, sign.signature, key)) {
|
||||||
qCritical("Invalid signature for sharing container %s.", qPrintable(reference.path));
|
qCritical("Invalid signature for sharing container %s.", qPrintable(reference.path));
|
||||||
return {Invalid, KeeShareSettings::Certificate()};
|
return {Invalid, KeeShareSettings::Certificate()};
|
||||||
|
@ -212,7 +212,7 @@ void ShareObserver::reinitialize()
|
||||||
QStringList success;
|
QStringList success;
|
||||||
QStringList warning;
|
QStringList warning;
|
||||||
QStringList error;
|
QStringList error;
|
||||||
for (Update update : updated) {
|
for (const auto& update : updated) {
|
||||||
if (!update.oldReference.path.isEmpty()) {
|
if (!update.oldReference.path.isEmpty()) {
|
||||||
m_fileWatcher->removePath(update.oldReference.path);
|
m_fileWatcher->removePath(update.oldReference.path);
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ void ShareObserver::reinitialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update.newReference.isImporting()) {
|
if (update.newReference.isImporting()) {
|
||||||
const Result result = this->importFromReferenceContainer(update.newReference.path);
|
const auto result = this->importFromReferenceContainer(update.newReference.path);
|
||||||
if (!result.isValid()) {
|
if (!result.isValid()) {
|
||||||
// tolerable result - blocked import or missing source
|
// tolerable result - blocked import or missing source
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -919,7 +919,7 @@ void TestCli::testRemove()
|
||||||
readBack.close();
|
readBack.close();
|
||||||
QVERIFY(readBackDb);
|
QVERIFY(readBackDb);
|
||||||
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Sample Entry"));
|
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Sample Entry"));
|
||||||
QVERIFY(readBackDb->rootGroup()->findEntryByPath("/Recycle Bin/Sample Entry"));
|
QVERIFY(readBackDb->rootGroup()->findEntryByPath(QString("/%1/Sample Entry").arg(Group::tr("Recycle Bin"))));
|
||||||
|
|
||||||
pos = m_stdoutFile->pos();
|
pos = m_stdoutFile->pos();
|
||||||
|
|
||||||
|
@ -937,7 +937,7 @@ void TestCli::testRemove()
|
||||||
readBack.close();
|
readBack.close();
|
||||||
QVERIFY(readBackDb);
|
QVERIFY(readBackDb);
|
||||||
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Sample Entry"));
|
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Sample Entry"));
|
||||||
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Recycle Bin/Sample Entry"));
|
QVERIFY(!readBackDb->rootGroup()->findEntryByPath(QString("/%1/Sample Entry").arg(Group::tr("Recycle Bin"))));
|
||||||
|
|
||||||
pos = m_stdoutFile->pos();
|
pos = m_stdoutFile->pos();
|
||||||
|
|
||||||
|
@ -977,13 +977,13 @@ void TestCli::testRemoveQuiet()
|
||||||
readBack.close();
|
readBack.close();
|
||||||
QVERIFY(readBackDb);
|
QVERIFY(readBackDb);
|
||||||
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Sample Entry"));
|
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Sample Entry"));
|
||||||
QVERIFY(readBackDb->rootGroup()->findEntryByPath("/Recycle Bin/Sample Entry"));
|
QVERIFY(readBackDb->rootGroup()->findEntryByPath(QString("/%1/Sample Entry").arg(Group::tr("Recycle Bin"))));
|
||||||
|
|
||||||
pos = m_stdoutFile->pos();
|
pos = m_stdoutFile->pos();
|
||||||
|
|
||||||
// remove the entry completely
|
// remove the entry completely
|
||||||
Utils::Test::setNextPassword("a");
|
Utils::Test::setNextPassword("a");
|
||||||
removeCmd.execute({"rm", "-q", m_dbFile->fileName(), "/Recycle Bin/Sample Entry"});
|
removeCmd.execute({"rm", "-q", m_dbFile->fileName(), QString("/%1/Sample Entry").arg(Group::tr("Recycle Bin"))});
|
||||||
m_stdoutFile->seek(pos);
|
m_stdoutFile->seek(pos);
|
||||||
QCOMPARE(m_stdoutFile->readAll(), QByteArray(""));
|
QCOMPARE(m_stdoutFile->readAll(), QByteArray(""));
|
||||||
|
|
||||||
|
@ -994,7 +994,7 @@ void TestCli::testRemoveQuiet()
|
||||||
readBack.close();
|
readBack.close();
|
||||||
QVERIFY(readBackDb);
|
QVERIFY(readBackDb);
|
||||||
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Sample Entry"));
|
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Sample Entry"));
|
||||||
QVERIFY(!readBackDb->rootGroup()->findEntryByPath("/Recycle Bin/Sample Entry"));
|
QVERIFY(!readBackDb->rootGroup()->findEntryByPath(QString("/%1/Sample Entry").arg(Group::tr("Recycle Bin"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCli::testShow()
|
void TestCli::testShow()
|
||||||
|
|
|
@ -301,12 +301,12 @@ void TestSharing::testSettingsSerialization_data()
|
||||||
QTest::addColumn<bool>("exporting");
|
QTest::addColumn<bool>("exporting");
|
||||||
QTest::addColumn<KeeShareSettings::Certificate>("ownCertificate");
|
QTest::addColumn<KeeShareSettings::Certificate>("ownCertificate");
|
||||||
QTest::addColumn<KeeShareSettings::Key>("ownKey");
|
QTest::addColumn<KeeShareSettings::Key>("ownKey");
|
||||||
QTest::addColumn<QList<KeeShareSettings::Certificate>>("foreignCertificates");
|
QTest::addColumn<QList<KeeShareSettings::ScopedCertificate>>("foreignCertificates");
|
||||||
QTest::newRow("1") << false << false << KeeShareSettings::Certificate() << KeeShareSettings::Key() << QList<KeeShareSettings::ScopedCertificate>();
|
QTest::newRow("1") << false << false << KeeShareSettings::Certificate() << KeeShareSettings::Key() << QList<KeeShareSettings::ScopedCertificate>();
|
||||||
QTest::newRow("2") << true << false << KeeShareSettings::Certificate() << KeeShareSettings::Key() << QList<KeeShareSettings::ScopedCertificate>();
|
QTest::newRow("2") << true << false << KeeShareSettings::Certificate() << KeeShareSettings::Key() << QList<KeeShareSettings::ScopedCertificate>();
|
||||||
QTest::newRow("3") << true << true << KeeShareSettings::Certificate() << KeeShareSettings::Key() << QList<KeeShareSettings::ScopedCertificate>({ certificate0, certificate1 });
|
QTest::newRow("3") << true << true << KeeShareSettings::Certificate() << KeeShareSettings::Key() << QList<KeeShareSettings::ScopedCertificate>({ certificate0, certificate1 });
|
||||||
QTest::newRow("4") << false << true << certificate0 << key0 << QList<KeeShareSettings::ScopedCertificate>();
|
QTest::newRow("4") << false << true << certificate0.certificate << key0 << QList<KeeShareSettings::ScopedCertificate>();
|
||||||
QTest::newRow("5") << false << false << certificate0 << key0 << QList<KeeShareSettings::ScopedCertificate>({ certificate1 });
|
QTest::newRow("5") << false << false << certificate0.certificate << key0 << QList<KeeShareSettings::ScopedCertificate>({ certificate1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const OpenSSHKey& TestSharing::stubkey(int index)
|
const OpenSSHKey& TestSharing::stubkey(int index)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue