Expose created/updated date filters for Risk Acceptance API (created_before/after, updated_before/after)#14786
Expose created/updated date filters for Risk Acceptance API (created_before/after, updated_before/after)#14786PDFour4 wants to merge 7 commits intoDefectDojo:devfrom
Conversation
1e2803f to
55a722f
Compare
|
@PDFour4 PRs need to be against the Dev branch - please update this PR to be against that branch. For details see: |
|
@mtesauro I've updated the PR base branch from master to dev. Should be all set now! |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
• use DateRangeFilter for created and updated • add explicit DateTimeFilter comparisons • updated risk acceptance API tests to assert new query params and deterministic result inclusion
2d8bfa8 to
7a0ed0a
Compare
|
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Update:The filter implementation has evolved since this PR was initiated. The maintainers have refactored ApiRiskAcceptanceFilter to use a dictionary-style fields configuration with automatic lookup expressions (gt/lt), which replaces the original explicit DateTimeFilter definitions my team initially contributed. Both approaches provide identical functionality and expose the same query parameters in the OpenAPI schema. This PR now focuses on adding comprehensive tests for the risk acceptance timestamp filters created_before/after, updated_before/after. The tests validate the new upstream implementation and ensure the filtering behavior works correctly. Locally verified: Both test_risk_acceptance_created_filter and test_risk_acceptance_updated_filter pass successfully with the latest code. |
|
@PDFour4 Aren't these filters already present on |
|
converted to draft as closure is pending for this PR as the feature is already in place in dev. |
|
@valentijnscholten yes it seems to already be implemented so all this pr does is add tests for those implemented features. If not needed I can close the pr. |
| created_before = DateTimeFilter(field_name="created", lookup_expr="lt") | ||
| created_after = DateTimeFilter(field_name="created", lookup_expr="gt") | ||
| updated_before = DateTimeFilter(field_name="updated", lookup_expr="lt") | ||
| updated_after = DateTimeFilter(field_name="updated", lookup_expr="gt") |
There was a problem hiding this comment.
these are redundant and without them the PR can be closed.
Summary
This adds before/after DateTime filter parameters for
createdandupdatedon the Risk Acceptance API and aligns the filter naming with existing API conventions.Changes
dojo/filters.py—ApiRiskAcceptanceFilter: useDateRangeFilterforcreated/updatedand add explicitcreated_before,created_after,updated_before,updated_after(DateTimeFilterwithlt/gt).unittests/test_risk_acceptance_api.py— addcreate_risk_acceptancetest helper and update tests to assert the new query params deterministically.Why
Consumers need precise before/after semantics for risk acceptance timestamps. This follows the established pattern used across the API (DateRangeFilter + explicit
_before/_afterDateTime filters) and ensures OpenAPI schema exposes the correct params.Fixes #14623
Testing
unittests/test_risk_acceptance_api.py. Run targeted tests:No migrations required.