diff options
author | Aetf <aetf@unlimitedcodeworks.xyz> | 2019-02-21 08:51:23 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2019-05-12 19:35:42 +0300 |
commit | d93f33f51417ed6e1d3e5112a52a7d0c2b9c454e (patch) | |
tree | 5851e886d5e100e9b22dbdcf981b75f900c8a82f /tests/TestEntrySearcher.cpp | |
parent | bc891761b6d15345f240e79c7439b27869d94871 (diff) |
Improve existing code prior to implementing FDO Secrets
* DatabaseTabWidget::newDatabase returns the created DatabaseWidget
* Emit DatabaseTabWidget::databaseOpened signal before a new tab is added
* EntrySearcher can now search attribute values including custom ones
* Add Group::applyGroupIconTo to set the group icon on the supplied entry
* Implement desktop notifications through the system tray icon
* Add DatabaseWidget::deleteEntries to delete a list of entries
* Add Aes128 in SymmetricCipher::algorithmIvSize
* Add DatabaseWidget::databaseReplaced signal
* Add a helper class to override the message box's parent (prevent bugs)
Diffstat (limited to 'tests/TestEntrySearcher.cpp')
-rw-r--r-- | tests/TestEntrySearcher.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/TestEntrySearcher.cpp b/tests/TestEntrySearcher.cpp index e949b97b8..5a14481ae 100644 --- a/tests/TestEntrySearcher.cpp +++ b/tests/TestEntrySearcher.cpp @@ -210,4 +210,40 @@ void TestEntrySearcher::testSearchTermParser() QCOMPARE(terms[1]->field, EntrySearcher::Field::Username); QCOMPARE(terms[1]->regex.pattern(), QString("\\d+\\w{2}")); + + // Test custom attribute search terms + m_entrySearcher.parseSearchTerms("+_abc:efg _def:\"ddd\""); + terms = m_entrySearcher.m_searchTerms; + + QCOMPARE(terms.length(), 2); + + QCOMPARE(terms[0]->field, EntrySearcher::Field::AttributeValue); + QCOMPARE(terms[0]->word, QString("abc")); + QCOMPARE(terms[0]->regex.pattern(), QString("^efg$")); + + QCOMPARE(terms[1]->field, EntrySearcher::Field::AttributeValue); + QCOMPARE(terms[1]->word, QString("def")); + QCOMPARE(terms[1]->regex.pattern(), QString("ddd")); +} + +void TestEntrySearcher::testCustomAttributesAreSearched() +{ + QScopedPointer<Entry> e1(new Entry()); + e1->setGroup(m_rootGroup); + + e1->attributes()->set("testAttribute", "testE1"); + e1->attributes()->set("testProtected", "testP", true); + + QScopedPointer<Entry> e2(new Entry()); + e2->setGroup(m_rootGroup); + e2->attributes()->set("testAttribute", "testE2"); + e2->attributes()->set("testProtected", "testP2", true); + + // search for custom entries + m_searchResult = m_entrySearcher.search("_testAttribute:test", m_rootGroup); + QCOMPARE(m_searchResult.count(), 2); + + // protected attributes are ignored + m_searchResult = m_entrySearcher.search("_testAttribute:test _testProtected:testP2", m_rootGroup); + QCOMPARE(m_searchResult.count(), 2); } |