Skip to content

Update methods in the CreditCardValidation model to use hashes

What does this MR do and why?

Screenshots

Page Before After
User profile user-profile-before user-profile-after
Card matches card-matches-before card-matches-after
Abuse Report abuse-report-before abuse-report-after

How to set up and validate locally

  1. Turn on SaaS mode
export GITLAB_SIMULATE_SAAS = 1
gdk restart
  1. Create two credit card records in the rails console:
> user1 = User.first.id
> c1 = Users::CreditCardValidation.create(user_id: User.first.id, last_digits: 1111, credit_card_validated_at: Date.today, expiration_date: 1.year.from_now.to_date, holder_name: 'John Doe', network: 'Visa')

> user2 = User.last.id
> c2 = Users::CreditCardValidation.create(user_id: User.last.id, last_digits: 1111, credit_card_validated_at: Date.today, expiration_date: 1.year.from_now.to_date, holder_name: 'John Doe', network: 'Visa')
  1. Now to check that we are correctly getting credit card matches, run:
> c1.similar_records
=> 2

> c1.similar_holder_names_count 
=> 2
  1. We can also ban user2 to make sure that we can check if a credit card is being used by a banned user:
> user2.ban!

> c1.used_by_banned_user?
=> true

User profile page 4. You can also, log-in as admin and navigate to user1's profile - http://127.0.0.1:3000/admin/users/:user1_username. You should see a Credit card section, but with only Validated at field.

Card matches page 5. Click on View card matches and you should see the credit cards we created in step 2. Previously, when displaying credit card matches we would show the holder name, last digits and expiration date of the credit card which we have removed in this MR, and replaced that with the name of the user with the matching credit card.

Abuse report page 6. Lastly, we can also create an abuse report for user1 to make sure that holder name has been removed from the abuse report as well. In the rails console:

AbuseReport.create(user_id: user1, reporter_id: 1, category: 'spam', message: 'test')
  1. Navigate to the abuse report, http://127.0.0.1:3000/admin/abuse_reports/:abuse_report_id. Next to the Credit card section you should not see the card's holder name.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #413525

Edited by Hinam Mehra

Merge request reports