From ecaf97aa60c9c5994b85470a8794e52b545c6800 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 18 Aug 2020 17:20:37 +0200 Subject: [PATCH] [users] Tests of config-loading of groups lists --- src/modules/users/Tests.cpp | 43 ++++++++++++++++++++++++++++ src/modules/users/tests/3-wing.conf | 2 ++ src/modules/users/tests/4-audio.conf | 6 ++++ 3 files changed, 51 insertions(+) create mode 100644 src/modules/users/tests/3-wing.conf create mode 100644 src/modules/users/tests/4-audio.conf diff --git a/src/modules/users/Tests.cpp b/src/modules/users/Tests.cpp index 914821f63..f0fc91165 100644 --- a/src/modules/users/Tests.cpp +++ b/src/modules/users/Tests.cpp @@ -21,6 +21,7 @@ #include "JobQueue.h" #include "utils/Logger.h" +#include "utils/Yaml.h" #include @@ -43,6 +44,9 @@ private Q_SLOTS: void initTestCase(); void testDefaultGroups(); + void testDefaultGroupsYAML_data(); + void testDefaultGroupsYAML(); + void testHostActions_data(); void testHostActions(); void testPasswordChecks(); @@ -112,6 +116,45 @@ UserTests::testDefaultGroups() } } +void UserTests::testDefaultGroupsYAML_data() +{ + QTest::addColumn< QString >( "filename" ); + QTest::addColumn< int >("count"); + QTest::addColumn("group"); + + QTest::newRow("users.conf") << "users.conf" << 7 << "video"; + QTest::newRow("dashed list") << "tests/4-audio.conf" << 4 << "audio"; + QTest::newRow("blocked list") << "tests/3-wing.conf" << 3 << "wing"; +} + +void +UserTests::testDefaultGroupsYAML() +{ + if ( !Calamares::JobQueue::instance() ) + { + (void)new Calamares::JobQueue(); + } + + QFETCH(QString, filename); + QFETCH(int, count); + QFETCH(QString, group); + + QFile fi( QString("%1/%2").arg(BUILD_AS_TEST, filename) ); + QVERIFY(fi.exists()); + + bool ok = false; + const auto map = CalamaresUtils::loadYaml(fi, &ok); + QVERIFY(ok); + QVERIFY(map.count() > 0); + + Config c; + c.setConfigurationMap(map); + + QCOMPARE( c.defaultGroups().count(), count); + QVERIFY( c.defaultGroups().contains( group ) ); +} + + void UserTests::testHostActions_data() { diff --git a/src/modules/users/tests/3-wing.conf b/src/modules/users/tests/3-wing.conf new file mode 100644 index 000000000..3c7dc61af --- /dev/null +++ b/src/modules/users/tests/3-wing.conf @@ -0,0 +1,2 @@ +--- +defaultGroups: [ wing, wheel, users ] diff --git a/src/modules/users/tests/4-audio.conf b/src/modules/users/tests/4-audio.conf new file mode 100644 index 000000000..fb7fdb3d2 --- /dev/null +++ b/src/modules/users/tests/4-audio.conf @@ -0,0 +1,6 @@ +--- +defaultGroups: + - users + - lp + - wheel + - audio