Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FdoSecrets: Add unit tests for secret service integration #4232

Merged
merged 4 commits into from
May 29, 2020

Conversation

Aetf
Copy link
Contributor

@Aetf Aetf commented Jan 24, 2020

Type of change

  • ✅ Refactor (significant modification to existing code)
  • ✅ New feature (non-breaking change which adds functionality)

Description and Context

This adds proper unit tests to the secret service integration plugin. The tests cover most exposed API and some regression tests for previously fixed issues.

The first commit adds all test cases. The whole test is added as a GUI test because currently the plugin still depends on DatabaseWidget. Other changes included in this commit:

  • The ownership management of DatabaseOpenDialog inside DatabaseTabWidget is changed from using QScopedPointer to setting QObject parent. The lifetime of DatabaseOpenDialog is not affected, but it enables the testing code to access the DatabaseOpenDialog via object hierarchy.
  • Added a new argument LAUNCHER to the add_unit_test macro. The calling site can specify a launcher program used to start the test binary. This is needed to use dbus-run-session to run the dbus test.

The following commits fix issues discovered by newly added tests. One notable change is the addition of skipProtected option to the entry searcher. The option is disabled by default, so the behavior remains the same as before. When enabled, search terms referring to password or protected attributes are filtered out before the searcher performs the match. And if there are no terms left after filtering, the default is changed to not match, so the search API via DBus won't return everything when passing only this kind of terms. This is a more general solution of #4008, which only considers passwords.

Testing strategy

make test

CTest runner will automatically use dbus-run-session to run testguifdosecrets.

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]
  • ✅ My change requires a change to the documentation, and I have updated it accordingly.
  • ✅ I have added tests to cover my changes.

@Aetf Aetf force-pushed the feature/fdo-secrets-unittests branch 5 times, most recently from 2d71cc5 to d167be0 Compare January 24, 2020 21:41
@Aetf
Copy link
Contributor Author

Aetf commented Jan 24, 2020

Enough fighting CI for today 🤦‍♂️. The last issue seems to be missing dbus-run-session in the CI environment.

@droidmonkey
Copy link
Member

droidmonkey commented Jan 25, 2020

Easy fix, we can add that. Are there any version constraints?

@Aetf
Copy link
Contributor Author

Aetf commented Jan 25, 2020

Just did a quick search, on ubuntu, dbus-run-session is provided by the dbus package. I think the current 1.10.6 available in ubuntu repo should be fine, although I've only tested with 1.12.6.

@droidmonkey droidmonkey added this to the v2.6.0 milestone Feb 1, 2020
@Aetf Aetf force-pushed the feature/fdo-secrets-unittests branch from d167be0 to 9cc5e58 Compare February 16, 2020 01:04
@Aetf Aetf force-pushed the feature/fdo-secrets-unittests branch from 9cc5e58 to 82de2f2 Compare March 3, 2020 19:43
@droidmonkey droidmonkey modified the milestones: v2.6.0, v2.7.0 May 21, 2020
@Aetf Aetf force-pushed the feature/fdo-secrets-unittests branch from 82de2f2 to 000b149 Compare May 24, 2020 19:29
@Aetf
Copy link
Contributor Author

Aetf commented May 24, 2020

Ping. I rebased this on the latest develop.

@droidmonkey
Copy link
Member

If the tests pass I'll merge it :-D

@droidmonkey droidmonkey modified the milestones: v2.7.0, v2.6.0 May 24, 2020
@Aetf
Copy link
Contributor Author

Aetf commented May 24, 2020

Cool! Thanks for reviewing. This depends on #4776 to correctly cleanup between test cases, though.

@droidmonkey
Copy link
Member

Merged that one, please rebase again

@Aetf Aetf force-pushed the feature/fdo-secrets-unittests branch from 000b149 to c568671 Compare May 25, 2020 01:53
@Aetf
Copy link
Contributor Author

Aetf commented May 25, 2020

The failure in CI seems unrelated in TestCli::testEdit (Windows) and TestCli::testYubiKeyOption (Ubuntu).

@droidmonkey
Copy link
Member

Yah sometimes those trip for random reasons

src/gui/MainWindow.cpp Outdated Show resolved Hide resolved
src/gui/DatabaseTabWidget.cpp Show resolved Hide resolved
src/gui/DatabaseTabWidget.h Show resolved Hide resolved
src/core/EntrySearcher.cpp Outdated Show resolved Hide resolved
src/core/EntrySearcher.cpp Outdated Show resolved Hide resolved
src/core/EntrySearcher.h Outdated Show resolved Hide resolved
@lkilo
Copy link

lkilo commented May 25, 2020 via email

@droidmonkey
Copy link
Member

I made some minor tweaks (see comments above), good to go now.

@droidmonkey droidmonkey added the pr: tests Pull requests that adds or modifies tests label May 26, 2020
Copy link
Contributor Author

@Aetf Aetf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thanks, I was going to address the rest comments tomorrow :P.

All looks good to me except the logic behind skipping protected in the entry searcher. See my inline comments. Basically, pre-filtering the protected terms is still necessary and I think your initial comment of putting it in parsing should work. I just didn't get time to sit down and actually look at it. Will do it tomorrow.

src/core/EntrySearcher.cpp Outdated Show resolved Hide resolved
@Aetf Aetf force-pushed the feature/fdo-secrets-unittests branch 2 times, most recently from c284009 to dc5b097 Compare May 26, 2020 16:10
@Aetf Aetf force-pushed the feature/fdo-secrets-unittests branch from dc5b097 to e30233e Compare May 26, 2020 21:18
@Aetf
Copy link
Contributor Author

Aetf commented May 26, 2020

Rebased and squashed the fixups into the original commit.

@Aetf
Copy link
Contributor Author

Aetf commented May 26, 2020

It's TestCli::testYubiKeyOption again failing on Windows :/

@Aetf Aetf force-pushed the feature/fdo-secrets-unittests branch from 19609a5 to a1f599c Compare May 28, 2020 02:07
@Aetf Aetf merged commit 229a756 into keepassxreboot:develop May 29, 2020
@Aetf Aetf deleted the feature/fdo-secrets-unittests branch November 2, 2020 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: Secret Service pr: tests Pull requests that adds or modifies tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants