[users] Add tests for moved password-check configuration

- link the PW checks to the test, and libpwquality if needed
- test only does very basic config-mungeing
This commit is contained in:
Adriaan de Groot 2020-08-05 13:03:56 +02:00
parent 900deb5dc8
commit b2b9ae7799
2 changed files with 18 additions and 0 deletions

View File

@ -71,4 +71,7 @@ calamares_add_test(
SOURCES SOURCES
Tests.cpp Tests.cpp
Config.cpp Config.cpp
CheckPWQuality.cpp
LIBRARIES
${USER_EXTRA_LIB}
) )

View File

@ -26,6 +26,7 @@
// Implementation details // Implementation details
extern void setConfigurationDefaultGroups( const QVariantMap& map, QStringList& defaultGroups ); extern void setConfigurationDefaultGroups( const QVariantMap& map, QStringList& defaultGroups );
extern HostNameActions getHostNameActions( const QVariantMap& configurationMap ); extern HostNameActions getHostNameActions( const QVariantMap& configurationMap );
extern bool addPasswordCheck( const QString& key, const QVariant& value, PasswordCheckList& passwordChecks );
/** @brief Test Config object methods and internals /** @brief Test Config object methods and internals
* *
@ -43,6 +44,7 @@ private Q_SLOTS:
void testDefaultGroups(); void testDefaultGroups();
void testHostActions_data(); void testHostActions_data();
void testHostActions(); void testHostActions();
void testPasswordChecks();
}; };
UserTests::UserTests() {} UserTests::UserTests() {}
@ -141,6 +143,19 @@ UserTests::testHostActions()
QCOMPARE( getHostNameActions( m ), HostNameActions( result ) | HostNameAction::WriteEtcHosts ); QCOMPARE( getHostNameActions( m ), HostNameActions( result ) | HostNameAction::WriteEtcHosts );
} }
void
UserTests::testPasswordChecks()
{
{
PasswordCheckList l;
QCOMPARE( l.length(), 0 );
QVERIFY( !addPasswordCheck( "nonempty", QVariant(false), l ) ); // a silly setting
QCOMPARE( l.length(), 0 );
QVERIFY( addPasswordCheck( "nonempty", QVariant(true), l ) );
QCOMPARE( l.length(), 1 );
}
}
QTEST_GUILESS_MAIN( UserTests ) QTEST_GUILESS_MAIN( UserTests )