Skip to content

Add manage_reports API key permission#2952

Merged
smcmurtry merged 4 commits into
mainfrom
feat/api-key-manage-reports-permission
Jul 17, 2026
Merged

Add manage_reports API key permission#2952
smcmurtry merged 4 commits into
mainfrom
feat/api-key-manage-reports-permission

Conversation

@smcmurtry

@smcmurtry smcmurtry commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary | Résumé

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.

Related Issues | Cartes liées

Reviewer checklist | Liste de vérification du réviseur

  • This PR does not break existing functionality.
  • This PR does not violate GCNotify's privacy policies.
  • This PR does not raise new security concerns. Refer to our GC Notify Risk Register document on our Google drive.
  • This PR does not significantly alter performance.
  • Additional required documentation resulting of these changes is covered (such as the README, setup instructions, a related ADR or the technical documentation).

⚠ If boxes cannot be checked off before merging the PR, they should be moved to the "Release Instructions" section with appropriate steps required to verify before release. For example, changes to celery code may require tests on staging to verify that performance has not been affected.

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
Copilot AI review requested due to automatic review settings July 16, 2026 19:23
@smcmurtry
smcmurtry requested a review from jimleroyer as a code owner July 16, 2026 19:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" to ApiKeyPermission so it’s included in API_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.

@smcmurtry smcmurtry changed the title feat(api-key): add manage_reports API key permission Add manage_reports API key permission Jul 16, 2026
Comment thread tests/app/dao/test_api_key_dao.py Outdated
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets move this import to the top

…ds-snc/notification-api into feat/api-key-manage-reports-permission
@smcmurtry
smcmurtry merged commit 0656757 into main Jul 17, 2026
18 checks passed
@smcmurtry
smcmurtry deleted the feat/api-key-manage-reports-permission branch July 17, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants