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

Test coverage of access controls #3599

Open
3 tasks
Matt-Spence opened this issue Feb 28, 2025 · 0 comments
Open
3 tasks

Test coverage of access controls #3599

Matt-Spence opened this issue Feb 28, 2025 · 0 comments

Comments

@Matt-Spence
Copy link
Contributor

Matt-Spence commented Feb 28, 2025

Issue description

Right now our testing for permissions consists of two methods: a full check on all urls in test_urls_auth.py, or ad-hoc permissions tests scattered around our testing files. The problem with the former is that it only checks for authentication, ensuring endpoints require a valid login.gov account before providing access. It doesn't check specific access controls (permission restrictions) beyond that. The latter, on the other hand, is not systemic in any way and likely has large gaps.

This is an opportunity to improve our test coverage. We should implement a system where all endpoints are checked for access controls against some central source of truth. This should ideally be done in a way that will automatically cover any new urls we create, so that tests cannot pass if access controls on all urls don't match the source of truth.

Acceptance criteria

  • New unit tests are added that check that the correct permissions are required to access all django admin, including analytics, pages mentioned in urls.py and the "domain/" pages
  • all urls in urls.py are checked
  • a developer would get python-test errors if a new url is added whose permissions are not explicitly set in the unit test(s) (such as a central source of truth used by the unit tests)

Limiting scope to the admin pages (including analytics) and domain pages due to the sheer number of urls we have. Follow on tickets would build on this for the other pages

Additional context

The approach chosen should be expandable in the future as we will build on this.

Ideally, we would have a central source of truth is created where all access controls for all urls are listed in some format. New test(s)would then check access controls against the central source of truth. Then, if If a url is not found in the source of truth the test should fail, to enforce that all urls should be in the source of truth.

Our recent permissions audit should provide an excellent starting point for the central source of truth. Once that is created in some machine-readable format, it should be possible to loop through urls.py and check every view there against the source of truth.

link to slack thread

Links to other issues

No response

@allly-b allly-b moved this from 👶 New to ⚙ Dev Parking Lot in .gov Product Board Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ⚙ Dev Parking Lot
Development

No branches or pull requests

1 participant