-
Notifications
You must be signed in to change notification settings - Fork 13.1k
fix: audit.settings endpoint filtering by actor returning empty results
#36027
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
Conversation
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: f0ec90a The changes in this PR will be included in the next version bump. This PR includes changesets to release 36 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #36027 +/- ##
===========================================
- Coverage 64.73% 64.61% -0.12%
===========================================
Files 3107 3256 +149
Lines 93094 96255 +3161
Branches 17748 18045 +297
===========================================
+ Hits 60267 62198 +1931
- Misses 30040 31125 +1085
- Partials 2787 2932 +145
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Proposed changes (including videos or screenshots)
The filtering by actor was not working, and 2 issues were identified:
endtest function was being called at the end of the test, nor were the promises being awaited. This means every possible error was being ommited. Also in the filtering tests, the result was only being asserted by verifying if the result was an array, and not ensuring that the results match the passed query.actorfilter arrives in the endpoint function as an object, and being directly passed to the query. When passing objects in a mongo query, it only matches if there's a full match between the objects. This means that passingactor: { type: 'user' }returns no records, becauseactorhas many more properties, thus not an exact match.Firstly the tests were improved by awaiting the promises, and adding extra assertions, guaranteeing that they are failing with the current implementation, and that the filters are working properly.
Then the issue was fixed by mapping the actor object properties to a proper mongo query, transforming
actor: { type: 'user', _id: 'xxx' }to{ 'actor.type': 'user', 'actor._id': 'xxx' }.This PR should fix the issue, and ensure it doesn't happen again due to fixed/improved tests.
Issue(s)
CORE-1159
Steps to test or reproduce
Further comments