[users] Add tests for autologin settings

- four possibilities for old and new keys
- 6e is the check for not-actually-set, to track defaults
This commit is contained in:
Adriaan de Groot 2021-04-13 16:01:07 +02:00
parent adb9f37cca
commit 2b8309eb04
6 changed files with 75 additions and 0 deletions

View File

@ -44,6 +44,9 @@ private Q_SLOTS:
void testHostActions();
void testPasswordChecks();
void testUserPassword();
void testAutoLogin_data();
void testAutoLogin();
};
UserTests::UserTests() {}
@ -339,6 +342,43 @@ UserTests::testUserPassword()
}
}
void
UserTests::testAutoLogin_data()
{
QTest::addColumn< QString >( "filename" );
QTest::addColumn< bool >( "autoLoginIsSet" );
QTest::addColumn< QString >( "autoLoginGroupName" );
QTest::newRow( "old, old" ) << "tests/6a-issue-1672.conf" << true << "derp";
QTest::newRow( "old, new" ) << "tests/6b-issue-1672.conf" << true << "derp";
QTest::newRow( "new, old" ) << "tests/6c-issue-1672.conf" << true << "derp";
QTest::newRow( "new, new" ) << "tests/6d-issue-1672.conf" << true << "derp";
QTest::newRow( "default" ) << "tests/6e-issue-1672.conf" << false << QString();
}
void
UserTests::testAutoLogin()
{
QFETCH( QString, filename );
QFETCH( bool, autoLoginIsSet );
QFETCH( QString, autoLoginGroupName );
// BUILD_AS_TEST is the source-directory path
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.doAutoLogin(), autoLoginIsSet );
QCOMPARE( c.autoLoginGroup(), autoLoginGroupName );
}
QTEST_GUILESS_MAIN( UserTests )

View File

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
autologinGroup: derp
doAutologin: true

View File

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
autologinGroup: derp
doAutoLogin: true

View File

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
autoLoginGroup: derp
doAutologin: true

View File

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
autoLoginGroup: derp
doAutoLogin: true

View File

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
doautologin: true
autologingroup: wheel