mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-02 06:36:07 -04:00
SSH Agent: Track which database owns a key for remove-on-lock
Fixes #4532
This commit is contained in:
parent
9e17d52e8e
commit
a1b4a3f8b7
6 changed files with 60 additions and 37 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue