Merge branch 'fix-sudo-settings' into calamares

This commit is contained in:
Adriaan de Groot 2020-11-06 22:28:37 +01:00
commit 3b152ba455
3 changed files with 45 additions and 1 deletions

View File

@ -815,7 +815,7 @@ Config::createJobs() const
Calamares::Job* j;
if ( m_sudoersGroup.isEmpty() )
if ( !m_sudoersGroup.isEmpty() )
{
j = new SetupSudoJob( m_sudoersGroup );
jobs.append( Calamares::job_ptr( j ) );

View File

@ -38,6 +38,7 @@ SetupSudoJob::exec()
{
if ( m_sudoGroup.isEmpty() )
{
cDebug() << "Skipping sudo 10-installer because the sudoGroup is empty.";
return Calamares::JobResult::ok();
}

View File

@ -34,6 +34,8 @@ private Q_SLOTS:
void testReadGroup();
void testCreateGroup();
void testSudoGroup();
};
GroupTests::GroupTests() {}
@ -98,6 +100,47 @@ GroupTests::testCreateGroup()
QVERIFY( !j.exec() ); // running as regular user this should fail
}
void GroupTests::testSudoGroup()
{
// Test programmatic changes
{
Config c;
QSignalSpy spy(&c, &Config::sudoersGroupChanged);
QCOMPARE( c.sudoersGroup(), QString() );
c.setSudoersGroup( QStringLiteral( "wheel" ) );
QCOMPARE( c.sudoersGroup(), QStringLiteral( "wheel" ) );
QCOMPARE( spy.count(), 1); // Changed to wheel
// Do it again, no change
c.setSudoersGroup( QStringLiteral( "wheel" ) );
QCOMPARE( c.sudoersGroup(), QStringLiteral( "wheel" ) );
QCOMPARE( spy.count(), 1);
c.setSudoersGroup( QStringLiteral( "roue" ) );
QCOMPARE( c.sudoersGroup(), QStringLiteral( "roue" ) );
QCOMPARE( spy.count(), 2);
}
// Test config loading
{
Config c;
QSignalSpy spy(&c, &Config::sudoersGroupChanged);
QCOMPARE( c.sudoersGroup(), QString() );
QVariantMap m;
c.setConfigurationMap( m );
QCOMPARE( c.sudoersGroup(), QString() );
QCOMPARE( spy.count(), 0); // Unchanged
const auto key = QStringLiteral( "sudoersGroup" );
const auto v0 = QStringLiteral( "wheel" );
const auto v1 = QStringLiteral( "roue" );
m.insert( key, v0 );
c.setConfigurationMap( m );
QCOMPARE( c.sudoersGroup(), v0 );
QCOMPARE( spy.count(), 1);
}
}
QTEST_GUILESS_MAIN( GroupTests )