fix(delacc): cross-validate body DelAccAccno and DelAccScode on DELETE#39
Merged
fix(delacc): cross-validate body DelAccAccno and DelAccScode on DELETE#39
Conversation
…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.
Contributor
|
✅ Test coverage looks good. The new/changed behavior in this PR has adequate test coverage. No additional tests needed. The three new tests in
|
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 #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 consultDelAccAccnoorDelAccScodeat 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:
DelAccAccnoisLong/optional. When non-null, it must equal the pathaccno. Mismatch → 400 withdetail="Body DelAccAccno does not match path accno.".DelAccScodeisString/optional (pattern allows""). When non-empty, it must equalcbsa.sortcode. Mismatch → 400 withdetail="Body DelAccScode does not match the configured branch sortcode.".Both responses are the standard
Validation failedProblemDetail. No service-level changes — the controller short-circuits before invokingdelaccService.delete.Tests
DelaccControllerWebMvcTest(8 tests, all green; pinnedcbsa.sortcode=987654via@TestPropertySourceto match the existing happy-path body):rejectsBodyAccnoThatMismatchesPath— newrejectsBodyScodeThatMismatchesConfiguredSortcode— newallowsEmptyOrNullBodyKeyFields— new (omittingDelAccAccno,DelAccScode=""still 200)Local
./mvnw verifygreen: 192/192.augment review