Repository navigation
Conversation
The report findings filter now builds its test choices from the tests the current user can view, like the asset, engagement and organization choices in the same filter. Adds a test for the report pages that use it.
|
Adversarial review of this diff. CI is green, and I found nothing that blocks a merge. The scoping change is correct. I found no other field in this filter that needs the same change. My notes are below, most important first. 1. A Before this change, I checked this in a Django shell on 3.5.102 as a non-superuser:
The asset, engagement and organization fields in this filter already work this way, so the new behavior matches them. If a user loses access to a test, a saved report widget or bookmark for it now gives a wider report. The rows are still limited to findings the user can view. If we want an empty result instead, 2. The The test title also shows on that page outside the self.assertContains(response, f'<option value="{self.test_a.id}"')3. No check for a user who can view every test The PR body says nothing changes for those users, but no subtest asserts it. Add a superuser pass that expects both titles. 4. The choices are not narrowed to the report scope (older than this PR) On a test, engagement, asset or organization report, the dropdown lists every test the user can view. 5. The class default is still
test = ModelChoiceFilter(queryset=Test.objects.none(), label="Test")Then the field shows nothing if a later edit skips the 6. The option order is not fixed The registered 7. Small cleanups
What I checked
|
The test report page shows the test title outside the dropdown, so the old positive check passed with an empty dropdown. The test now looks for the option element itself. A second test checks that a superuser sees every test in the choices.
The test choices in the report findings filter now come from the tests the current user can view, like the asset, engagement and organization choices in the same filter. Adds a test for the report pages that use the filter. No change for users who can view every test.