QtPass 1.6.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
tst_passwordconfig.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
3#include <QString>
4#include <QtTest>
5
8
9class tst_passwordconfig : public QObject {
10 Q_OBJECT
11
12private Q_SLOTS:
13 void initTestCase();
14 void passwordConfigurationDefaults();
15 void passwordConfigurationSetters();
16 void passwordConfigurationCharacterSets();
17 void passwordConfigurationLength();
18 void passwordConfigurationCustomChars();
19};
20
21void tst_passwordconfig::initTestCase() {
22 // Reset any leftover test settings to ensure clean state
25}
26
27void tst_passwordconfig::passwordConfigurationDefaults() {
28 PasswordConfiguration config;
29 QCOMPARE(config.length, 16);
31 QVERIFY(!config.Characters[PasswordConfiguration::ALLCHARS].isEmpty());
32 QVERIFY(!config.Characters[PasswordConfiguration::ALPHABETICAL].isEmpty());
33 QVERIFY(!config.Characters[PasswordConfiguration::ALPHANUMERIC].isEmpty());
34}
35
36void tst_passwordconfig::passwordConfigurationSetters() {
37 // Reset any previous test settings to ensure clean state
40
45
46 PasswordConfiguration config = QtPassSettings::getPasswordConfiguration();
47 QCOMPARE(config.length, 24);
48 QCOMPARE(config.selected, 3);
49
50 // Reset after test
53}
54
55void tst_passwordconfig::passwordConfigurationCharacterSets() {
56 PasswordConfiguration config;
57 QVERIFY(config.Characters[PasswordConfiguration::ALLCHARS].length() >
59 QVERIFY(config.Characters[PasswordConfiguration::ALPHANUMERIC].length() >
61}
62
63void tst_passwordconfig::passwordConfigurationLength() {
64 PasswordConfiguration config;
65 config.length = 0;
66 QCOMPARE(config.length, 0);
67 config.length = 100;
68 QCOMPARE(config.length, 100);
69}
70
71void tst_passwordconfig::passwordConfigurationCustomChars() {
72 PasswordConfiguration config;
73 QString custom = "abc123";
75 QCOMPARE(config.Characters[PasswordConfiguration::CUSTOM], custom);
76}
77
78QTEST_MAIN(tst_passwordconfig)
79#include "tst_passwordconfig.moc"
static auto getPasswordConfiguration() -> PasswordConfiguration
Get complete password generation configuration.
static void setPasswordLength(const int &passwordLength)
Save password length setting.
static void setPasswordChars(const QString &passwordChars)
Save custom password characters.
static void setPasswordCharsselection(const int &passwordCharsSelection)
Save password character selection mode.
int length
Length of the password.
enum PasswordConfiguration::characterSet selected
QString Characters[CHARSETS_COUNT]
The different character sets.