Skip to content

fix(strr-api): keep a regular draft from being turned into a renewal outside the window (REGBACKLOG-391) - #1965

Merged
severinbeauvais merged 1 commit into
bcgov:feature-REGBACKLOG-391-v2from
severinbeauvais:REGBACKLOG-391-renewal-convert-guard
Dec 3, 2026
Merged

severinbeauvais merged 1 commit into
bcgov:feature-REGBACKLOG-391-v2from
severinbeauvais:REGBACKLOG-391-renewal-convert-guard

Conversation

@severinbeauvais

Copy link
Copy Markdown
Collaborator

Addresses Copilot's review comment on #1964.

Problem: /applications/{number} accepts POST as well as PUT, but the registration ID mismatch check ran only on PUT. Calling POST with isDraft on an existing regular draft, with a renewal payload, skipped that check. It also skipped the renewal window checks and the RENEWAL_ALREADY_IN_PROGRESS check, all of which exempt existing applications. save_application then turned the draft into a renewal. The web apps always use PUT for existing applications, so only a direct API call could do this.

Fix: run the mismatch check for any existing application, whatever the method. An existing draft now gets past those checks only if it is already a renewal of the requested registration.

Tests: test_regular_draft_cannot_become_renewal_outside_window covers POST and PUT, before the window opens and after it closes. Without the fix, both POST cases fail.

…outside the window (REGBACKLOG-391)

The registration ID check now applies to POST as well as PUT on /applications/{number}, so an existing draft can only skip the renewal window and in-progress checks if it is already a renewal of the requested registration.

Addresses review feedback on bcgov#1964.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 23:14
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

@severinbeauvais severinbeauvais self-assigned this Dec 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the renewal-window safeguard update.

No open issues 🎉

What changed in this PR

Closes a direct-API bypass in #1964’s renewal safeguards that allowed regular drafts to become renewals outside the permitted window.

Changes:

  • Applies the registration ID mismatch check to existing applications regardless of HTTP method.
  • Adds POST and PUT regression tests before the renewal window opens and after it closes.
File Description
strr-api/​tests/​unit/​resources/​test_renewal_window_api.py Tests rejection and verifies the draft remains unchanged.
strr-api/​src/​strr_api/​resources/​application.py Enforces registration ID matching for all existing applications.

Review effort: Balanced

@Jacky-Pham Jacky-Pham left a comment

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.

LGTM. The regular draft tests passed for POST and PUT.

@severinbeauvais
severinbeauvais merged commit e2b3e0a into bcgov:feature-REGBACKLOG-391-v2 Dec 3, 2026
9 checks passed
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.

4 participants