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
path: root/tests
diff options
context:
space:
mode:
authorToni Spets <toni.spets@iki.fi>2020-04-04 09:00:49 +0300
committerJonathan White <support@dmapps.us>2020-05-19 16:23:41 +0300
commita1b4a3f8b75781d2fbef2cbacf706c8cf9bc3cb0 (patch)
tree7816b6f57474fa301a632d2179a67af038624de3 /tests
parent9e17d52e8e1f98ec3490ddd0d2ea107cdcaf6a65 (diff)
SSH Agent: Track which database owns a key for remove-on-lock
Fixes #4532
Diffstat (limited to 'tests')
-rw-r--r--tests/TestSSHAgent.cpp15
-rw-r--r--tests/TestSSHAgent.h1
2 files changed, 12 insertions, 4 deletions
diff --git a/tests/TestSSHAgent.cpp b/tests/TestSSHAgent.cpp
index 4a13d64f8..a3137eb31 100644
--- a/tests/TestSSHAgent.cpp
+++ b/tests/TestSSHAgent.cpp
@@ -119,9 +119,16 @@ void TestSSHAgent::testIdentity()
bool keyInAgent;
// test adding a key works
- QVERIFY(agent.addIdentity(m_key, settings));
+ QVERIFY(agent.addIdentity(m_key, settings, m_uuid));
QVERIFY(agent.checkIdentity(m_key, keyInAgent) && keyInAgent);
+ // test non-conflicting key ownership doesn't throw an error
+ QVERIFY(agent.addIdentity(m_key, settings, m_uuid));
+
+ // test conflicting key ownership throws an error
+ QUuid secondUuid("{11111111-1111-1111-1111-111111111111}");
+ QVERIFY(!agent.addIdentity(m_key, settings, secondUuid));
+
// test removing a key works
QVERIFY(agent.removeIdentity(m_key));
QVERIFY(agent.checkIdentity(m_key, keyInAgent) && !keyInAgent);
@@ -139,7 +146,7 @@ void TestSSHAgent::testRemoveOnClose()
bool keyInAgent;
settings.setRemoveAtDatabaseClose(true);
- QVERIFY(agent.addIdentity(m_key, settings));
+ QVERIFY(agent.addIdentity(m_key, settings, m_uuid));
QVERIFY(agent.checkIdentity(m_key, keyInAgent) && keyInAgent);
agent.setEnabled(false);
QVERIFY(agent.checkIdentity(m_key, keyInAgent) && !keyInAgent);
@@ -160,7 +167,7 @@ void TestSSHAgent::testLifetimeConstraint()
settings.setLifetimeConstraintDuration(2); // two seconds
// identity should be in agent immediately after adding
- QVERIFY(agent.addIdentity(m_key, settings));
+ QVERIFY(agent.addIdentity(m_key, settings, m_uuid));
QVERIFY(agent.checkIdentity(m_key, keyInAgent) && keyInAgent);
QElapsedTimer timer;
@@ -193,7 +200,7 @@ void TestSSHAgent::testConfirmConstraint()
settings.setUseConfirmConstraintWhenAdding(true);
- QVERIFY(agent.addIdentity(m_key, settings));
+ QVERIFY(agent.addIdentity(m_key, settings, m_uuid));
// we can't test confirmation itself is working but we can test the agent accepts the key
QVERIFY(agent.checkIdentity(m_key, keyInAgent) && keyInAgent);
diff --git a/tests/TestSSHAgent.h b/tests/TestSSHAgent.h
index 6b99e8e65..13e8076e7 100644
--- a/tests/TestSSHAgent.h
+++ b/tests/TestSSHAgent.h
@@ -41,6 +41,7 @@ private:
QString m_agentSocketFileName;
QProcess m_agentProcess;
OpenSSHKey m_key;
+ QUuid m_uuid;
};
#endif // TESTSSHAGENT_H