Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP-12240: Card length validation matches CARD_RANGE_LENGTH #1164

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

nataliecarey
Copy link
Contributor

@nataliecarey nataliecarey commented Feb 16, 2024

WHAT YOU DID

I used CARD_RANGE_LENGTH to define the minimum length for the card number as any card number shorter than this leads to a 404 even if the range is correct.

How to test

  • Pick a bin range from a CSV that's shorter than the maximum (currently 11) (e.g. 71221111 from src/test/resources/card-id-resource-integration-test/test-bin-ranges.csv)
  • Make requests with different numbers of zeros on the end of the prefix e.g. 71221111, then 712211110, then 7122111100

Expectation: The first requests should give validation failures (422 status code), then when they pass validation they should be found (200 status code), if you continue to make them longer you'll reach another validation failure (422 status code).

Current reality: The first requests should give validation failures (422 status code), then when they pass validation then when you reach 10 characters it will pass validation but fail to find the card (404 status code), then adding one more zero leads to it being found (200 status code), if you continue to make them longer you'll reach another validation failure (422 status code).

Code review checklist

Logging

  • No logging has been added as the validation already existed, it's just been updated

Documentation

  • No changes to the documentation as it already explains about updating the CARD_RANGE_LENGTH and already implies that no other change is needed - with this PR no other change is needed (AFAICT).

Copy link
Contributor

@nlsteers nlsteers left a comment

Choose a reason for hiding this comment

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

Looks good, one small comment

}

@Test
public void shouldErrorWhenOneCharTooShortCardNumberProvided() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this test is very similar to the one above, you can parameterise these to DRY this up a bit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, thanks.

Copy link
Contributor

@nlsteers nlsteers left a comment

Choose a reason for hiding this comment

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

🚀

@nataliecarey nataliecarey merged commit c57a79d into master Feb 19, 2024
9 checks passed
@nataliecarey nataliecarey deleted the PP-12240_card-length-validation branch February 19, 2024 11:37
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.

2 participants