feat(aci): Add ability to filter workflows by connected detectors#105695
feat(aci): Add ability to filter workflows by connected detectors#105695
Conversation
| detector_ids = [int(id) for id in raw_detectorlist] | ||
| except ValueError: | ||
| raise ValidationError({"detector": ["Invalid detector ID format"]}) | ||
| queryset = queryset.filter(detectorworkflow__detector_id__in=detector_ids).distinct() |
There was a problem hiding this comment.
let's also add a filter here for the users organization -- that way we can prevent any possible security issues where a user asks for a detector not part of their org.
There was a problem hiding this comment.
We are already adding the org filter at the top of filter_workflows
There was a problem hiding this comment.
ah, i didn't notice it was the same queryset 👍
| assert len(response3.data) == 2 | ||
| assert {self.workflow.name, self.workflow_two.name} == {w["name"] for w in response3.data} | ||
|
|
||
| def test_filter_by_detector(self) -> None: |
There was a problem hiding this comment.
thoughts on adding a test case for selecting a detector not part of your org and ensure it returns the correct status codes? (my guess is we'd either want to 401 or 404)
There was a problem hiding this comment.
I can add a test case for it certainly. I think the current behavior is correct (which is that it will just return an empty list)
Adds the ability to do
/organizations/org-slug/workflows/?detector=1&detector=2which will return workflows connected to either of those two detectors.