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

Test the Vehicle VIN validator with known good and bad values, fixes … #2640

Merged
merged 5 commits into from
Jan 24, 2023
Merged

Test the Vehicle VIN validator with known good and bad values, fixes … #2640

merged 5 commits into from
Jan 24, 2023

Conversation

alextaujenis
Copy link
Contributor

Summary

An issue could occur where both the Vehicle VIN generator and validator are refactored in this library (for instance, changing the modulus operator from 11 to 10). This would change both the checksum generator and validator, allowing the test suite to pass, but fundamentally changing (and corrupting) the VIN checksum algorithm.

To protect against this, as well as giving confidence to anyone refactoring the Vehicle VIN generator or validator, several known good and bad VIN checks have been added as tests.

@alextaujenis
Copy link
Contributor Author

The only broken test here is fixed in #2638

Copy link
Contributor

@stefannibrasil stefannibrasil left a comment

Choose a reason for hiding this comment

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

hi @alextaujenis thanks for the PR! I left some comments.

test/faker/default/test_faker_vehicle.rb Outdated Show resolved Hide resolved
@alextaujenis
Copy link
Contributor Author

I removed the standalone (duplicate) vin regex test, which is checked inside the valid_vin method.

I think this PR is good to go.

Copy link
Contributor

@stefannibrasil stefannibrasil left a comment

Choose a reason for hiding this comment

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

Nice, thanks for improving the password tests, too. thank you @alextaujenis 💯

@stefannibrasil stefannibrasil merged commit 2f63c85 into faker-ruby:main Jan 24, 2023
@alextaujenis alextaujenis deleted the verify-vin branch February 1, 2023 21:01
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.

3 participants