2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2020-07-27 15:35:24 +02:00
|
|
|
*
|
|
|
|
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2020-07-27 15:35:24 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "CreateUserJob.h"
|
|
|
|
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QtTest/QtTest>
|
|
|
|
|
|
|
|
// Implementation details
|
2020-07-29 12:18:25 +02:00
|
|
|
extern QStringList groupsInTargetSystem( const QDir& targetRoot ); // CreateUserJob
|
2020-07-27 15:35:24 +02:00
|
|
|
|
|
|
|
class CreateUserTests : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
CreateUserTests();
|
2020-09-22 22:14:41 +02:00
|
|
|
~CreateUserTests() override {}
|
2020-07-27 15:35:24 +02:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
|
|
|
|
void testReadGroup();
|
|
|
|
};
|
|
|
|
|
|
|
|
CreateUserTests::CreateUserTests() {}
|
|
|
|
|
|
|
|
void
|
|
|
|
CreateUserTests::initTestCase()
|
|
|
|
{
|
|
|
|
Logger::setupLogLevel( Logger::LOGDEBUG );
|
|
|
|
cDebug() << "Users test started.";
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CreateUserTests::testReadGroup()
|
|
|
|
{
|
|
|
|
QDir root( "/" );
|
|
|
|
QVERIFY( root.exists() );
|
|
|
|
|
|
|
|
// Get the groups in the host system
|
|
|
|
QStringList groups = groupsInTargetSystem( root );
|
|
|
|
QVERIFY( groups.count() > 2 );
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
QVERIFY( groups.contains( QStringLiteral( "wheel" ) ) );
|
|
|
|
#else
|
|
|
|
QVERIFY( groups.contains( QStringLiteral( "root" ) ) );
|
|
|
|
#endif
|
2020-08-11 22:16:03 +02:00
|
|
|
// openSUSE doesn't have "sys"
|
|
|
|
// QVERIFY( groups.contains( QStringLiteral( "sys" ) ) );
|
|
|
|
QVERIFY( groups.contains( QStringLiteral( "nogroup" ) ) );
|
|
|
|
QVERIFY( groups.contains( QStringLiteral( "tty" ) ) );
|
2020-07-27 15:35:24 +02:00
|
|
|
|
|
|
|
for ( const QString& s : groups )
|
|
|
|
{
|
|
|
|
QVERIFY( !s.isEmpty() );
|
|
|
|
QVERIFY( !s.contains( '#' ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN( CreateUserTests )
|
|
|
|
|
|
|
|
#include "utils/moc-warnings.h"
|
|
|
|
|
2020-07-29 13:23:41 +02:00
|
|
|
#include "TestCreateUserJob.moc"
|