Fix update discovery and isolate fingerprint installer permissions

This commit is contained in:
ajp_anton
2026-09-12 05:51:06 +00:00
parent 7f56368674
commit 61ef199667
14 changed files with 106 additions and 51 deletions
+34 -2
View File
@@ -12,6 +12,38 @@ class ToolModelTest : public QObject
Q_OBJECT
private Q_SLOTS:
void comparesRpmVersions_data()
{
QTest::addColumn<QString>("installed");
QTest::addColumn<QString>("available");
QTest::addColumn<bool>("update");
QTest::newRow("numeric release") << QStringLiteral("0.1.0-9.fc44") << QStringLiteral("0.1.0-11.fc44") << true;
QTest::newRow("same version") << QStringLiteral("0.1.0-11.fc44") << QStringLiteral("0.1.0-11.fc44") << false;
QTest::newRow("locally newer") << QStringLiteral("0.1.0-25.fc44") << QStringLiteral("0.1.0-23.fc44") << false;
QTest::newRow("epoch wins") << QStringLiteral("2.0-1") << QStringLiteral("1:1.0-1") << true;
QTest::newRow("installed epoch wins") << QStringLiteral("1:1.0-1") << QStringLiteral("2.0-1") << false;
QTest::newRow("implicit zero epoch") << QStringLiteral("0:1.0-1") << QStringLiteral("1.0-1") << false;
QTest::newRow("prerelease") << QStringLiteral("1.0~rc1-1") << QStringLiteral("1.0-1") << true;
QTest::newRow("snapshot") << QStringLiteral("1.0-1") << QStringLiteral("1.0^git1-1") << true;
QTest::newRow("newer than snapshot") << QStringLiteral("1.0^git1-1") << QStringLiteral("1.0.1-1") << true;
}
void comparesRpmVersions()
{
QFETCH(QString, installed);
QFETCH(QString, available);
QFETCH(bool, update);
ToolModel model;
// Match an older noarch install against its native-architecture update.
// No DNF transaction state or privileged files are needed to compare EVRs.
const PackageRecord current{QStringLiteral("touchpad-hold-tap"), installed, QStringLiteral("noarch"), QStringLiteral("Gesture")};
const PackageRecord candidate{current.name, available, QStringLiteral("x86_64"), current.summary};
model.setPackages({current}, {candidate});
QCOMPARE(model.data(model.index(0), ToolModel::UpdateAvailableRole).toBool(), update);
model.setPackages({}, {candidate});
QVERIFY(!model.data(model.index(0), ToolModel::UpdateAvailableRole).toBool());
}
void incompatibleFrameworkIsOnlyListedWhenInstalled() {
if (packageCompatibilityError(QStringLiteral("framework-laptop-tools")).isEmpty()) QSKIP("Requires a non-Framework test host");
const PackageRecord package{QStringLiteral("framework-laptop-tools"), QStringLiteral("1"), QStringLiteral("x86_64"), QStringLiteral("Hardware controls")};
@@ -55,7 +87,7 @@ private Q_SLOTS:
const PackageRecord installed{QStringLiteral("touchpad-hold-tap"), QStringLiteral("0.1.0-5.fc44"), QStringLiteral("noarch"), QStringLiteral("Gesture")};
const PackageRecord available{QStringLiteral("touchpad-hold-tap"), QStringLiteral("0.1.0-6.fc44"), QStringLiteral("noarch"), QStringLiteral("Gesture")};
model.setPackages({installed}, {available}, {QStringLiteral("touchpad-hold-tap")});
model.setPackages({installed}, {available});
QCOMPARE(model.rowCount(), 1);
const QModelIndex index = model.index(0);
@@ -67,7 +99,7 @@ private Q_SLOTS:
QCOMPARE(model.mayRemove(QStringLiteral("missing-tool")), false);
}
void doesNotGuessUpdatesFromDifferentVersionStrings()
void doesNotOfferDowngrades()
{
ToolModel model;
const PackageRecord installed{QStringLiteral("touchpad-hold-tap"), QStringLiteral("0.1.0-7.fc44"), QStringLiteral("noarch"), QStringLiteral("Gesture")};