mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-03-11 08:54:48 +00:00
Add test for healthcheck exclusion
Adds 2 groups, excludes one and makes sure it doesn't show up in the health check.
This commit is contained in:
parent
49e945d1c0
commit
3b3bb9a949
2 changed files with 111 additions and 6 deletions
|
|
@ -2473,11 +2473,11 @@ void TestGui::testDatabaseReports()
|
|||
|
||||
addEntry("Finance", "Chase", "user1", "password");
|
||||
addEntry("Finance", "Amex", "user1", "password123");
|
||||
addEntry("Finance", "Capital One", "user1", "lasdjfi309q23i8u2wjei");
|
||||
addEntry("Finance", "Capital One", "user1", "password456");
|
||||
|
||||
addEntry("Entertainment", "Netflix", "user1", "password");
|
||||
addEntry("Entertainment", "Hulu", "user1", "jwafh783jiwaef");
|
||||
addEntry("Entertainment", "Apple TV", "user1", "21983yr2weuajfduiwife;j");
|
||||
addEntry("Entertainment", "Hulu", "user1", "password321");
|
||||
addEntry("Entertainment", "Apple TV", "user1", "password123");
|
||||
|
||||
Group* entertainmentGroup = m_dbWidget->currentGroup()->findChildByName("Entertainment");
|
||||
QCOMPARE(entertainmentGroup->entries().size(), 3);
|
||||
|
|
@ -2521,7 +2521,109 @@ void TestGui::testDatabaseReports()
|
|||
QVERIFY(healthModel);
|
||||
|
||||
QTRY_COMPARE(healthCheckWidgetSpy.count(), 1);
|
||||
QCOMPARE(healthModel->rowCount(), 6);
|
||||
QCOMPARE(healthModel->rowCount(), 8); // account for 2 existing passwords at the start of each test case
|
||||
|
||||
auto *reportsDialogButtonBox = reportsDialog->findChild<QDialogButtonBox*>("buttonBox");
|
||||
QTest::mouseClick(reportsDialogButtonBox->button(QDialogButtonBox::Close), Qt::LeftButton);
|
||||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::ViewMode);
|
||||
}
|
||||
|
||||
void TestGui::testExcludedDatabaseReports()
|
||||
{
|
||||
addGroup("Finance");
|
||||
addGroup("Entertainment");
|
||||
|
||||
// Use bad passwords to make sure they all show up in health report
|
||||
addEntry("Finance", "Chase", "user1", "password");
|
||||
addEntry("Finance", "Amex", "user1", "password123");
|
||||
addEntry("Finance", "Capital One", "user1", "password456");
|
||||
|
||||
addEntry("Entertainment", "Netflix", "user1", "password");
|
||||
addEntry("Entertainment", "Hulu", "user1", "password321");
|
||||
addEntry("Entertainment", "Apple TV", "user1", "password123");
|
||||
|
||||
Group* entertainmentGroup = m_dbWidget->currentGroup()->findChildByName("Entertainment");
|
||||
m_dbWidget->groupView()->setCurrentGroup(entertainmentGroup);
|
||||
|
||||
auto* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
|
||||
QVERIFY(toolBar);
|
||||
|
||||
auto *editGroupAction = m_mainWindow->findChild<QAction*>("actionGroupEdit");
|
||||
QVERIFY(editGroupAction->isEnabled());
|
||||
triggerAction("actionGroupEdit");
|
||||
|
||||
auto* editGroupWidget = m_dbWidget->findChild<EditGroupWidget*>("editGroupWidget");
|
||||
QVERIFY(editGroupWidget);
|
||||
|
||||
// Bring up group edit page
|
||||
QTest::mouseClick(editGroupWidget, Qt::LeftButton);
|
||||
|
||||
QLineEdit* nameEdit = editGroupWidget->findChild<QLineEdit*>("editName");
|
||||
QCOMPARE(nameEdit->text(), QString("Entertainment"));
|
||||
|
||||
// Find database report exclusion checkbox and check it
|
||||
QCheckBox *excludeGroupFromReportsCheckbox = editGroupWidget->findChild<QCheckBox*>("excludeReportsCheckBox");
|
||||
QVERIFY(excludeGroupFromReportsCheckbox);
|
||||
|
||||
excludeGroupFromReportsCheckbox->setChecked(true);
|
||||
|
||||
auto* editGroupWidgetButtonBox = editGroupWidget->findChild<QDialogButtonBox*>("buttonBox");
|
||||
QVERIFY(editGroupWidgetButtonBox);
|
||||
|
||||
// Apply and go back to main view
|
||||
QTest::mouseClick(editGroupWidgetButtonBox->button(QDialogButtonBox::Apply), Qt::LeftButton);
|
||||
QTest::mouseClick(editGroupWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::ViewMode);
|
||||
|
||||
QVERIFY(entertainmentGroup->excludeFromReports());
|
||||
|
||||
// Verify they don't show up in the report
|
||||
auto *actionReports = m_mainWindow->findChild<QAction*>("actionReports");
|
||||
QVERIFY(actionReports->isEnabled());
|
||||
|
||||
QWidget* actionReportsWidget = toolBar->widgetForAction(actionReports);
|
||||
QVERIFY(actionReportsWidget);
|
||||
QVERIFY(actionReportsWidget->isVisible());
|
||||
QVERIFY(actionReportsWidget->isEnabled());
|
||||
|
||||
QTest::mouseClick(actionReportsWidget, Qt::LeftButton);
|
||||
|
||||
auto *reportsDialog = m_dbWidget->findChild<ReportsDialog*>("reportsDialog");
|
||||
QVERIFY(reportsDialog);
|
||||
|
||||
CategoryListWidget *categoryList = reportsDialog->findChild<CategoryListWidget*>("categoryList");
|
||||
categoryList->setCurrentCategory(1);
|
||||
|
||||
QStackedWidget *stackedWidget = reportsDialog->findChild<QStackedWidget*>("stackedWidget");
|
||||
QVERIFY(stackedWidget);
|
||||
stackedWidget->setCurrentIndex(1);
|
||||
|
||||
ReportsWidgetHealthcheck* healthCheckWidget = reportsDialog->findChild<ReportsWidgetHealthcheck*>();
|
||||
QVERIFY(healthCheckWidget);
|
||||
|
||||
QTest::mouseClick(healthCheckWidget, Qt::LeftButton);
|
||||
QTableView *healthTable = healthCheckWidget->findChild<QTableView*>("healthcheckTableView");
|
||||
QVERIFY(healthTable);
|
||||
|
||||
QSignalSpy healthCheckWidgetSpy(healthCheckWidget, &ReportsWidgetHealthcheck::tablePopulated);
|
||||
|
||||
QAbstractItemModel *healthModel = healthTable->model();
|
||||
QVERIFY(healthModel);
|
||||
|
||||
// There should be 3 showing
|
||||
QTRY_COMPARE(healthCheckWidgetSpy.count(), 1);
|
||||
QCOMPARE(healthModel->rowCount(), 5); // account for 2 existing passwords at the start of each test case
|
||||
|
||||
QCheckBox *showExcludedCheckBox = healthCheckWidget->findChild<QCheckBox*>("showExcluded");
|
||||
QVERIFY(showExcludedCheckBox);
|
||||
QCOMPARE(showExcludedCheckBox->isChecked(), false);
|
||||
|
||||
showExcludedCheckBox->click();
|
||||
QVERIFY(showExcludedCheckBox->isChecked());
|
||||
QTRY_COMPARE(healthCheckWidgetSpy.count(), 2);
|
||||
|
||||
healthModel = healthTable->model();
|
||||
QCOMPARE(healthModel->rowCount(), 8); // account for 2 existing passwords at the start of each test case
|
||||
|
||||
auto *reportsDialogButtonBox = reportsDialog->findChild<QDialogButtonBox*>("buttonBox");
|
||||
QTest::mouseClick(reportsDialogButtonBox->button(QDialogButtonBox::Close), Qt::LeftButton);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ private slots:
|
|||
void cleanup();
|
||||
void cleanupTestCase();
|
||||
|
||||
|
||||
void testDatabaseReports();
|
||||
void testExcludedDatabaseReports();
|
||||
|
||||
private:
|
||||
void testSettingsDefaultTabOrder();
|
||||
void testCreateDatabase();
|
||||
void testMergeDatabase();
|
||||
|
|
@ -71,9 +76,7 @@ private slots:
|
|||
void testTrayRestoreHide();
|
||||
void testShortcutConfig();
|
||||
void testMenuActionStates();
|
||||
void testExcludeGroupFromReports();
|
||||
|
||||
private:
|
||||
void addCannedEntries();
|
||||
void addGroup(const QString &name);
|
||||
void addEntry(const QString &groupName, const QString &title, const QString &username, const QString &password);
|
||||
|
|
|
|||
Loading…
Reference in a new issue