Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: components/autofill/core/browser/credit_card_unittest.cc

Issue 2170773002: UnionPay credit card numbers now validated by Luhn checksum. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/autofill/core/browser/validation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 "6011 0009 9013 9424", 43 "6011 0009 9013 9424",
44 "3530-1113-3330-0000", 44 "3530-1113-3330-0000",
45 "3566002020360505", 45 "3566002020360505",
46 "5555 5555 5555 4444", 46 "5555 5555 5555 4444",
47 "5105-1051-0510-5100", 47 "5105-1051-0510-5100",
48 "4111111111111111", 48 "4111111111111111",
49 "4012 8888 8888 1881", 49 "4012 8888 8888 1881",
50 "4222-2222-2222-2", 50 "4222-2222-2222-2",
51 "5019717010103742", 51 "5019717010103742",
52 "6331101999990016", 52 "6331101999990016",
53 53 "6247130048162403",
54 // A UnionPay card that doesn't pass the Luhn checksum
55 "6200000000000000",
56 }; 54 };
57 const char* const kInvalidNumbers[] = { 55 const char* const kInvalidNumbers[] = {
58 "4111 1111 112", /* too short */ 56 "4111 1111 112", /* too short */
59 "41111111111111111115", /* too long */ 57 "41111111111111111115", /* too long */
60 "4111-1111-1111-1110", /* wrong Luhn checksum */ 58 "4111-1111-1111-1110", /* wrong Luhn checksum */
61 "3056 9309 0259 04aa", /* non-digit characters */ 59 "3056 9309 0259 04aa", /* non-digit characters */
62 }; 60 };
63 61
64 } // namespace 62 } // namespace
65 63
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 { "6011000990139424", kDiscoverCard, true }, 633 { "6011000990139424", kDiscoverCard, true },
636 { "3530111333300000", kJCBCard, true }, 634 { "3530111333300000", kJCBCard, true },
637 { "3566002020360505", kJCBCard, true }, 635 { "3566002020360505", kJCBCard, true },
638 { "5555555555554444", kMasterCard, true }, 636 { "5555555555554444", kMasterCard, true },
639 { "5105105105105100", kMasterCard, true }, 637 { "5105105105105100", kMasterCard, true },
640 { "4111111111111111", kVisaCard, true }, 638 { "4111111111111111", kVisaCard, true },
641 { "4012888888881881", kVisaCard, true }, 639 { "4012888888881881", kVisaCard, true },
642 { "4222222222222", kVisaCard, true }, 640 { "4222222222222", kVisaCard, true },
643 641
644 // The relevant sample numbers from 642 // The relevant sample numbers from
645 // http://auricsystems.com/support-center/sample-credit-card-numbers/ 643 // https://www.auricsystems.com/sample-credit-card-numbers/
646 { "343434343434343", kAmericanExpressCard, true }, 644 { "343434343434343", kAmericanExpressCard, true },
647 { "371144371144376", kAmericanExpressCard, true }, 645 { "371144371144376", kAmericanExpressCard, true },
648 { "341134113411347", kAmericanExpressCard, true }, 646 { "341134113411347", kAmericanExpressCard, true },
649 { "36438936438936", kDinersCard, true }, 647 { "36438936438936", kDinersCard, true },
650 { "36110361103612", kDinersCard, true }, 648 { "36110361103612", kDinersCard, true },
651 { "36111111111111", kDinersCard, true }, 649 { "36111111111111", kDinersCard, true },
652 { "6011016011016011", kDiscoverCard, true }, 650 { "6011016011016011", kDiscoverCard, true },
653 { "6011000990139424", kDiscoverCard, true }, 651 { "6011000990139424", kDiscoverCard, true },
654 { "6011000000000004", kDiscoverCard, true }, 652 { "6011000000000004", kDiscoverCard, true },
655 { "6011000995500000", kDiscoverCard, true }, 653 { "6011000995500000", kDiscoverCard, true },
656 { "6500000000000002", kDiscoverCard, true }, 654 { "6500000000000002", kDiscoverCard, true },
657 { "3566002020360505", kJCBCard, true }, 655 { "3566002020360505", kJCBCard, true },
658 { "3528000000000007", kJCBCard, true }, 656 { "3528000000000007", kJCBCard, true },
659 { "5500005555555559", kMasterCard, true }, 657 { "5500005555555559", kMasterCard, true },
660 { "5555555555555557", kMasterCard, true }, 658 { "5555555555555557", kMasterCard, true },
661 { "5454545454545454", kMasterCard, true }, 659 { "5454545454545454", kMasterCard, true },
662 { "5555515555555551", kMasterCard, true }, 660 { "5555515555555551", kMasterCard, true },
663 { "5405222222222226", kMasterCard, true }, 661 { "5405222222222226", kMasterCard, true },
664 { "5478050000000007", kMasterCard, true }, 662 { "5478050000000007", kMasterCard, true },
665 { "5111005111051128", kMasterCard, true }, 663 { "5111005111051128", kMasterCard, true },
666 { "5112345112345114", kMasterCard, true }, 664 { "5112345112345114", kMasterCard, true },
667 { "5115915115915118", kMasterCard, true }, 665 { "5115915115915118", kMasterCard, true },
668 666 { "6247130048162403", kUnionPay, true },
669 // A UnionPay card that doesn't pass the Luhn checksum 667 { "6247130048162403", kUnionPay, true },
670 { "6200000000000000", kUnionPay, true }, 668 { "622384452162063648", kUnionPay, true },
671 669
672 // Empty string 670 // Empty string
673 { std::string(), kGenericCard, false }, 671 { std::string(), kGenericCard, false },
674 672
675 // Non-numeric 673 // Non-numeric
676 { "garbage", kGenericCard, false }, 674 { "garbage", kGenericCard, false },
677 { "4garbage", kVisaCard, false }, 675 { "4garbage", kVisaCard, false },
678 676
679 // Fails Luhn check. 677 // Fails Luhn check.
680 { "4111111111111112", kVisaCard, false }, 678 { "4111111111111112", kVisaCard, false },
679 { "6247130048162413", kUnionPay, false },
681 680
682 // Invalid length. 681 // Invalid length.
683 { "3434343434343434", kAmericanExpressCard, false }, 682 { "3434343434343434", kAmericanExpressCard, false },
684 { "411111111111116", kVisaCard, false }, 683 { "411111111111116", kVisaCard, false },
685 684
686 // Issuer Identification Numbers (IINs) that Chrome recognizes. 685 // Issuer Identification Numbers (IINs) that Chrome recognizes.
687 { "4", kVisaCard, false }, 686 { "4", kVisaCard, false },
688 { "34", kAmericanExpressCard, false }, 687 { "34", kAmericanExpressCard, false },
689 { "37", kAmericanExpressCard, false }, 688 { "37", kAmericanExpressCard, false },
690 { "300", kDinersCard, false }, 689 { "300", kDinersCard, false },
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 card.set_record_type(kTestCases[i].record_type); 898 card.set_record_type(kTestCases[i].record_type);
900 if (card.record_type() != CreditCard::LOCAL_CARD) 899 if (card.record_type() != CreditCard::LOCAL_CARD)
901 card.SetServerStatus(kTestCases[i].server_status); 900 card.SetServerStatus(kTestCases[i].server_status);
902 901
903 EXPECT_EQ(kTestCases[i].should_update_expiration, 902 EXPECT_EQ(kTestCases[i].should_update_expiration,
904 card.ShouldUpdateExpiration(now)); 903 card.ShouldUpdateExpiration(now));
905 } 904 }
906 } 905 }
907 906
908 } // namespace autofill 907 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/validation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698