Skip to content

fix(delacc): cross-validate body DelAccAccno and DelAccScode on DELETE#39

Merged
a2chang merged 1 commit intomainfrom
polish/delacc-followup
May 1, 2026
Merged

fix(delacc): cross-validate body DelAccAccno and DelAccScode on DELETE#39
a2chang merged 1 commit intomainfrom
polish/delacc-followup

Conversation

@a2chang
Copy link
Copy Markdown
Contributor

@a2chang a2chang commented May 1, 2026

Closes #26.

What

Same shape as the DELCUS cross-validation in #23/PR #38, applied to DelaccController.

Previously DELETE /api/v1/delacc/remove/{accno} validated the request body's commarea via bean-validation but did not consult DelAccAccno or DelAccScode at all — the delete was driven solely by the path. A request whose body disagreed with the path/configured sortcode would still delete the path account.

Now, after bean-validation:

  • DelAccAccno is Long/optional. When non-null, it must equal the path accno. Mismatch → 400 with detail="Body DelAccAccno does not match path accno.".
  • DelAccScode is String/optional (pattern allows ""). When non-empty, it must equal cbsa.sortcode. Mismatch → 400 with detail="Body DelAccScode does not match the configured branch sortcode.".

Both responses are the standard Validation failed ProblemDetail. No service-level changes — the controller short-circuits before invoking delaccService.delete.

Tests

DelaccControllerWebMvcTest (8 tests, all green; pinned cbsa.sortcode=987654 via @TestPropertySource to match the existing happy-path body):

  • rejectsBodyAccnoThatMismatchesPath — new
  • rejectsBodyScodeThatMismatchesConfiguredSortcode — new
  • allowsEmptyOrNullBodyKeyFields — new (omitting DelAccAccno, DelAccScode="" still 200)
  • existing 5 tests still pass

Local ./mvnw verify green: 192/192.

augment review

…path / configured sortcode

Closes #26.

Mirrors the DELCUS path/body cross-validation from PR #38. After
bean-validation, the controller now rejects the request when:

* delAccAccno is non-null and does not equal the path accno, or
* delAccScode is non-empty and does not equal cbsa.sortcode.

Both yield the standard 'Validation failed' ProblemDetail at HTTP 400,
short-circuiting before delaccService.delete is invoked, so a
misaddressed request can never silently delete the path account.

Tests: DelaccControllerWebMvcTest now pins cbsa.sortcode=987654 via
@TestPropertySource and adds rejectsBodyAccnoThatMismatchesPath,
rejectsBodyScodeThatMismatchesConfiguredSortcode, and
allowsEmptyOrNullBodyKeyFields.
@augmentcode
Copy link
Copy Markdown
Contributor

augmentcode Bot commented May 1, 2026

Test Coverage Guardian 🧪

Test coverage looks good. The new/changed behavior in this PR has adequate test coverage. No additional tests needed.

The three new tests in DelaccControllerWebMvcTest comprehensively cover:

  • Account number mismatch validation
  • Sortcode mismatch validation
  • Optional field handling (null/empty values)

Copy link
Copy Markdown

@augment-app-staging augment-app-staging Bot left a comment

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@a2chang a2chang merged commit 6abce31 into main May 1, 2026
1 check passed
@a2chang a2chang deleted the polish/delacc-followup branch May 1, 2026 20:30
@a2chang a2chang mentioned this pull request May 1, 2026
22 tasks
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.

DELACC follow-up: validate body fields against path on DELETE

1 participant