mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-07 05:52:33 -04:00
Add some password-related feature (#92)
* Add Standalone Password Generator. Closes #18 * Add an entropy meter for passwords. Closes #84 * Don't require password repeat when it is visible. Fixes #27
This commit is contained in:
parent
19a960856c
commit
b2f3cc6903
28 changed files with 28401 additions and 195 deletions
|
@ -21,6 +21,7 @@
|
|||
#include <QApplication>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QMimeData>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
|
@ -228,6 +229,80 @@ void TestGui::testAddEntry()
|
|||
QTRY_COMPARE(entryView->model()->rowCount(), 4);
|
||||
}
|
||||
|
||||
void TestGui::testEntryEntropy()
|
||||
{
|
||||
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
|
||||
|
||||
// Find the new entry action
|
||||
QAction* entryNewAction = m_mainWindow->findChild<QAction*>("actionEntryNew");
|
||||
QVERIFY(entryNewAction->isEnabled());
|
||||
|
||||
// Find the button associated with the new entry action
|
||||
QWidget* entryNewWidget = toolBar->widgetForAction(entryNewAction);
|
||||
QVERIFY(entryNewWidget->isVisible());
|
||||
QVERIFY(entryNewWidget->isEnabled());
|
||||
|
||||
// Click the new entry button and check that we enter edit mode
|
||||
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
|
||||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
|
||||
|
||||
// Add entry "test" and confirm added
|
||||
EditEntryWidget* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
|
||||
QLineEdit* titleEdit = editEntryWidget->findChild<QLineEdit*>("titleEdit");
|
||||
QTest::keyClicks(titleEdit, "test");
|
||||
|
||||
// Open the password generator
|
||||
QToolButton* generatorButton = editEntryWidget->findChild<QToolButton*>("tooglePasswordGeneratorButton");
|
||||
QTest::mouseClick(generatorButton, Qt::LeftButton);
|
||||
|
||||
// Type in some password
|
||||
QLineEdit* editNewPassword = editEntryWidget->findChild<QLineEdit*>("editNewPassword");
|
||||
QLabel* entropyLabel = editEntryWidget->findChild<QLabel*>("entropyLabel");
|
||||
QLabel* strengthLabel = editEntryWidget->findChild<QLabel*>("strengthLabel");
|
||||
|
||||
editNewPassword->setText("");
|
||||
QTest::keyClicks(editNewPassword, "hello");
|
||||
QCOMPARE(entropyLabel->text(), QString("Entropy: 6.38 bit"));
|
||||
QCOMPARE(strengthLabel->text(), QString("Password Quality: Poor"));
|
||||
|
||||
editNewPassword->setText("");
|
||||
QTest::keyClicks(editNewPassword, "helloworld");
|
||||
QCOMPARE(entropyLabel->text(), QString("Entropy: 13.10 bit"));
|
||||
QCOMPARE(strengthLabel->text(), QString("Password Quality: Poor"));
|
||||
|
||||
editNewPassword->setText("");
|
||||
QTest::keyClicks(editNewPassword, "password1");
|
||||
QCOMPARE(entropyLabel->text(), QString("Entropy: 4.00 bit"));
|
||||
QCOMPARE(strengthLabel->text(), QString("Password Quality: Poor"));
|
||||
|
||||
editNewPassword->setText("");
|
||||
QTest::keyClicks(editNewPassword, "D0g..................");
|
||||
QCOMPARE(entropyLabel->text(), QString("Entropy: 19.02 bit"));
|
||||
QCOMPARE(strengthLabel->text(), QString("Password Quality: Poor"));
|
||||
|
||||
editNewPassword->setText("");
|
||||
QTest::keyClicks(editNewPassword, "Tr0ub4dour&3");
|
||||
QCOMPARE(entropyLabel->text(), QString("Entropy: 30.87 bit"));
|
||||
QCOMPARE(strengthLabel->text(), QString("Password Quality: Poor"));
|
||||
|
||||
editNewPassword->setText("");
|
||||
QTest::keyClicks(editNewPassword, "correcthorsebatterystaple");
|
||||
QCOMPARE(entropyLabel->text(), QString("Entropy: 47.98 bit"));
|
||||
QCOMPARE(strengthLabel->text(), QString("Password Quality: Weak"));
|
||||
|
||||
editNewPassword->setText("");
|
||||
QTest::keyClicks(editNewPassword, "YQC3kbXbjC652dTDH");
|
||||
QCOMPARE(entropyLabel->text(), QString("Entropy: 96.07 bit"));
|
||||
QCOMPARE(strengthLabel->text(), QString("Password Quality: Good"));
|
||||
|
||||
editNewPassword->setText("");
|
||||
QTest::keyClicks(editNewPassword, "Bs5ZFfthWzR8DGFEjaCM6bGqhmCT4km");
|
||||
QCOMPARE(entropyLabel->text(), QString("Entropy: 174.59 bit"));
|
||||
QCOMPARE(strengthLabel->text(), QString("Password Quality: Excellent"));
|
||||
|
||||
// We are done
|
||||
}
|
||||
|
||||
void TestGui::testSearch()
|
||||
{
|
||||
// Add canned entries for consistent testing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue