OLD | NEW |
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 "base/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "components/autofill/content/browser/wallet/full_wallet.h" | 11 #include "components/autofill/content/browser/wallet/full_wallet.h" |
12 #include "components/autofill/content/browser/wallet/required_action.h" | 12 #include "components/autofill/content/browser/wallet/required_action.h" |
13 #include "components/autofill/content/browser/wallet/wallet_test_util.h" | 13 #include "components/autofill/content/browser/wallet/wallet_test_util.h" |
| 14 #include "components/autofill/core/browser/autofill_type.h" |
| 15 #include "components/autofill/core/browser/field_types.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
15 | 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 const char kFullWalletValidResponse[] = | 20 const char kFullWalletValidResponse[] = |
19 "{" | 21 "{" |
20 " \"expiration_month\":12," | 22 " \"expiration_month\":12," |
21 " \"expiration_year\":3000," | 23 " \"expiration_year\":3000," |
22 " \"iin\":\"iin\"," | 24 " \"iin\":\"iin\"," |
23 " \"rest\":\"rest\"," | 25 " \"rest\":\"rest\"," |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 2012, | 447 2012, |
446 "528512", | 448 "528512", |
447 "5ec4feecf9d6", | 449 "5ec4feecf9d6", |
448 GetTestAddress(), | 450 GetTestAddress(), |
449 GetTestShippingAddress(), | 451 GetTestShippingAddress(), |
450 required_actions); | 452 required_actions); |
451 std::vector<uint8> one_time_pad; | 453 std::vector<uint8> one_time_pad; |
452 EXPECT_TRUE(base::HexStringToBytes("5F04A8704183", &one_time_pad)); | 454 EXPECT_TRUE(base::HexStringToBytes("5F04A8704183", &one_time_pad)); |
453 full_wallet.set_one_time_pad(one_time_pad); | 455 full_wallet.set_one_time_pad(one_time_pad); |
454 EXPECT_EQ(ASCIIToUTF16("5285121925598459"), | 456 EXPECT_EQ(ASCIIToUTF16("5285121925598459"), |
455 full_wallet.GetInfo(CREDIT_CARD_NUMBER)); | 457 full_wallet.GetInfo(AutofillType(CREDIT_CARD_NUMBER))); |
456 EXPECT_EQ(ASCIIToUTF16("989"), | 458 EXPECT_EQ(ASCIIToUTF16("989"), |
457 full_wallet.GetInfo(CREDIT_CARD_VERIFICATION_CODE)); | 459 full_wallet.GetInfo(AutofillType(CREDIT_CARD_VERIFICATION_CODE))); |
458 } | 460 } |
459 | 461 |
460 TEST_F(FullWalletTest, RestLengthUnderDecryptionTest) { | 462 TEST_F(FullWalletTest, RestLengthUnderDecryptionTest) { |
461 std::vector<RequiredAction> required_actions; | 463 std::vector<RequiredAction> required_actions; |
462 FullWallet full_wallet(12, | 464 FullWallet full_wallet(12, |
463 2012, | 465 2012, |
464 "528512", | 466 "528512", |
465 "4c567667e6", | 467 "4c567667e6", |
466 GetTestAddress(), | 468 GetTestAddress(), |
467 GetTestShippingAddress(), | 469 GetTestShippingAddress(), |
468 required_actions); | 470 required_actions); |
469 std::vector<uint8> one_time_pad; | 471 std::vector<uint8> one_time_pad; |
470 EXPECT_TRUE(base::HexStringToBytes("063AD35324BF", &one_time_pad)); | 472 EXPECT_TRUE(base::HexStringToBytes("063AD35324BF", &one_time_pad)); |
471 full_wallet.set_one_time_pad(one_time_pad); | 473 full_wallet.set_one_time_pad(one_time_pad); |
472 EXPECT_EQ(ASCIIToUTF16("5285127106109719"), | 474 EXPECT_EQ(ASCIIToUTF16("5285127106109719"), |
473 full_wallet.GetInfo(CREDIT_CARD_NUMBER)); | 475 full_wallet.GetInfo(AutofillType(CREDIT_CARD_NUMBER))); |
474 EXPECT_EQ(ASCIIToUTF16("385"), | 476 EXPECT_EQ(ASCIIToUTF16("385"), |
475 full_wallet.GetInfo(CREDIT_CARD_VERIFICATION_CODE)); | 477 full_wallet.GetInfo(AutofillType(CREDIT_CARD_VERIFICATION_CODE))); |
476 } | 478 } |
477 | 479 |
478 TEST_F(FullWalletTest, GetCreditCardInfo) { | 480 TEST_F(FullWalletTest, GetCreditCardInfo) { |
479 std::vector<RequiredAction> required_actions; | 481 std::vector<RequiredAction> required_actions; |
480 FullWallet full_wallet(12, | 482 FullWallet full_wallet(12, |
481 2015, | 483 2015, |
482 "528512", | 484 "528512", |
483 "1a068673eb0", | 485 "1a068673eb0", |
484 GetTestAddress(), | 486 GetTestAddress(), |
485 GetTestShippingAddress(), | 487 GetTestShippingAddress(), |
486 required_actions); | 488 required_actions); |
487 | 489 |
488 EXPECT_EQ(ASCIIToUTF16("15"), | 490 EXPECT_EQ(ASCIIToUTF16("15"), |
489 full_wallet.GetInfo(CREDIT_CARD_EXP_2_DIGIT_YEAR)); | 491 full_wallet.GetInfo(AutofillType(CREDIT_CARD_EXP_2_DIGIT_YEAR))); |
490 | 492 |
491 EXPECT_EQ(ASCIIToUTF16("12/15"), | 493 EXPECT_EQ(ASCIIToUTF16("12/15"), |
492 full_wallet.GetInfo(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); | 494 full_wallet.GetInfo( |
| 495 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR))); |
493 | 496 |
494 EXPECT_EQ(ASCIIToUTF16("12/2015"), | 497 EXPECT_EQ(ASCIIToUTF16("12/2015"), |
495 full_wallet.GetInfo(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); | 498 full_wallet.GetInfo( |
| 499 AutofillType(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR))); |
496 | 500 |
497 std::vector<uint8> one_time_pad; | 501 std::vector<uint8> one_time_pad; |
498 EXPECT_TRUE(base::HexStringToBytes("075DA779F98B", &one_time_pad)); | 502 EXPECT_TRUE(base::HexStringToBytes("075DA779F98B", &one_time_pad)); |
499 full_wallet.set_one_time_pad(one_time_pad); | 503 full_wallet.set_one_time_pad(one_time_pad); |
500 EXPECT_EQ(ASCIIToUTF16("MasterCard"), | 504 EXPECT_EQ(ASCIIToUTF16("MasterCard"), |
501 full_wallet.GetInfo(CREDIT_CARD_TYPE)); | 505 full_wallet.GetInfo(AutofillType(CREDIT_CARD_TYPE))); |
502 } | 506 } |
503 | 507 |
504 } // namespace wallet | 508 } // namespace wallet |
505 } // namespace autofill | 509 } // namespace autofill |
OLD | NEW |