Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2019-06-25 01:03:42 +0300
committerJonathan White <support@dmapps.us>2019-06-25 22:37:40 +0300
commit0e0cba653f2648842d90ceef957f52f9ec851f86 (patch)
tree790e7982c797e812f3e70bd8c5496e7762af1eb5 /tests/TestCli.cpp
parentbb2d7bca5a5de675d6ee1f4ec4c4f868229da47a (diff)
CLI: add 'analyze' subcommand for offline HIBP breach checks
This new subcommand checks all passwords in the given database against a given list of SHA-1 password hashes. Such lists are available from the "Have I Been Pwned" project at https://haveibeenpwned.com/Passwords. Note that this support offline checking only. The HIBP project also provides a web API for checking specific hash ranges; this is not currently supported.
Diffstat (limited to 'tests/TestCli.cpp')
-rw-r--r--tests/TestCli.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/TestCli.cpp b/tests/TestCli.cpp
index a7bb067c8..d65a7af6c 100644
--- a/tests/TestCli.cpp
+++ b/tests/TestCli.cpp
@@ -32,6 +32,7 @@
#include "format/KeePass2.h"
#include "cli/Add.h"
+#include "cli/Analyze.h"
#include "cli/Clip.h"
#include "cli/Command.h"
#include "cli/Create.h"
@@ -51,6 +52,7 @@
#include <QFile>
#include <QFuture>
#include <QSet>
+#include <QTextStream>
#include <QtConcurrent>
#include <cstdio>
@@ -160,8 +162,9 @@ QSharedPointer<Database> TestCli::readTestDatabase() const
void TestCli::testCommand()
{
- QCOMPARE(Command::getCommands().size(), 13);
+ QCOMPARE(Command::getCommands().size(), 14);
QVERIFY(Command::getCommand("add"));
+ QVERIFY(Command::getCommand("analyze"));
QVERIFY(Command::getCommand("clip"));
QVERIFY(Command::getCommand("create"));
QVERIFY(Command::getCommand("diceware"));
@@ -239,6 +242,22 @@ void TestCli::testAdd()
QCOMPARE(entry->password(), QString("newpassword"));
}
+void TestCli::testAnalyze()
+{
+ Analyze analyzeCmd;
+ QVERIFY(!analyzeCmd.name.isEmpty());
+ QVERIFY(analyzeCmd.getDescriptionLine().contains(analyzeCmd.name));
+
+ const QString hibpPath = QString(KEEPASSX_TEST_DATA_DIR).append("/hibp.txt");
+
+ Utils::Test::setNextPassword("a");
+ analyzeCmd.execute({"analyze", "--hibp", hibpPath, m_dbFile->fileName()});
+ m_stdoutFile->reset();
+ m_stdoutFile->readLine(); // skip password prompt
+ auto output = m_stdoutFile->readAll();
+ QVERIFY(output.contains("Sample Entry") && output.contains("123"));
+}
+
bool isTOTP(const QString& value)
{
QString val = value.trimmed();