calamares/src/modules/users/TestPasswordJob.cpp

56 lines
1.1 KiB
C++
Raw Normal View History

/* === This file is part of Calamares - <https://calamares.io> ===
2017-06-20 23:43:50 +02:00
*
* SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
2017-06-20 23:43:50 +02:00
*
* Calamares is Free Software: see the License-Identifier above.
2017-06-20 23:43:50 +02:00
*
*/
#include "SetPasswordJob.h"
#include <QtTest/QtTest>
class PasswordTests : public QObject
{
Q_OBJECT
public:
PasswordTests();
~PasswordTests() override;
private Q_SLOTS:
void initTestCase();
void testSalt();
};
2017-06-20 23:43:50 +02:00
2020-07-25 15:27:41 +02:00
PasswordTests::PasswordTests() {}
2017-06-20 23:43:50 +02:00
2020-07-25 15:27:41 +02:00
PasswordTests::~PasswordTests() {}
2017-06-20 23:43:50 +02:00
void
PasswordTests::initTestCase()
{
}
void
PasswordTests::testSalt()
{
QString s = SetPasswordJob::make_salt( 8 );
QCOMPARE( s.length(), 4 + 8 ); // 8 salt chars, plus $6$, plus trailing $
2017-06-20 23:43:50 +02:00
QVERIFY( s.startsWith( "$6$" ) );
QVERIFY( s.endsWith( '$' ) );
qDebug() << "Obtained salt" << s;
s = SetPasswordJob::make_salt( 11 );
QCOMPARE( s.length(), 4 + 11 );
QVERIFY( s.startsWith( "$6$" ) );
QVERIFY( s.endsWith( '$' ) );
qDebug() << "Obtained salt" << s;
}
QTEST_GUILESS_MAIN( PasswordTests )
#include "utils/moc-warnings.h"
#include "TestPasswordJob.moc"