[users] Tests of config-loading of groups lists
This commit is contained in:
parent
ab3e393d45
commit
ecaf97aa60
@ -21,6 +21,7 @@
|
||||
|
||||
#include "JobQueue.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Yaml.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
@ -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<QString>("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()
|
||||
{
|
||||
|
2
src/modules/users/tests/3-wing.conf
Normal file
2
src/modules/users/tests/3-wing.conf
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
defaultGroups: [ wing, wheel, users ]
|
6
src/modules/users/tests/4-audio.conf
Normal file
6
src/modules/users/tests/4-audio.conf
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
defaultGroups:
|
||||
- users
|
||||
- lp
|
||||
- wheel
|
||||
- audio
|
Loading…
Reference in New Issue
Block a user