fix(delcus): cross-validate body CommCustno vs path, single-space CommDelFailCd#38
Merged
fix(delcus): cross-validate body CommCustno vs path, single-space CommDelFailCd#38
Conversation
…mDelFailCd Closes #23. * DelcusController: when the body's CommCustno is non-empty, it must match the path customerNumber (compared as long, tolerating leading zeros). Mismatch returns HTTP 400 with the standard 'Validation failed' ProblemDetail so a misaddressed request can never silently delete the path target. * DelcusController: emit ' ' instead of '' for CommDelFailCd on success to preserve the fixed-width 1-char commarea contract for clients porting from COBOL. * DelcusControllerWebMvcTest: tighten happy-path assertion and add rejectsBodyCommCustnoThatMismatchesPath + acceptsMatchingBodyCommCustno.
Contributor
|
✅ Test coverage looks good. The new/changed behavior in this PR has adequate test coverage. No additional tests needed. The new validation logic (cross-checking body
|
a2chang
added a commit
that referenced
this pull request
May 1, 2026
…path / configured sortcode (#39) 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. Co-authored-by: Augment Agent <agent@augmentcode.com>
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.
Closes #23.
What
Two follow-ups against
DelcusController, both flagged at the round-3 cap on PR #21:1. (medium) Cross-validate body
CommCustnoagainst pathOn
DELETE /api/v1/delcus/remove/{customerNumber}, the body'sdelCus.commCustnowas previously ignored. A request whose path and body disagree would silently delete the path target. Now: whencommCustnois supplied (the field's pattern allows the empty string for clients sending only the path), it must equal the path value (compared aslong, so leading zeros are tolerated). Mismatch → HTTP 400 withProblemDetailtitle="Validation failed",detail="Body CommCustno does not match path customerNumber.".2. (low) Single-space
CommDelFailCdplaceholder on successCommDelFailCdis a fixed-width 1-char commarea slot. The success response now emits" "instead of""to preserve the length-1 contract for clients porting from COBOL.Tests
DelcusControllerWebMvcTest(6 tests, all green):returnsSuccessfulResponseForHappyPath— tightened to also assertCommDelFailCd == " ".rejectsBodyCommCustnoThatMismatchesPath— new; path1, body0000000002→ 400 with the validation ProblemDetail above.acceptsMatchingBodyCommCustno— new; path1, body0000000001→ 200 (also covers the leading-zero tolerance).Local
./mvnw verifygreen: 189/189.augment review