2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2017-06-20 23:43:50 +02:00
|
|
|
*
|
2020-07-29 13:31:39 +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
|
|
|
*
|
2020-08-25 16:05:56 +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>
|
|
|
|
|
2020-07-29 13:31:39 +02:00
|
|
|
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 );
|
2019-10-21 17:21:33 +02:00
|
|
|
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;
|
|
|
|
}
|
2020-07-29 13:31:39 +02:00
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN( PasswordTests )
|
|
|
|
|
|
|
|
#include "utils/moc-warnings.h"
|
|
|
|
|
|
|
|
#include "TestPasswordJob.moc"
|