summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2019-06-24 09:21:39 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2019-08-15 10:00:37 +0000
commit55ecbb9660048b06959d471b783a05e4f6b47efd (patch)
treefdc942d40902f0df0ec769ad3baf8eb8d9749745 /tests
parent120e527ed16f6c579e46f71c9018ad35ad1cb528 (diff)
Update repository categories on server authentication request
If repositories in a category were located on a server that requires user authentication, IFW couldn't update information of the repositories inside a category during runtime. This prevents for example storing credentials from the authentication request dialog and blocks the usage of that category. Add a method for updating contents in repository categories and a unit test for the new method. Also some minor tweaks to relevant bits of code. Task-number: QTIFW-1358 Change-Id: Idfa2559df6d0d2a6de428b8d5fb1f7672aa1e300 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/repository/tst_repository.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/installer/repository/tst_repository.cpp b/tests/auto/installer/repository/tst_repository.cpp
index 8d5d278a2..7b8405baf 100644
--- a/tests/auto/installer/repository/tst_repository.cpp
+++ b/tests/auto/installer/repository/tst_repository.cpp
@@ -1,4 +1,6 @@
#include "repository.h"
+#include "repositorycategory.h"
+#include "settings.h"
#include <QDataStream>
#include <QString>
@@ -114,6 +116,51 @@ private slots:
s1 >> r1; s2 >> r2;
QCOMPARE(r1, r2);
}
+
+ void testUpdateRepositoryCategories()
+ {
+ Settings settings;
+
+ RepositoryCategory category;
+ category.setEnabled(true);
+ category.setDisplayName(QLatin1String("category"));
+
+ Repository original(QUrl("http://example.com/"), true);
+ original.setEnabled(true);
+ category.addRepository(original);
+
+ Repository replacement = original;
+ replacement.setUsername(QLatin1String("user"));
+ replacement.setPassword(QLatin1String("pass"));
+
+ QSet<RepositoryCategory> categories;
+ categories.insert(category);
+ settings.setRepositoryCategories(categories);
+
+ QHash<QString, QPair<Repository, Repository>> update;
+
+ // non-empty update
+ update.insert(QLatin1String("replace"), qMakePair(original, replacement));
+ QVERIFY(settings.updateRepositoryCategories(update) == Settings::UpdatesApplied);
+
+ // verify that the values really updated
+ QVERIFY(settings.repositoryCategories().values().at(0)
+ .repositories().values().at(0).username() == "user");
+
+ QVERIFY(settings.repositoryCategories().values().at(0)
+ .repositories().values().at(0).password() == "pass");
+
+ // empty update
+ update.clear();
+ QVERIFY(settings.updateRepositoryCategories(update) == Settings::NoUpdatesApplied);
+
+ // non-matching repository update
+ Repository nonMatching(QUrl("https://www.qt.io/"), true);
+ nonMatching.setEnabled(true);
+
+ update.insert(QLatin1String("replace"), qMakePair(nonMatching, replacement));
+ QVERIFY(settings.updateRepositoryCategories(update) == Settings::NoUpdatesApplied);
+ }
};
QTEST_MAIN(tst_Repository)