Add manage_reports API key permission#2952
Merged
Merged
Conversation
Add MANAGE_REPORTS to the ApiKeyPermission enum so it flows into API_KEY_PERMISSION_TYPES and the ApiKey.permissions validator, making 'manage_reports' a grantable key permission. Enforcement on the reports endpoints will follow in a later change. Ref: cds-snc/notification-planning#3371
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new API-key-level permission (manage_reports) to the existing permission enum so it becomes a valid, persistable entry in ApiKey.permissions, with a DAO round-trip test to confirm persistence and lookup behavior.
Changes:
- Add
MANAGE_REPORTS = "manage_reports"toApiKeyPermissionso it’s included inAPI_KEY_PERMISSION_TYPES. - Add a DAO test that persists an API key with the new permission and verifies round-tripping +
has_permission()behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/models.py | Extends ApiKeyPermission with MANAGE_REPORTS, automatically expanding API_KEY_PERMISSION_TYPES used by the permissions validator. |
| tests/app/dao/test_api_key_dao.py | Adds coverage to ensure manage_reports is accepted, persisted, loaded back as expected, and recognized by has_permission(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
manage_reports API key permission
jzbahrai
reviewed
Jul 16, 2026
| assert fetched.permissions == ["manage_templates"] | ||
|
|
||
| def test_can_persist_and_round_trip_manage_reports_permission(self, sample_service): | ||
| from app.models import API_KEY_PERMISSION_TYPES, ApiKeyPermission |
Collaborator
There was a problem hiding this comment.
lets move this import to the top
…ds-snc/notification-api into feat/api-key-manage-reports-permission
jzbahrai
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary | Résumé
Add
MANAGE_REPORTSto theApiKeyPermissionenum so it flows into API_KEY_PERMISSION_TYPES and the ApiKey.permissions validator, making 'manage_reports' a grantable key permission.Related Issues | Cartes liées
Reviewer checklist | Liste de vérification du réviseur