[users] Adjust tests to changed groups-list

This commit is contained in:
Adriaan de Groot 2020-10-13 17:36:24 +02:00
parent d3135898fd
commit e46d9f735d

View File

@ -16,7 +16,7 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
// Implementation details // Implementation details
extern void setConfigurationDefaultGroups( const QVariantMap& map, QStringList& defaultGroups ); extern void setConfigurationDefaultGroups( const QVariantMap& map, QList< GroupDescription >& defaultGroups );
extern HostNameActions getHostNameActions( const QVariantMap& configurationMap ); extern HostNameActions getHostNameActions( const QVariantMap& configurationMap );
extern bool addPasswordCheck( const QString& key, const QVariant& value, PasswordCheckList& passwordChecks ); extern bool addPasswordCheck( const QString& key, const QVariant& value, PasswordCheckList& passwordChecks );
@ -56,29 +56,32 @@ void
UserTests::testDefaultGroups() UserTests::testDefaultGroups()
{ {
{ {
QStringList groups; QList< GroupDescription > groups;
QVariantMap hweelGroup; QVariantMap hweelGroup;
QVERIFY( groups.isEmpty() ); QVERIFY( groups.isEmpty() );
hweelGroup.insert( "defaultGroups", QStringList { "hweel" } ); hweelGroup.insert( "defaultGroups", QStringList { "hweel" } );
setConfigurationDefaultGroups( hweelGroup, groups ); setConfigurationDefaultGroups( hweelGroup, groups );
QCOMPARE( groups.count(), 1 ); QCOMPARE( groups.count(), 1 );
QVERIFY( groups.contains( "hweel" ) ); QVERIFY( groups.contains( GroupDescription( "hweel" ) ) );
} }
{ {
QStringList desired { "wheel", "root", "operator" }; QStringList desired { "wheel", "root", "operator" };
QStringList groups; QList< GroupDescription > groups;
QVariantMap threeGroup; QVariantMap threeGroup;
QVERIFY( groups.isEmpty() ); QVERIFY( groups.isEmpty() );
threeGroup.insert( "defaultGroups", desired ); threeGroup.insert( "defaultGroups", desired );
setConfigurationDefaultGroups( threeGroup, groups ); setConfigurationDefaultGroups( threeGroup, groups );
QCOMPARE( groups.count(), 3 ); QCOMPARE( groups.count(), 3 );
QVERIFY( !groups.contains( "hweel" ) ); QVERIFY( !groups.contains( GroupDescription( "hweel" ) ) );
QCOMPARE( groups, desired ); for ( const auto& s : desired )
{
QVERIFY( groups.contains( GroupDescription( s ) ) );
}
} }
{ {
QStringList groups; QList< GroupDescription > groups;
QVariantMap explicitEmpty; QVariantMap explicitEmpty;
QVERIFY( groups.isEmpty() ); QVERIFY( groups.isEmpty() );
explicitEmpty.insert( "defaultGroups", QStringList() ); explicitEmpty.insert( "defaultGroups", QStringList() );
@ -87,22 +90,22 @@ UserTests::testDefaultGroups()
} }
{ {
QStringList groups; QList< GroupDescription > groups;
QVariantMap missing; QVariantMap missing;
QVERIFY( groups.isEmpty() ); QVERIFY( groups.isEmpty() );
setConfigurationDefaultGroups( missing, groups ); setConfigurationDefaultGroups( missing, groups );
QCOMPARE( groups.count(), 6 ); // because of fallback! QCOMPARE( groups.count(), 6 ); // because of fallback!
QVERIFY( groups.contains( "lp" ) ); QVERIFY( groups.contains( GroupDescription( "lp" ) ) );
} }
{ {
QStringList groups; QList< GroupDescription > groups;
QVariantMap typeMismatch; QVariantMap typeMismatch;
QVERIFY( groups.isEmpty() ); QVERIFY( groups.isEmpty() );
typeMismatch.insert( "defaultGroups", 1 ); typeMismatch.insert( "defaultGroups", 1 );
setConfigurationDefaultGroups( typeMismatch, groups ); setConfigurationDefaultGroups( typeMismatch, groups );
QCOMPARE( groups.count(), 6 ); // because of fallback! QCOMPARE( groups.count(), 6 ); // because of fallback!
QVERIFY( groups.contains( "lp" ) ); QVERIFY( groups.contains( GroupDescription( "lp" ) ) );
} }
} }