| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/password_manager/password_store_mac.h" | 5 #include "chrome/browser/password_manager/password_store_mac.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 form->federation_origin); | 151 form->federation_origin); |
| 152 } else { | 152 } else { |
| 153 EXPECT_EQ(WideToUTF16(expectation->password_value), | 153 EXPECT_EQ(WideToUTF16(expectation->password_value), |
| 154 form->password_value); | 154 form->password_value); |
| 155 EXPECT_TRUE(form->federation_origin.unique()); | 155 EXPECT_TRUE(form->federation_origin.unique()); |
| 156 } | 156 } |
| 157 } else { | 157 } else { |
| 158 EXPECT_TRUE(form->blacklisted_by_user); | 158 EXPECT_TRUE(form->blacklisted_by_user); |
| 159 } | 159 } |
| 160 EXPECT_EQ(expectation->preferred, form->preferred); | 160 EXPECT_EQ(expectation->preferred, form->preferred); |
| 161 EXPECT_EQ(expectation->ssl_valid, form->ssl_valid); | |
| 162 EXPECT_DOUBLE_EQ(expectation->creation_time, | 161 EXPECT_DOUBLE_EQ(expectation->creation_time, |
| 163 form->date_created.ToDoubleT()); | 162 form->date_created.ToDoubleT()); |
| 164 base::Time created = base::Time::FromDoubleT(expectation->creation_time); | 163 base::Time created = base::Time::FromDoubleT(expectation->creation_time); |
| 165 EXPECT_EQ( | 164 EXPECT_EQ( |
| 166 created + base::TimeDelta::FromDays( | 165 created + base::TimeDelta::FromDays( |
| 167 password_manager::kTestingDaysAfterPasswordsAreSynced), | 166 password_manager::kTestingDaysAfterPasswordsAreSynced), |
| 168 form->date_synced); | 167 form->date_synced); |
| 169 EXPECT_EQ(GURL(password_manager::kTestingIconUrlSpec), form->icon_url); | 168 EXPECT_EQ(GURL(password_manager::kTestingIconUrlSpec), form->icon_url); |
| 170 } | 169 } |
| 171 } | 170 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 327 |
| 329 #pragma mark - | 328 #pragma mark - |
| 330 | 329 |
| 331 TEST_F(PasswordStoreMacInternalsTest, TestKeychainToFormTranslation) { | 330 TEST_F(PasswordStoreMacInternalsTest, TestKeychainToFormTranslation) { |
| 332 typedef struct { | 331 typedef struct { |
| 333 const PasswordForm::Scheme scheme; | 332 const PasswordForm::Scheme scheme; |
| 334 const char* signon_realm; | 333 const char* signon_realm; |
| 335 const char* origin; | 334 const char* origin; |
| 336 const wchar_t* username; // Set to NULL to check for a blacklist entry. | 335 const wchar_t* username; // Set to NULL to check for a blacklist entry. |
| 337 const wchar_t* password; | 336 const wchar_t* password; |
| 338 const bool ssl_valid; | |
| 339 const int creation_year; | 337 const int creation_year; |
| 340 const int creation_month; | 338 const int creation_month; |
| 341 const int creation_day; | 339 const int creation_day; |
| 342 const int creation_hour; | 340 const int creation_hour; |
| 343 const int creation_minute; | 341 const int creation_minute; |
| 344 const int creation_second; | 342 const int creation_second; |
| 345 } TestExpectations; | 343 } TestExpectations; |
| 346 | 344 |
| 347 TestExpectations expected[] = { | 345 TestExpectations expected[] = { |
| 348 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 346 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 349 "http://some.domain.com/", L"joe_user", L"sekrit", false, 2002, 6, 1, 17, | 347 "http://some.domain.com/", L"joe_user", L"sekrit", 2002, 6, 1, 17, 15, |
| 350 15, 0}, | 348 0}, |
| 351 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 349 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 352 "http://some.domain.com/insecure.html", L"joe_user", L"sekrit", false, | 350 "http://some.domain.com/insecure.html", L"joe_user", L"sekrit", 1999, 12, |
| 353 1999, 12, 31, 23, 59, 59}, | 351 31, 23, 59, 59}, |
| 354 {PasswordForm::SCHEME_HTML, "https://some.domain.com/", | 352 {PasswordForm::SCHEME_HTML, "https://some.domain.com/", |
| 355 "https://some.domain.com/secure.html", L"secure_user", L"password", true, | 353 "https://some.domain.com/secure.html", L"secure_user", L"password", 2010, |
| 356 2010, 9, 8, 7, 6, 5}, | 354 9, 8, 7, 6, 5}, |
| 357 {PasswordForm::SCHEME_HTML, "http://dont.remember.com/", | 355 {PasswordForm::SCHEME_HTML, "http://dont.remember.com/", |
| 358 "http://dont.remember.com/", NULL, NULL, false, 2000, 1, 1, 0, 0, 0}, | 356 "http://dont.remember.com/", NULL, NULL, 2000, 1, 1, 0, 0, 0}, |
| 359 {PasswordForm::SCHEME_HTML, "http://dont.remember.com/", | 357 {PasswordForm::SCHEME_HTML, "http://dont.remember.com/", |
| 360 "http://dont.remember.com/", NULL, NULL, false, 2000, 1, 1, 0, 0, 0}, | 358 "http://dont.remember.com/", NULL, NULL, 2000, 1, 1, 0, 0, 0}, |
| 361 {PasswordForm::SCHEME_HTML, "https://dont.remember.com/", | 359 {PasswordForm::SCHEME_HTML, "https://dont.remember.com/", |
| 362 "https://dont.remember.com/", NULL, NULL, true, 2000, 1, 1, 0, 0, 0}, | 360 "https://dont.remember.com/", NULL, NULL, 2000, 1, 1, 0, 0, 0}, |
| 363 {PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security", | 361 {PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security", |
| 364 "http://some.domain.com:4567/insecure.html", L"basic_auth_user", | 362 "http://some.domain.com:4567/insecure.html", L"basic_auth_user", |
| 365 L"basic", false, 1998, 03, 30, 10, 00, 00}, | 363 L"basic", 1998, 03, 30, 10, 00, 00}, |
| 366 {PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", | 364 {PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", |
| 367 "https://some.domain.com/", L"digest_auth_user", L"digest", true, 1998, | 365 "https://some.domain.com/", L"digest_auth_user", L"digest", 1998, 3, 30, |
| 368 3, 30, 10, 0, 0}, | 366 10, 0, 0}, |
| 369 // This one gives us an invalid date, which we will treat as a "NULL" date | 367 // This one gives us an invalid date, which we will treat as a "NULL" date |
| 370 // which is 1601. | 368 // which is 1601. |
| 371 {PasswordForm::SCHEME_OTHER, "http://a.server.com/", | 369 {PasswordForm::SCHEME_OTHER, "http://a.server.com/", |
| 372 "http://a.server.com/", L"abc", L"123", false, 1601, 1, 1, 0, 0, 0}, | 370 "http://a.server.com/", L"abc", L"123", 1601, 1, 1, 0, 0, 0}, |
| 373 {PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/", "", | 371 {PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/", "", |
| 374 L"joe_user", L"secret", true, 2015, 5, 15, 14, 13, 12}, | 372 L"joe_user", L"secret", 2015, 5, 15, 14, 13, 12}, |
| 375 }; | 373 }; |
| 376 | 374 |
| 377 for (unsigned int i = 0; i < arraysize(expected); ++i) { | 375 for (unsigned int i = 0; i < arraysize(expected); ++i) { |
| 378 SCOPED_TRACE(testing::Message("In iteration ") << i); | 376 SCOPED_TRACE(testing::Message("In iteration ") << i); |
| 379 // Create our fake KeychainItemRef; see MockAppleKeychain docs. | 377 // Create our fake KeychainItemRef; see MockAppleKeychain docs. |
| 380 SecKeychainItemRef keychain_item = | 378 SecKeychainItemRef keychain_item = |
| 381 reinterpret_cast<SecKeychainItemRef>(i + 1); | 379 reinterpret_cast<SecKeychainItemRef>(i + 1); |
| 382 PasswordForm form; | 380 PasswordForm form; |
| 383 bool parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem( | 381 bool parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem( |
| 384 *keychain_, keychain_item, &form, true); | 382 *keychain_, keychain_item, &form, true); |
| 385 | 383 |
| 386 EXPECT_TRUE(parsed); | 384 EXPECT_TRUE(parsed); |
| 387 | 385 |
| 388 EXPECT_EQ(expected[i].scheme, form.scheme); | 386 EXPECT_EQ(expected[i].scheme, form.scheme); |
| 389 EXPECT_EQ(GURL(expected[i].origin), form.origin); | 387 EXPECT_EQ(GURL(expected[i].origin), form.origin); |
| 390 EXPECT_EQ(expected[i].ssl_valid, form.ssl_valid); | |
| 391 EXPECT_EQ(std::string(expected[i].signon_realm), form.signon_realm); | 388 EXPECT_EQ(std::string(expected[i].signon_realm), form.signon_realm); |
| 392 if (expected[i].username) { | 389 if (expected[i].username) { |
| 393 EXPECT_EQ(WideToUTF16(expected[i].username), form.username_value); | 390 EXPECT_EQ(WideToUTF16(expected[i].username), form.username_value); |
| 394 EXPECT_EQ(WideToUTF16(expected[i].password), form.password_value); | 391 EXPECT_EQ(WideToUTF16(expected[i].password), form.password_value); |
| 395 EXPECT_FALSE(form.blacklisted_by_user); | 392 EXPECT_FALSE(form.blacklisted_by_user); |
| 396 } else { | 393 } else { |
| 397 EXPECT_TRUE(form.blacklisted_by_user); | 394 EXPECT_TRUE(form.blacklisted_by_user); |
| 398 } | 395 } |
| 399 base::Time::Exploded exploded_time; | 396 base::Time::Exploded exploded_time; |
| 400 form.date_created.UTCExplode(&exploded_time); | 397 form.date_created.UTCExplode(&exploded_time); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 419 TEST_F(PasswordStoreMacInternalsTest, TestKeychainSearch) { | 416 TEST_F(PasswordStoreMacInternalsTest, TestKeychainSearch) { |
| 420 struct TestDataAndExpectation { | 417 struct TestDataAndExpectation { |
| 421 const PasswordFormData data; | 418 const PasswordFormData data; |
| 422 const size_t expected_fill_matches; | 419 const size_t expected_fill_matches; |
| 423 const size_t expected_merge_matches; | 420 const size_t expected_merge_matches; |
| 424 }; | 421 }; |
| 425 // Most fields are left blank because we don't care about them for searching. | 422 // Most fields are left blank because we don't care about them for searching. |
| 426 TestDataAndExpectation test_data[] = { | 423 TestDataAndExpectation test_data[] = { |
| 427 // An HTML form we've seen. | 424 // An HTML form we've seen. |
| 428 {{PasswordForm::SCHEME_HTML, "http://some.domain.com/", NULL, NULL, NULL, | 425 {{PasswordForm::SCHEME_HTML, "http://some.domain.com/", NULL, NULL, NULL, |
| 429 NULL, NULL, L"joe_user", NULL, false, false, 0}, | 426 NULL, NULL, L"joe_user", NULL, false, 0}, |
| 430 2, | 427 2, |
| 431 2}, | 428 2}, |
| 432 {{PasswordForm::SCHEME_HTML, "http://some.domain.com/", NULL, NULL, NULL, | 429 {{PasswordForm::SCHEME_HTML, "http://some.domain.com/", NULL, NULL, NULL, |
| 433 NULL, NULL, L"wrong_user", NULL, false, false, 0}, | 430 NULL, NULL, L"wrong_user", NULL, false, 0}, |
| 434 2, | 431 2, |
| 435 0}, | 432 0}, |
| 436 // An HTML form we haven't seen | 433 // An HTML form we haven't seen |
| 437 {{PasswordForm::SCHEME_HTML, "http://www.unseendomain.com/", NULL, NULL, | 434 {{PasswordForm::SCHEME_HTML, "http://www.unseendomain.com/", NULL, NULL, |
| 438 NULL, NULL, NULL, L"joe_user", NULL, false, false, 0}, | 435 NULL, NULL, NULL, L"joe_user", NULL, false, 0}, |
| 439 0, | 436 0, |
| 440 0}, | 437 0}, |
| 441 // Basic auth that should match. | 438 // Basic auth that should match. |
| 442 {{PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security", | 439 {{PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security", |
| 443 NULL, NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, false, false, | 440 NULL, NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, false, 0}, |
| 444 0}, | |
| 445 1, | 441 1, |
| 446 1}, | 442 1}, |
| 447 // Basic auth with the wrong port. | 443 // Basic auth with the wrong port. |
| 448 {{PasswordForm::SCHEME_BASIC, "http://some.domain.com:1111/low_security", | 444 {{PasswordForm::SCHEME_BASIC, "http://some.domain.com:1111/low_security", |
| 449 NULL, NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, false, false, | 445 NULL, NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, false, 0}, |
| 450 0}, | |
| 451 0, | 446 0, |
| 452 0}, | 447 0}, |
| 453 // Digest auth we've saved under https, visited with http. | 448 // Digest auth we've saved under https, visited with http. |
| 454 {{PasswordForm::SCHEME_DIGEST, "http://some.domain.com/high_security", | 449 {{PasswordForm::SCHEME_DIGEST, "http://some.domain.com/high_security", |
| 455 NULL, NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, false, false, | 450 NULL, NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, false, 0}, |
| 456 0}, | |
| 457 0, | 451 0, |
| 458 0}, | 452 0}, |
| 459 // Digest auth that should match. | 453 // Digest auth that should match. |
| 460 {{PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", | 454 {{PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", |
| 461 NULL, NULL, NULL, NULL, NULL, L"wrong_user", NULL, false, true, 0}, | 455 NULL, NULL, NULL, NULL, NULL, L"wrong_user", NULL, false, 0}, |
| 462 1, | 456 1, |
| 463 0}, | 457 0}, |
| 464 // Digest auth with the wrong domain. | 458 // Digest auth with the wrong domain. |
| 465 {{PasswordForm::SCHEME_DIGEST, "https://some.domain.com/other_domain", | 459 {{PasswordForm::SCHEME_DIGEST, "https://some.domain.com/other_domain", |
| 466 NULL, NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, false, true, | 460 NULL, NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, false, 0}, |
| 467 0}, | |
| 468 0, | 461 0, |
| 469 0}, | 462 0}, |
| 470 // Android credentials (both legacy ones with origin, and without). | 463 // Android credentials (both legacy ones with origin, and without). |
| 471 {{PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/", | 464 {{PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/", |
| 472 "android://hash@com.domain.some/", NULL, NULL, NULL, NULL, L"joe_user", | 465 "android://hash@com.domain.some/", NULL, NULL, NULL, NULL, L"joe_user", |
| 473 NULL, false, true, 0}, | 466 NULL, false, 0}, |
| 474 1, | 467 1, |
| 475 1}, | 468 1}, |
| 476 {{PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/", NULL, | 469 {{PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/", NULL, |
| 477 NULL, NULL, NULL, NULL, L"joe_user", NULL, false, true, 0}, | 470 NULL, NULL, NULL, NULL, L"joe_user", NULL, false, 0}, |
| 478 1, | 471 1, |
| 479 1}, | 472 1}, |
| 480 // Federated logins do not have a corresponding Keychain entry, and should | 473 // Federated logins do not have a corresponding Keychain entry, and should |
| 481 // not match the username/password stored for the same application. Note | 474 // not match the username/password stored for the same application. Note |
| 482 // that it will match for filling, however, because that part does not | 475 // that it will match for filling, however, because that part does not |
| 483 // know | 476 // know |
| 484 // that it is a federated login. | 477 // that it is a federated login. |
| 485 {{PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/", NULL, | 478 {{PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/", NULL, |
| 486 NULL, NULL, NULL, NULL, L"joe_user", | 479 NULL, NULL, NULL, NULL, L"joe_user", |
| 487 password_manager::kTestingFederatedLoginMarker, false, true, 0}, | 480 password_manager::kTestingFederatedLoginMarker, false, 0}, |
| 488 1, | 481 1, |
| 489 0}, | 482 0}, |
| 490 /// Garbage forms should have no matches. | 483 /// Garbage forms should have no matches. |
| 491 {{PasswordForm::SCHEME_HTML, "foo/bar/baz", NULL, NULL, NULL, NULL, NULL, | 484 {{PasswordForm::SCHEME_HTML, "foo/bar/baz", NULL, NULL, NULL, NULL, NULL, |
| 492 NULL, NULL, false, false, 0}, | 485 NULL, NULL, false, 0}, |
| 493 0, | 486 0, |
| 494 0}, | 487 0}, |
| 495 }; | 488 }; |
| 496 | 489 |
| 497 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); | 490 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); |
| 498 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); | 491 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); |
| 499 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 492 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 500 for (unsigned int i = 0; i < arraysize(test_data); ++i) { | 493 for (unsigned int i = 0; i < arraysize(test_data); ++i) { |
| 501 std::unique_ptr<PasswordForm> query_form = | 494 std::unique_ptr<PasswordForm> query_form = |
| 502 CreatePasswordFormFromDataForTesting(test_data[i].data); | 495 CreatePasswordFormFromDataForTesting(test_data[i].data); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 GURL signon_gurl = GURL(form->signon_realm); | 552 GURL signon_gurl = GURL(form->signon_realm); |
| 560 form->signon_realm = signon_gurl.ReplaceComponents(replacement).spec(); | 553 form->signon_realm = signon_gurl.ReplaceComponents(replacement).spec(); |
| 561 } | 554 } |
| 562 | 555 |
| 563 TEST_F(PasswordStoreMacInternalsTest, TestKeychainExactSearch) { | 556 TEST_F(PasswordStoreMacInternalsTest, TestKeychainExactSearch) { |
| 564 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); | 557 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); |
| 565 | 558 |
| 566 PasswordFormData base_form_data[] = { | 559 PasswordFormData base_form_data[] = { |
| 567 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 560 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 568 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, | 561 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, |
| 569 L"joe_user", NULL, true, false, 0}, | 562 L"joe_user", NULL, true, 0}, |
| 570 {PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security", | 563 {PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security", |
| 571 "http://some.domain.com:4567/insecure.html", NULL, NULL, NULL, NULL, | 564 "http://some.domain.com:4567/insecure.html", NULL, NULL, NULL, NULL, |
| 572 L"basic_auth_user", NULL, true, false, 0}, | 565 L"basic_auth_user", NULL, true, 0}, |
| 573 {PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", | 566 {PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", |
| 574 "https://some.domain.com", NULL, NULL, NULL, NULL, L"digest_auth_user", | 567 "https://some.domain.com", NULL, NULL, NULL, NULL, L"digest_auth_user", |
| 575 NULL, true, true, 0}, | 568 NULL, true, 0}, |
| 576 }; | 569 }; |
| 577 | 570 |
| 578 for (unsigned int i = 0; i < arraysize(base_form_data); ++i) { | 571 for (unsigned int i = 0; i < arraysize(base_form_data); ++i) { |
| 579 // Create a base form and make sure we find a match. | 572 // Create a base form and make sure we find a match. |
| 580 std::unique_ptr<PasswordForm> base_form = | 573 std::unique_ptr<PasswordForm> base_form = |
| 581 CreatePasswordFormFromDataForTesting(base_form_data[i]); | 574 CreatePasswordFormFromDataForTesting(base_form_data[i]); |
| 582 EXPECT_TRUE(keychain_adapter.HasPasswordsMergeableWithForm(*base_form)); | 575 EXPECT_TRUE(keychain_adapter.HasPasswordsMergeableWithForm(*base_form)); |
| 583 EXPECT_TRUE(keychain_adapter.HasPasswordExactlyMatchingForm(*base_form)); | 576 EXPECT_TRUE(keychain_adapter.HasPasswordExactlyMatchingForm(*base_form)); |
| 584 | 577 |
| 585 // Make sure that the matching isn't looser than it should be by checking | 578 // Make sure that the matching isn't looser than it should be by checking |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 611 |
| 619 TEST_F(PasswordStoreMacInternalsTest, TestKeychainAdd) { | 612 TEST_F(PasswordStoreMacInternalsTest, TestKeychainAdd) { |
| 620 struct TestDataAndExpectation { | 613 struct TestDataAndExpectation { |
| 621 PasswordFormData data; | 614 PasswordFormData data; |
| 622 bool should_succeed; | 615 bool should_succeed; |
| 623 }; | 616 }; |
| 624 TestDataAndExpectation test_data[] = { | 617 TestDataAndExpectation test_data[] = { |
| 625 // Test a variety of scheme/port/protocol/path variations. | 618 // Test a variety of scheme/port/protocol/path variations. |
| 626 {{PasswordForm::SCHEME_HTML, "http://web.site.com/", | 619 {{PasswordForm::SCHEME_HTML, "http://web.site.com/", |
| 627 "http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL, | 620 "http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL, |
| 628 L"anonymous", L"knock-knock", false, false, 0}, | 621 L"anonymous", L"knock-knock", false, 0}, |
| 629 true}, | 622 true}, |
| 630 {{PasswordForm::SCHEME_HTML, "https://web.site.com/", | 623 {{PasswordForm::SCHEME_HTML, "https://web.site.com/", |
| 631 "https://web.site.com/", NULL, NULL, NULL, NULL, L"admin", L"p4ssw0rd", | 624 "https://web.site.com/", NULL, NULL, NULL, NULL, L"admin", L"p4ssw0rd", |
| 632 false, false, 0}, | 625 false, 0}, |
| 633 true}, | 626 true}, |
| 634 {{PasswordForm::SCHEME_BASIC, "http://a.site.com:2222/therealm", | 627 {{PasswordForm::SCHEME_BASIC, "http://a.site.com:2222/therealm", |
| 635 "http://a.site.com:2222/", NULL, NULL, NULL, NULL, L"username", | 628 "http://a.site.com:2222/", NULL, NULL, NULL, NULL, L"username", |
| 636 L"password", false, false, 0}, | 629 L"password", false, 0}, |
| 637 true}, | 630 true}, |
| 638 {{PasswordForm::SCHEME_DIGEST, "https://digest.site.com/differentrealm", | 631 {{PasswordForm::SCHEME_DIGEST, "https://digest.site.com/differentrealm", |
| 639 "https://digest.site.com/secure.html", NULL, NULL, NULL, NULL, | 632 "https://digest.site.com/secure.html", NULL, NULL, NULL, NULL, |
| 640 L"testname", L"testpass", false, false, 0}, | 633 L"testname", L"testpass", false, 0}, |
| 641 true}, | 634 true}, |
| 642 // Test that Android credentials can be stored. Also check the legacy form | 635 // Test that Android credentials can be stored. Also check the legacy form |
| 643 // when |origin| was still filled with the Android URI (and not left | 636 // when |origin| was still filled with the Android URI (and not left |
| 644 // empty). | 637 // empty). |
| 645 {{PasswordForm::SCHEME_HTML, "android://hash@com.example.alpha/", "", | 638 {{PasswordForm::SCHEME_HTML, "android://hash@com.example.alpha/", "", |
| 646 NULL, NULL, NULL, NULL, L"joe_user", L"password", false, true, 0}, | 639 NULL, NULL, NULL, NULL, L"joe_user", L"password", false, 0}, |
| 647 true}, | 640 true}, |
| 648 {{PasswordForm::SCHEME_HTML, "android://hash@com.example.beta/", | 641 {{PasswordForm::SCHEME_HTML, "android://hash@com.example.beta/", |
| 649 "android://hash@com.example.beta/", NULL, NULL, NULL, NULL, | 642 "android://hash@com.example.beta/", NULL, NULL, NULL, NULL, |
| 650 L"jane_user", L"password2", false, true, 0}, | 643 L"jane_user", L"password2", false, 0}, |
| 651 true}, | 644 true}, |
| 652 // Make sure that garbage forms are rejected. | 645 // Make sure that garbage forms are rejected. |
| 653 {{PasswordForm::SCHEME_HTML, "gobbledygook", "gobbledygook", NULL, NULL, | 646 {{PasswordForm::SCHEME_HTML, "gobbledygook", "gobbledygook", NULL, NULL, |
| 654 NULL, NULL, L"anonymous", L"knock-knock", false, false, 0}, | 647 NULL, NULL, L"anonymous", L"knock-knock", false, 0}, |
| 655 false}, | 648 false}, |
| 656 // Test that failing to update a duplicate (forced using the magic failure | 649 // Test that failing to update a duplicate (forced using the magic failure |
| 657 // password; see MockAppleKeychain::ItemModifyAttributesAndData) is | 650 // password; see MockAppleKeychain::ItemModifyAttributesAndData) is |
| 658 // reported. | 651 // reported. |
| 659 {{PasswordForm::SCHEME_HTML, "http://some.domain.com", | 652 {{PasswordForm::SCHEME_HTML, "http://some.domain.com", |
| 660 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, | 653 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, |
| 661 L"joe_user", L"fail_me", false, false, 0}, | 654 L"joe_user", L"fail_me", false, 0}, |
| 662 false}, | 655 false}, |
| 663 }; | 656 }; |
| 664 | 657 |
| 665 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); | 658 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); |
| 666 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 659 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 667 | 660 |
| 668 for (unsigned int i = 0; i < arraysize(test_data); ++i) { | 661 for (unsigned int i = 0; i < arraysize(test_data); ++i) { |
| 669 std::unique_ptr<PasswordForm> in_form = | 662 std::unique_ptr<PasswordForm> in_form = |
| 670 CreatePasswordFormFromDataForTesting(test_data[i].data); | 663 CreatePasswordFormFromDataForTesting(test_data[i].data); |
| 671 bool add_succeeded = owned_keychain_adapter.AddPassword(*in_form); | 664 bool add_succeeded = owned_keychain_adapter.AddPassword(*in_form); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 685 PasswordFormData data = {PasswordForm::SCHEME_HTML, | 678 PasswordFormData data = {PasswordForm::SCHEME_HTML, |
| 686 "http://some.domain.com", | 679 "http://some.domain.com", |
| 687 "http://some.domain.com/insecure.html", | 680 "http://some.domain.com/insecure.html", |
| 688 NULL, | 681 NULL, |
| 689 NULL, | 682 NULL, |
| 690 NULL, | 683 NULL, |
| 691 NULL, | 684 NULL, |
| 692 L"joe_user", | 685 L"joe_user", |
| 693 L"updated_password", | 686 L"updated_password", |
| 694 false, | 687 false, |
| 695 false, | |
| 696 0}; | 688 0}; |
| 697 std::unique_ptr<PasswordForm> update_form = | 689 std::unique_ptr<PasswordForm> update_form = |
| 698 CreatePasswordFormFromDataForTesting(data); | 690 CreatePasswordFormFromDataForTesting(data); |
| 699 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); | 691 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); |
| 700 EXPECT_TRUE(keychain_adapter.AddPassword(*update_form)); | 692 EXPECT_TRUE(keychain_adapter.AddPassword(*update_form)); |
| 701 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(2); | 693 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(2); |
| 702 PasswordForm stored_form; | 694 PasswordForm stored_form; |
| 703 internal_keychain_helpers::FillPasswordFormFromKeychainItem( | 695 internal_keychain_helpers::FillPasswordFormFromKeychainItem( |
| 704 *keychain_, keychain_item, &stored_form, true); | 696 *keychain_, keychain_item, &stored_form, true); |
| 705 EXPECT_EQ(update_form->password_value, stored_form.password_value); | 697 EXPECT_EQ(update_form->password_value, stored_form.password_value); |
| 706 } | 698 } |
| 707 } | 699 } |
| 708 | 700 |
| 709 TEST_F(PasswordStoreMacInternalsTest, TestKeychainRemove) { | 701 TEST_F(PasswordStoreMacInternalsTest, TestKeychainRemove) { |
| 710 struct TestDataAndExpectation { | 702 struct TestDataAndExpectation { |
| 711 PasswordFormData data; | 703 PasswordFormData data; |
| 712 bool should_succeed; | 704 bool should_succeed; |
| 713 }; | 705 }; |
| 714 TestDataAndExpectation test_data[] = { | 706 TestDataAndExpectation test_data[] = { |
| 715 // Test deletion of an item that we add. | 707 // Test deletion of an item that we add. |
| 716 {{PasswordForm::SCHEME_HTML, "http://web.site.com/", | 708 {{PasswordForm::SCHEME_HTML, "http://web.site.com/", |
| 717 "http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL, | 709 "http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL, |
| 718 L"anonymous", L"knock-knock", false, false, 0}, | 710 L"anonymous", L"knock-knock", false, 0}, |
| 719 true}, | 711 true}, |
| 720 // Test that Android credentials can be removed. Also check the legacy | 712 // Test that Android credentials can be removed. Also check the legacy |
| 721 // case | 713 // case when |origin| was still filled with the Android URI (and not left |
| 722 // when |origin| was still filled with the Android URI (and not left | |
| 723 // empty). | 714 // empty). |
| 724 {{PasswordForm::SCHEME_HTML, "android://hash@com.example.alpha/", "", | 715 {{PasswordForm::SCHEME_HTML, "android://hash@com.example.alpha/", "", |
| 725 NULL, NULL, NULL, NULL, L"joe_user", L"secret", false, true, 0}, | 716 NULL, NULL, NULL, NULL, L"joe_user", L"secret", false, 0}, |
| 726 true}, | 717 true}, |
| 727 {{PasswordForm::SCHEME_HTML, "android://hash@com.example.beta/", | 718 {{PasswordForm::SCHEME_HTML, "android://hash@com.example.beta/", |
| 728 "android://hash@com.example.beta/", NULL, NULL, NULL, NULL, | 719 "android://hash@com.example.beta/", NULL, NULL, NULL, NULL, |
| 729 L"jane_user", L"secret", false, true, 0}, | 720 L"jane_user", L"secret", false, 0}, |
| 730 true}, | 721 true}, |
| 731 // Make sure we don't delete items we don't own. | 722 // Make sure we don't delete items we don't own. |
| 732 {{PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 723 {{PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 733 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, | 724 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, |
| 734 L"joe_user", NULL, true, false, 0}, | 725 L"joe_user", NULL, true, 0}, |
| 735 false}, | 726 false}, |
| 736 }; | 727 }; |
| 737 | 728 |
| 738 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); | 729 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); |
| 739 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 730 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 740 | 731 |
| 741 // Add our test items (except the last one) so that we can delete them. | 732 // Add our test items (except the last one) so that we can delete them. |
| 742 for (unsigned int i = 0; i + 1 < arraysize(test_data); ++i) { | 733 for (unsigned int i = 0; i + 1 < arraysize(test_data); ++i) { |
| 743 std::unique_ptr<PasswordForm> add_form = | 734 std::unique_ptr<PasswordForm> add_form = |
| 744 CreatePasswordFormFromDataForTesting(test_data[i].data); | 735 CreatePasswordFormFromDataForTesting(test_data[i].data); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 764 base_form.username_value = ASCIIToUTF16("joe_user"); | 755 base_form.username_value = ASCIIToUTF16("joe_user"); |
| 765 | 756 |
| 766 { | 757 { |
| 767 // Check that everything unimportant can be changed. | 758 // Check that everything unimportant can be changed. |
| 768 PasswordForm different_form(base_form); | 759 PasswordForm different_form(base_form); |
| 769 different_form.username_element = ASCIIToUTF16("username"); | 760 different_form.username_element = ASCIIToUTF16("username"); |
| 770 different_form.submit_element = ASCIIToUTF16("submit"); | 761 different_form.submit_element = ASCIIToUTF16("submit"); |
| 771 different_form.username_element = ASCIIToUTF16("password"); | 762 different_form.username_element = ASCIIToUTF16("password"); |
| 772 different_form.password_value = ASCIIToUTF16("sekrit"); | 763 different_form.password_value = ASCIIToUTF16("sekrit"); |
| 773 different_form.action = GURL("http://some.domain.com/action.cgi"); | 764 different_form.action = GURL("http://some.domain.com/action.cgi"); |
| 774 different_form.ssl_valid = true; | |
| 775 different_form.preferred = true; | 765 different_form.preferred = true; |
| 776 different_form.date_created = base::Time::Now(); | 766 different_form.date_created = base::Time::Now(); |
| 777 EXPECT_TRUE( | 767 EXPECT_TRUE( |
| 778 FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH)); | 768 FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH)); |
| 779 | 769 |
| 780 // Check that path differences don't prevent a match. | 770 // Check that path differences don't prevent a match. |
| 781 base_form.origin = GURL("http://some.domain.com/other_page.html"); | 771 base_form.origin = GURL("http://some.domain.com/other_page.html"); |
| 782 EXPECT_TRUE( | 772 EXPECT_TRUE( |
| 783 FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH)); | 773 FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH)); |
| 784 } | 774 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 PasswordFormData keychain_user_1 = {PasswordForm::SCHEME_HTML, | 824 PasswordFormData keychain_user_1 = {PasswordForm::SCHEME_HTML, |
| 835 "http://some.domain.com/", | 825 "http://some.domain.com/", |
| 836 "http://some.domain.com/", | 826 "http://some.domain.com/", |
| 837 "", | 827 "", |
| 838 L"", | 828 L"", |
| 839 L"", | 829 L"", |
| 840 L"", | 830 L"", |
| 841 L"joe_user", | 831 L"joe_user", |
| 842 L"sekrit", | 832 L"sekrit", |
| 843 false, | 833 false, |
| 844 false, | |
| 845 1010101010}; | 834 1010101010}; |
| 846 PasswordFormData keychain_user_1_with_path = { | 835 PasswordFormData keychain_user_1_with_path = { |
| 847 PasswordForm::SCHEME_HTML, | 836 PasswordForm::SCHEME_HTML, |
| 848 "http://some.domain.com/", | 837 "http://some.domain.com/", |
| 849 "http://some.domain.com/page.html", | 838 "http://some.domain.com/page.html", |
| 850 "", | 839 "", |
| 851 L"", | 840 L"", |
| 852 L"", | 841 L"", |
| 853 L"", | 842 L"", |
| 854 L"joe_user", | 843 L"joe_user", |
| 855 L"otherpassword", | 844 L"otherpassword", |
| 856 false, | 845 false, |
| 857 false, | |
| 858 1010101010}; | 846 1010101010}; |
| 859 PasswordFormData keychain_user_2 = {PasswordForm::SCHEME_HTML, | 847 PasswordFormData keychain_user_2 = {PasswordForm::SCHEME_HTML, |
| 860 "http://some.domain.com/", | 848 "http://some.domain.com/", |
| 861 "http://some.domain.com/", | 849 "http://some.domain.com/", |
| 862 "", | 850 "", |
| 863 L"", | 851 L"", |
| 864 L"", | 852 L"", |
| 865 L"", | 853 L"", |
| 866 L"john.doe", | 854 L"john.doe", |
| 867 L"sesame", | 855 L"sesame", |
| 868 false, | 856 false, |
| 869 false, | |
| 870 958739876}; | 857 958739876}; |
| 871 PasswordFormData keychain_blacklist = {PasswordForm::SCHEME_HTML, | 858 PasswordFormData keychain_blacklist = {PasswordForm::SCHEME_HTML, |
| 872 "http://some.domain.com/", | 859 "http://some.domain.com/", |
| 873 "http://some.domain.com/", | 860 "http://some.domain.com/", |
| 874 "", | 861 "", |
| 875 L"", | 862 L"", |
| 876 L"", | 863 L"", |
| 877 L"", | 864 L"", |
| 878 NULL, | 865 NULL, |
| 879 NULL, | 866 NULL, |
| 880 false, | 867 false, |
| 881 false, | |
| 882 1010101010}; | 868 1010101010}; |
| 883 PasswordFormData keychain_android = {PasswordForm::SCHEME_HTML, | 869 PasswordFormData keychain_android = {PasswordForm::SCHEME_HTML, |
| 884 "android://hash@com.domain.some/", | 870 "android://hash@com.domain.some/", |
| 885 "", | 871 "", |
| 886 "", | 872 "", |
| 887 L"", | 873 L"", |
| 888 L"", | 874 L"", |
| 889 L"", | 875 L"", |
| 890 L"joe_user", | 876 L"joe_user", |
| 891 L"secret", | 877 L"secret", |
| 892 false, | 878 false, |
| 893 true, | |
| 894 1234567890}; | 879 1234567890}; |
| 895 | 880 |
| 896 PasswordFormData db_user_1 = {PasswordForm::SCHEME_HTML, | 881 PasswordFormData db_user_1 = {PasswordForm::SCHEME_HTML, |
| 897 "http://some.domain.com/", | 882 "http://some.domain.com/", |
| 898 "http://some.domain.com/", | 883 "http://some.domain.com/", |
| 899 "http://some.domain.com/action.cgi", | 884 "http://some.domain.com/action.cgi", |
| 900 L"submit", | 885 L"submit", |
| 901 L"username", | 886 L"username", |
| 902 L"password", | 887 L"password", |
| 903 L"joe_user", | 888 L"joe_user", |
| 904 L"", | 889 L"", |
| 905 true, | 890 true, |
| 906 false, | |
| 907 1212121212}; | 891 1212121212}; |
| 908 PasswordFormData db_user_1_with_path = { | 892 PasswordFormData db_user_1_with_path = { |
| 909 PasswordForm::SCHEME_HTML, | 893 PasswordForm::SCHEME_HTML, |
| 910 "http://some.domain.com/", | 894 "http://some.domain.com/", |
| 911 "http://some.domain.com/page.html", | 895 "http://some.domain.com/page.html", |
| 912 "http://some.domain.com/handlepage.cgi", | 896 "http://some.domain.com/handlepage.cgi", |
| 913 L"submit", | 897 L"submit", |
| 914 L"username", | 898 L"username", |
| 915 L"password", | 899 L"password", |
| 916 L"joe_user", | 900 L"joe_user", |
| 917 L"", | 901 L"", |
| 918 true, | 902 true, |
| 919 false, | |
| 920 1234567890}; | 903 1234567890}; |
| 921 PasswordFormData db_user_3_with_path = { | 904 PasswordFormData db_user_3_with_path = { |
| 922 PasswordForm::SCHEME_HTML, | 905 PasswordForm::SCHEME_HTML, |
| 923 "http://some.domain.com/", | 906 "http://some.domain.com/", |
| 924 "http://some.domain.com/page.html", | 907 "http://some.domain.com/page.html", |
| 925 "http://some.domain.com/handlepage.cgi", | 908 "http://some.domain.com/handlepage.cgi", |
| 926 L"submit", | 909 L"submit", |
| 927 L"username", | 910 L"username", |
| 928 L"password", | 911 L"password", |
| 929 L"second-account", | 912 L"second-account", |
| 930 L"", | 913 L"", |
| 931 true, | 914 true, |
| 932 false, | |
| 933 1240000000}; | 915 1240000000}; |
| 934 PasswordFormData database_blacklist_with_path = { | 916 PasswordFormData database_blacklist_with_path = { |
| 935 PasswordForm::SCHEME_HTML, | 917 PasswordForm::SCHEME_HTML, |
| 936 "http://some.domain.com/", | 918 "http://some.domain.com/", |
| 937 "http://some.domain.com/path.html", | 919 "http://some.domain.com/path.html", |
| 938 "http://some.domain.com/action.cgi", | 920 "http://some.domain.com/action.cgi", |
| 939 L"submit", | 921 L"submit", |
| 940 L"username", | 922 L"username", |
| 941 L"password", | 923 L"password", |
| 942 NULL, | 924 NULL, |
| 943 NULL, | 925 NULL, |
| 944 true, | 926 true, |
| 945 false, | |
| 946 1212121212}; | 927 1212121212}; |
| 947 PasswordFormData db_android = {PasswordForm::SCHEME_HTML, | 928 PasswordFormData db_android = {PasswordForm::SCHEME_HTML, |
| 948 "android://hash@com.domain.some/", | 929 "android://hash@com.domain.some/", |
| 949 "android://hash@com.domain.some/", | 930 "android://hash@com.domain.some/", |
| 950 "", | 931 "", |
| 951 L"", | 932 L"", |
| 952 L"", | 933 L"", |
| 953 L"", | 934 L"", |
| 954 L"joe_user", | 935 L"joe_user", |
| 955 L"", | 936 L"", |
| 956 false, | 937 false, |
| 957 true, | |
| 958 1234567890}; | 938 1234567890}; |
| 959 PasswordFormData db_federated = { | 939 PasswordFormData db_federated = { |
| 960 PasswordForm::SCHEME_HTML, | 940 PasswordForm::SCHEME_HTML, |
| 961 "android://hash@com.domain.some/", | 941 "android://hash@com.domain.some/", |
| 962 "android://hash@com.domain.some/", | 942 "android://hash@com.domain.some/", |
| 963 "", | 943 "", |
| 964 L"", | 944 L"", |
| 965 L"", | 945 L"", |
| 966 L"", | 946 L"", |
| 967 L"joe_user", | 947 L"joe_user", |
| 968 password_manager::kTestingFederatedLoginMarker, | 948 password_manager::kTestingFederatedLoginMarker, |
| 969 false, | 949 false, |
| 970 true, | |
| 971 3434343434}; | 950 3434343434}; |
| 972 | 951 |
| 973 PasswordFormData merged_user_1 = {PasswordForm::SCHEME_HTML, | 952 PasswordFormData merged_user_1 = {PasswordForm::SCHEME_HTML, |
| 974 "http://some.domain.com/", | 953 "http://some.domain.com/", |
| 975 "http://some.domain.com/", | 954 "http://some.domain.com/", |
| 976 "http://some.domain.com/action.cgi", | 955 "http://some.domain.com/action.cgi", |
| 977 L"submit", | 956 L"submit", |
| 978 L"username", | 957 L"username", |
| 979 L"password", | 958 L"password", |
| 980 L"joe_user", | 959 L"joe_user", |
| 981 L"sekrit", | 960 L"sekrit", |
| 982 true, | 961 true, |
| 983 false, | |
| 984 1212121212}; | 962 1212121212}; |
| 985 PasswordFormData merged_user_1_with_db_path = { | 963 PasswordFormData merged_user_1_with_db_path = { |
| 986 PasswordForm::SCHEME_HTML, | 964 PasswordForm::SCHEME_HTML, |
| 987 "http://some.domain.com/", | 965 "http://some.domain.com/", |
| 988 "http://some.domain.com/page.html", | 966 "http://some.domain.com/page.html", |
| 989 "http://some.domain.com/handlepage.cgi", | 967 "http://some.domain.com/handlepage.cgi", |
| 990 L"submit", | 968 L"submit", |
| 991 L"username", | 969 L"username", |
| 992 L"password", | 970 L"password", |
| 993 L"joe_user", | 971 L"joe_user", |
| 994 L"sekrit", | 972 L"sekrit", |
| 995 true, | 973 true, |
| 996 false, | |
| 997 1234567890}; | 974 1234567890}; |
| 998 PasswordFormData merged_user_1_with_both_paths = { | 975 PasswordFormData merged_user_1_with_both_paths = { |
| 999 PasswordForm::SCHEME_HTML, | 976 PasswordForm::SCHEME_HTML, |
| 1000 "http://some.domain.com/", | 977 "http://some.domain.com/", |
| 1001 "http://some.domain.com/page.html", | 978 "http://some.domain.com/page.html", |
| 1002 "http://some.domain.com/handlepage.cgi", | 979 "http://some.domain.com/handlepage.cgi", |
| 1003 L"submit", | 980 L"submit", |
| 1004 L"username", | 981 L"username", |
| 1005 L"password", | 982 L"password", |
| 1006 L"joe_user", | 983 L"joe_user", |
| 1007 L"otherpassword", | 984 L"otherpassword", |
| 1008 true, | 985 true, |
| 1009 false, | |
| 1010 1234567890}; | 986 1234567890}; |
| 1011 PasswordFormData merged_android = {PasswordForm::SCHEME_HTML, | 987 PasswordFormData merged_android = {PasswordForm::SCHEME_HTML, |
| 1012 "android://hash@com.domain.some/", | 988 "android://hash@com.domain.some/", |
| 1013 "android://hash@com.domain.some/", | 989 "android://hash@com.domain.some/", |
| 1014 "", | 990 "", |
| 1015 L"", | 991 L"", |
| 1016 L"", | 992 L"", |
| 1017 L"", | 993 L"", |
| 1018 L"joe_user", | 994 L"joe_user", |
| 1019 L"secret", | 995 L"secret", |
| 1020 false, | 996 false, |
| 1021 true, | |
| 1022 1234567890}; | 997 1234567890}; |
| 1023 | 998 |
| 1024 // Build up the big multi-dimensional array of data sets that will actually | 999 // Build up the big multi-dimensional array of data sets that will actually |
| 1025 // drive the test. Use vectors rather than arrays so that initialization is | 1000 // drive the test. Use vectors rather than arrays so that initialization is |
| 1026 // simple. | 1001 // simple. |
| 1027 enum { | 1002 enum { |
| 1028 KEYCHAIN_INPUT = 0, | 1003 KEYCHAIN_INPUT = 0, |
| 1029 DATABASE_INPUT, | 1004 DATABASE_INPUT, |
| 1030 MERGE_OUTPUT, | 1005 MERGE_OUTPUT, |
| 1031 KEYCHAIN_OUTPUT, | 1006 KEYCHAIN_OUTPUT, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 test_case); | 1095 test_case); |
| 1121 CHECK_FORMS(merged_forms.get(), test_data[MERGE_OUTPUT][test_case], | 1096 CHECK_FORMS(merged_forms.get(), test_data[MERGE_OUTPUT][test_case], |
| 1122 test_case); | 1097 test_case); |
| 1123 } | 1098 } |
| 1124 } | 1099 } |
| 1125 | 1100 |
| 1126 TEST_F(PasswordStoreMacInternalsTest, TestPasswordBulkLookup) { | 1101 TEST_F(PasswordStoreMacInternalsTest, TestPasswordBulkLookup) { |
| 1127 PasswordFormData db_data[] = { | 1102 PasswordFormData db_data[] = { |
| 1128 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 1103 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 1129 "http://some.domain.com/", "http://some.domain.com/action.cgi", | 1104 "http://some.domain.com/", "http://some.domain.com/action.cgi", |
| 1130 L"submit", L"username", L"password", L"joe_user", L"", true, false, | 1105 L"submit", L"username", L"password", L"joe_user", L"", true, 1212121212}, |
| 1131 1212121212}, | |
| 1132 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 1106 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 1133 "http://some.domain.com/page.html", | 1107 "http://some.domain.com/page.html", |
| 1134 "http://some.domain.com/handlepage.cgi", L"submit", L"username", | 1108 "http://some.domain.com/handlepage.cgi", L"submit", L"username", |
| 1135 L"password", L"joe_user", L"", true, false, 1234567890}, | 1109 L"password", L"joe_user", L"", true, 1234567890}, |
| 1136 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 1110 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 1137 "http://some.domain.com/page.html", | 1111 "http://some.domain.com/page.html", |
| 1138 "http://some.domain.com/handlepage.cgi", L"submit", L"username", | 1112 "http://some.domain.com/handlepage.cgi", L"submit", L"username", |
| 1139 L"password", L"second-account", L"", true, false, 1240000000}, | 1113 L"password", L"second-account", L"", true, 1240000000}, |
| 1140 {PasswordForm::SCHEME_HTML, "http://dont.remember.com/", | 1114 {PasswordForm::SCHEME_HTML, "http://dont.remember.com/", |
| 1141 "http://dont.remember.com/", "http://dont.remember.com/handlepage.cgi", | 1115 "http://dont.remember.com/", "http://dont.remember.com/handlepage.cgi", |
| 1142 L"submit", L"username", L"password", L"joe_user", L"", true, false, | 1116 L"submit", L"username", L"password", L"joe_user", L"", true, 1240000000}, |
| 1143 1240000000}, | |
| 1144 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 1117 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 1145 "http://some.domain.com/path.html", "http://some.domain.com/action.cgi", | 1118 "http://some.domain.com/path.html", "http://some.domain.com/action.cgi", |
| 1146 L"submit", L"username", L"password", NULL, NULL, true, false, | 1119 L"submit", L"username", L"password", NULL, NULL, true, 1212121212}, |
| 1147 1212121212}, | |
| 1148 }; | 1120 }; |
| 1149 ScopedVector<autofill::PasswordForm> database_forms; | 1121 ScopedVector<autofill::PasswordForm> database_forms; |
| 1150 for (unsigned int i = 0; i < arraysize(db_data); ++i) { | 1122 for (unsigned int i = 0; i < arraysize(db_data); ++i) { |
| 1151 database_forms.push_back( | 1123 database_forms.push_back( |
| 1152 CreatePasswordFormFromDataForTesting(db_data[i]).release()); | 1124 CreatePasswordFormFromDataForTesting(db_data[i]).release()); |
| 1153 } | 1125 } |
| 1154 ScopedVector<autofill::PasswordForm> merged_forms; | 1126 ScopedVector<autofill::PasswordForm> merged_forms; |
| 1155 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1127 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
| 1156 &merged_forms); | 1128 &merged_forms); |
| 1157 EXPECT_EQ(2U, database_forms.size()); | 1129 EXPECT_EQ(2U, database_forms.size()); |
| 1158 ASSERT_EQ(3U, merged_forms.size()); | 1130 ASSERT_EQ(3U, merged_forms.size()); |
| 1159 EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[0]->password_value); | 1131 EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[0]->password_value); |
| 1160 EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[1]->password_value); | 1132 EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[1]->password_value); |
| 1161 EXPECT_TRUE(merged_forms[2]->blacklisted_by_user); | 1133 EXPECT_TRUE(merged_forms[2]->blacklisted_by_user); |
| 1162 } | 1134 } |
| 1163 | 1135 |
| 1164 TEST_F(PasswordStoreMacInternalsTest, TestBlacklistedFiltering) { | 1136 TEST_F(PasswordStoreMacInternalsTest, TestBlacklistedFiltering) { |
| 1165 PasswordFormData db_data[] = { | 1137 PasswordFormData db_data[] = { |
| 1166 {PasswordForm::SCHEME_HTML, "http://dont.remember.com/", | 1138 {PasswordForm::SCHEME_HTML, "http://dont.remember.com/", |
| 1167 "http://dont.remember.com/", "http://dont.remember.com/handlepage.cgi", | 1139 "http://dont.remember.com/", "http://dont.remember.com/handlepage.cgi", |
| 1168 L"submit", L"username", L"password", L"joe_user", L"non_empty_password", | 1140 L"submit", L"username", L"password", L"joe_user", L"non_empty_password", |
| 1169 true, false, 1240000000}, | 1141 true, 1240000000}, |
| 1170 {PasswordForm::SCHEME_HTML, "https://dont.remember.com/", | 1142 {PasswordForm::SCHEME_HTML, "https://dont.remember.com/", |
| 1171 "https://dont.remember.com/", | 1143 "https://dont.remember.com/", |
| 1172 "https://dont.remember.com/handlepage_secure.cgi", L"submit", | 1144 "https://dont.remember.com/handlepage_secure.cgi", L"submit", |
| 1173 L"username", L"password", L"joe_user", L"non_empty_password", true, | 1145 L"username", L"password", L"joe_user", L"non_empty_password", true, |
| 1174 false, 1240000000}, | 1146 1240000000}, |
| 1175 }; | 1147 }; |
| 1176 ScopedVector<autofill::PasswordForm> database_forms; | 1148 ScopedVector<autofill::PasswordForm> database_forms; |
| 1177 for (unsigned int i = 0; i < arraysize(db_data); ++i) { | 1149 for (unsigned int i = 0; i < arraysize(db_data); ++i) { |
| 1178 database_forms.push_back( | 1150 database_forms.push_back( |
| 1179 CreatePasswordFormFromDataForTesting(db_data[i]).release()); | 1151 CreatePasswordFormFromDataForTesting(db_data[i]).release()); |
| 1180 } | 1152 } |
| 1181 ScopedVector<autofill::PasswordForm> merged_forms; | 1153 ScopedVector<autofill::PasswordForm> merged_forms; |
| 1182 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1154 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
| 1183 &merged_forms); | 1155 &merged_forms); |
| 1184 EXPECT_EQ(2U, database_forms.size()); | 1156 EXPECT_EQ(2U, database_forms.size()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 | 1222 |
| 1251 TEST_F(PasswordStoreMacInternalsTest, TestPasswordGetAll) { | 1223 TEST_F(PasswordStoreMacInternalsTest, TestPasswordGetAll) { |
| 1252 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); | 1224 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); |
| 1253 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); | 1225 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); |
| 1254 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1226 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 1255 | 1227 |
| 1256 // Add a few passwords of various types so that we own some. | 1228 // Add a few passwords of various types so that we own some. |
| 1257 PasswordFormData owned_password_data[] = { | 1229 PasswordFormData owned_password_data[] = { |
| 1258 {PasswordForm::SCHEME_HTML, "http://web.site.com/", | 1230 {PasswordForm::SCHEME_HTML, "http://web.site.com/", |
| 1259 "http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL, | 1231 "http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL, |
| 1260 L"anonymous", L"knock-knock", false, false, 0}, | 1232 L"anonymous", L"knock-knock", false, 0}, |
| 1261 {PasswordForm::SCHEME_BASIC, "http://a.site.com:2222/therealm", | 1233 {PasswordForm::SCHEME_BASIC, "http://a.site.com:2222/therealm", |
| 1262 "http://a.site.com:2222/", NULL, NULL, NULL, NULL, L"username", | 1234 "http://a.site.com:2222/", NULL, NULL, NULL, NULL, L"username", |
| 1263 L"password", false, false, 0}, | 1235 L"password", false, 0}, |
| 1264 {PasswordForm::SCHEME_DIGEST, "https://digest.site.com/differentrealm", | 1236 {PasswordForm::SCHEME_DIGEST, "https://digest.site.com/differentrealm", |
| 1265 "https://digest.site.com/secure.html", NULL, NULL, NULL, NULL, | 1237 "https://digest.site.com/secure.html", NULL, NULL, NULL, NULL, |
| 1266 L"testname", L"testpass", false, false, 0}, | 1238 L"testname", L"testpass", false, 0}, |
| 1267 }; | 1239 }; |
| 1268 for (unsigned int i = 0; i < arraysize(owned_password_data); ++i) { | 1240 for (unsigned int i = 0; i < arraysize(owned_password_data); ++i) { |
| 1269 std::unique_ptr<PasswordForm> form = | 1241 std::unique_ptr<PasswordForm> form = |
| 1270 CreatePasswordFormFromDataForTesting(owned_password_data[i]); | 1242 CreatePasswordFormFromDataForTesting(owned_password_data[i]); |
| 1271 owned_keychain_adapter.AddPassword(*form); | 1243 owned_keychain_adapter.AddPassword(*form); |
| 1272 } | 1244 } |
| 1273 | 1245 |
| 1274 ScopedVector<autofill::PasswordForm> all_passwords = | 1246 ScopedVector<autofill::PasswordForm> all_passwords = |
| 1275 keychain_adapter.GetAllPasswordFormPasswords(); | 1247 keychain_adapter.GetAllPasswordFormPasswords(); |
| 1276 EXPECT_EQ(9 + arraysize(owned_password_data), all_passwords.size()); | 1248 EXPECT_EQ(9 + arraysize(owned_password_data), all_passwords.size()); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 PasswordFormData joint_data = {PasswordForm::SCHEME_HTML, | 1409 PasswordFormData joint_data = {PasswordForm::SCHEME_HTML, |
| 1438 "http://some.domain.com/", | 1410 "http://some.domain.com/", |
| 1439 "http://some.domain.com/insecure.html", | 1411 "http://some.domain.com/insecure.html", |
| 1440 "login.cgi", | 1412 "login.cgi", |
| 1441 L"username", | 1413 L"username", |
| 1442 L"password", | 1414 L"password", |
| 1443 L"submit", | 1415 L"submit", |
| 1444 L"joe_user", | 1416 L"joe_user", |
| 1445 L"sekrit", | 1417 L"sekrit", |
| 1446 true, | 1418 true, |
| 1447 false, | |
| 1448 1}; | 1419 1}; |
| 1449 std::unique_ptr<PasswordForm> joint_form = | 1420 std::unique_ptr<PasswordForm> joint_form = |
| 1450 CreatePasswordFormFromDataForTesting(joint_data); | 1421 CreatePasswordFormFromDataForTesting(joint_data); |
| 1451 EXPECT_EQ(AddChangeForForm(*joint_form), login_db()->AddLogin(*joint_form)); | 1422 EXPECT_EQ(AddChangeForForm(*joint_form), login_db()->AddLogin(*joint_form)); |
| 1452 MockAppleKeychain::KeychainTestData joint_keychain_data = { | 1423 MockAppleKeychain::KeychainTestData joint_keychain_data = { |
| 1453 kSecAuthenticationTypeHTMLForm, | 1424 kSecAuthenticationTypeHTMLForm, |
| 1454 "some.domain.com", | 1425 "some.domain.com", |
| 1455 kSecProtocolTypeHTTP, | 1426 kSecProtocolTypeHTTP, |
| 1456 "/insecure.html", | 1427 "/insecure.html", |
| 1457 0, | 1428 0, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1480 PasswordFormData form_data; | 1451 PasswordFormData form_data; |
| 1481 const char* password; // NULL indicates no entry should be present. | 1452 const char* password; // NULL indicates no entry should be present. |
| 1482 }; | 1453 }; |
| 1483 | 1454 |
| 1484 // Make a series of update calls. | 1455 // Make a series of update calls. |
| 1485 UpdateData updates[] = { | 1456 UpdateData updates[] = { |
| 1486 // Update the keychain+db passwords (the normal password update case). | 1457 // Update the keychain+db passwords (the normal password update case). |
| 1487 { | 1458 { |
| 1488 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 1459 {PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 1489 "http://some.domain.com/insecure.html", "login.cgi", L"username", | 1460 "http://some.domain.com/insecure.html", "login.cgi", L"username", |
| 1490 L"password", L"submit", L"joe_user", L"53krit", true, false, 2}, | 1461 L"password", L"submit", L"joe_user", L"53krit", true, 2}, |
| 1491 "53krit", | 1462 "53krit", |
| 1492 }, | 1463 }, |
| 1493 // Update the keychain-only password; this simulates the initial use of a | 1464 // Update the keychain-only password; this simulates the initial use of a |
| 1494 // password stored by another browsers. | 1465 // password stored by another browsers. |
| 1495 { | 1466 { |
| 1496 {PasswordForm::SCHEME_HTML, "http://keychain.only.com/", | 1467 {PasswordForm::SCHEME_HTML, "http://keychain.only.com/", |
| 1497 "http://keychain.only.com/login.html", "login.cgi", L"username", | 1468 "http://keychain.only.com/login.html", "login.cgi", L"username", |
| 1498 L"password", L"submit", L"keychain", L"only", true, false, 2}, | 1469 L"password", L"submit", L"keychain", L"only", true, 2}, |
| 1499 "only", | 1470 "only", |
| 1500 }, | 1471 }, |
| 1501 // Update a password that doesn't exist in either location. This tests the | 1472 // Update a password that doesn't exist in either location. This tests the |
| 1502 // case where a form is filled, then the stored login is removed, then the | 1473 // case where a form is filled, then the stored login is removed, then the |
| 1503 // form is submitted. | 1474 // form is submitted. |
| 1504 { | 1475 { |
| 1505 {PasswordForm::SCHEME_HTML, "http://different.com/", | 1476 {PasswordForm::SCHEME_HTML, "http://different.com/", |
| 1506 "http://different.com/index.html", "login.cgi", L"username", | 1477 "http://different.com/index.html", "login.cgi", L"username", |
| 1507 L"password", L"submit", L"abc", L"123", true, false, 2}, | 1478 L"password", L"submit", L"abc", L"123", true, 2}, |
| 1508 NULL, | 1479 NULL, |
| 1509 }, | 1480 }, |
| 1510 }; | 1481 }; |
| 1511 for (unsigned int i = 0; i < arraysize(updates); ++i) { | 1482 for (unsigned int i = 0; i < arraysize(updates); ++i) { |
| 1512 std::unique_ptr<PasswordForm> form = | 1483 std::unique_ptr<PasswordForm> form = |
| 1513 CreatePasswordFormFromDataForTesting(updates[i].form_data); | 1484 CreatePasswordFormFromDataForTesting(updates[i].form_data); |
| 1514 store_->UpdateLogin(*form); | 1485 store_->UpdateLogin(*form); |
| 1515 } | 1486 } |
| 1516 | 1487 |
| 1517 FinishAsyncProcessing(); | 1488 FinishAsyncProcessing(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 PasswordFormData www_form_data = {PasswordForm::SCHEME_HTML, | 1531 PasswordFormData www_form_data = {PasswordForm::SCHEME_HTML, |
| 1561 "http://www.facebook.com/", | 1532 "http://www.facebook.com/", |
| 1562 "http://www.facebook.com/index.html", | 1533 "http://www.facebook.com/index.html", |
| 1563 "login", | 1534 "login", |
| 1564 L"username", | 1535 L"username", |
| 1565 L"password", | 1536 L"password", |
| 1566 L"submit", | 1537 L"submit", |
| 1567 L"joe_user", | 1538 L"joe_user", |
| 1568 L"sekrit", | 1539 L"sekrit", |
| 1569 true, | 1540 true, |
| 1570 false, | |
| 1571 1}; | 1541 1}; |
| 1572 std::unique_ptr<PasswordForm> www_form = | 1542 std::unique_ptr<PasswordForm> www_form = |
| 1573 CreatePasswordFormFromDataForTesting(www_form_data); | 1543 CreatePasswordFormFromDataForTesting(www_form_data); |
| 1574 EXPECT_EQ(AddChangeForForm(*www_form), login_db()->AddLogin(*www_form)); | 1544 EXPECT_EQ(AddChangeForForm(*www_form), login_db()->AddLogin(*www_form)); |
| 1575 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain()); | 1545 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain()); |
| 1576 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1546 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 1577 owned_keychain_adapter.AddPassword(*www_form); | 1547 owned_keychain_adapter.AddPassword(*www_form); |
| 1578 | 1548 |
| 1579 // 2. Get a password for m.facebook.com. | 1549 // 2. Get a password for m.facebook.com. |
| 1580 PasswordForm m_form(*www_form); | 1550 PasswordForm m_form(*www_form); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 PasswordForm::SCHEME_HTML, | 1623 PasswordForm::SCHEME_HTML, |
| 1654 "http://www.facebook.com/", | 1624 "http://www.facebook.com/", |
| 1655 "http://www.facebook.com/index.html", | 1625 "http://www.facebook.com/index.html", |
| 1656 "login", | 1626 "login", |
| 1657 L"submit", | 1627 L"submit", |
| 1658 L"username", | 1628 L"username", |
| 1659 L"password", | 1629 L"password", |
| 1660 L"joe_user", | 1630 L"joe_user", |
| 1661 L"sekrit", | 1631 L"sekrit", |
| 1662 true, | 1632 true, |
| 1663 false, | |
| 1664 0}; | 1633 0}; |
| 1665 // The old form doesn't have elements names. | 1634 // The old form doesn't have elements names. |
| 1666 PasswordFormData www_form_data_facebook_old = { | 1635 PasswordFormData www_form_data_facebook_old = { |
| 1667 PasswordForm::SCHEME_HTML, | 1636 PasswordForm::SCHEME_HTML, |
| 1668 "http://www.facebook.com/", | 1637 "http://www.facebook.com/", |
| 1669 "http://www.facebook.com/index.html", | 1638 "http://www.facebook.com/index.html", |
| 1670 "login", | 1639 "login", |
| 1671 L"", | 1640 L"", |
| 1672 L"", | 1641 L"", |
| 1673 L"", | 1642 L"", |
| 1674 L"joe_user", | 1643 L"joe_user", |
| 1675 L"oldsekrit", | 1644 L"oldsekrit", |
| 1676 true, | 1645 true, |
| 1677 false, | |
| 1678 0}; | 1646 0}; |
| 1679 PasswordFormData www_form_data_other = {PasswordForm::SCHEME_HTML, | 1647 PasswordFormData www_form_data_other = {PasswordForm::SCHEME_HTML, |
| 1680 "http://different.com/", | 1648 "http://different.com/", |
| 1681 "http://different.com/index.html", | 1649 "http://different.com/index.html", |
| 1682 "login", | 1650 "login", |
| 1683 L"submit", | 1651 L"submit", |
| 1684 L"username", | 1652 L"username", |
| 1685 L"password", | 1653 L"password", |
| 1686 L"different_joe_user", | 1654 L"different_joe_user", |
| 1687 L"sekrit", | 1655 L"sekrit", |
| 1688 true, | 1656 true, |
| 1689 false, | |
| 1690 0}; | 1657 0}; |
| 1691 std::unique_ptr<PasswordForm> form_facebook = | 1658 std::unique_ptr<PasswordForm> form_facebook = |
| 1692 CreatePasswordFormFromDataForTesting(www_form_data_facebook); | 1659 CreatePasswordFormFromDataForTesting(www_form_data_facebook); |
| 1693 std::unique_ptr<PasswordForm> form_facebook_old = | 1660 std::unique_ptr<PasswordForm> form_facebook_old = |
| 1694 CreatePasswordFormFromDataForTesting(www_form_data_facebook_old); | 1661 CreatePasswordFormFromDataForTesting(www_form_data_facebook_old); |
| 1695 std::unique_ptr<PasswordForm> form_other = | 1662 std::unique_ptr<PasswordForm> form_other = |
| 1696 CreatePasswordFormFromDataForTesting(www_form_data_other); | 1663 CreatePasswordFormFromDataForTesting(www_form_data_other); |
| 1697 base::Time now = base::Time::Now(); | 1664 base::Time now = base::Time::Now(); |
| 1698 base::Time next_day = now + base::TimeDelta::FromDays(1); | 1665 base::Time next_day = now + base::TimeDelta::FromDays(1); |
| 1699 if (check_created) { | 1666 if (check_created) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1783 PasswordForm::SCHEME_HTML, | 1750 PasswordForm::SCHEME_HTML, |
| 1784 "http://www.facebook.com/", | 1751 "http://www.facebook.com/", |
| 1785 "http://www.facebook.com/index.html", | 1752 "http://www.facebook.com/index.html", |
| 1786 "login", | 1753 "login", |
| 1787 L"submit", | 1754 L"submit", |
| 1788 L"username", | 1755 L"username", |
| 1789 L"password", | 1756 L"password", |
| 1790 L"joe_user", | 1757 L"joe_user", |
| 1791 L"sekrit", | 1758 L"sekrit", |
| 1792 true, | 1759 true, |
| 1793 false, | |
| 1794 0}; | 1760 0}; |
| 1795 std::unique_ptr<PasswordForm> form_facebook = | 1761 std::unique_ptr<PasswordForm> form_facebook = |
| 1796 CreatePasswordFormFromDataForTesting(www_form_data_facebook); | 1762 CreatePasswordFormFromDataForTesting(www_form_data_facebook); |
| 1797 form_facebook->skip_zero_click = false; | 1763 form_facebook->skip_zero_click = false; |
| 1798 | 1764 |
| 1799 PasswordFormData www_form_data_google = { | 1765 PasswordFormData www_form_data_google = { |
| 1800 PasswordForm::SCHEME_HTML, | 1766 PasswordForm::SCHEME_HTML, |
| 1801 "http://www.google.com/", | 1767 "http://www.google.com/", |
| 1802 "http://www.google.com/foo/bar/index.html", | 1768 "http://www.google.com/foo/bar/index.html", |
| 1803 "login", | 1769 "login", |
| 1804 L"submit", | 1770 L"submit", |
| 1805 L"username", | 1771 L"username", |
| 1806 L"password", | 1772 L"password", |
| 1807 L"joe_user", | 1773 L"joe_user", |
| 1808 L"sekrit", | 1774 L"sekrit", |
| 1809 true, | 1775 true, |
| 1810 false, | |
| 1811 0}; | 1776 0}; |
| 1812 std::unique_ptr<PasswordForm> form_google = | 1777 std::unique_ptr<PasswordForm> form_google = |
| 1813 CreatePasswordFormFromDataForTesting(www_form_data_google); | 1778 CreatePasswordFormFromDataForTesting(www_form_data_google); |
| 1814 form_google->skip_zero_click = false; | 1779 form_google->skip_zero_click = false; |
| 1815 | 1780 |
| 1816 // Add the zero-clickable forms to the database. | 1781 // Add the zero-clickable forms to the database. |
| 1817 PasswordsChangeObserver observer(store()); | 1782 PasswordsChangeObserver observer(store()); |
| 1818 store()->AddLogin(*form_facebook); | 1783 store()->AddLogin(*form_facebook); |
| 1819 store()->AddLogin(*form_google); | 1784 store()->AddLogin(*form_google); |
| 1820 EXPECT_CALL(observer, OnLoginsChanged(GetAddChangeList(*form_facebook))); | 1785 EXPECT_CALL(observer, OnLoginsChanged(GetAddChangeList(*form_facebook))); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 PasswordFormData www_form_data1 = {PasswordForm::SCHEME_HTML, | 1827 PasswordFormData www_form_data1 = {PasswordForm::SCHEME_HTML, |
| 1863 "http://www.facebook.com/", | 1828 "http://www.facebook.com/", |
| 1864 "http://www.facebook.com/index.html", | 1829 "http://www.facebook.com/index.html", |
| 1865 "login", | 1830 "login", |
| 1866 L"username", | 1831 L"username", |
| 1867 L"password", | 1832 L"password", |
| 1868 L"submit", | 1833 L"submit", |
| 1869 L"joe_user", | 1834 L"joe_user", |
| 1870 L"sekrit", | 1835 L"sekrit", |
| 1871 true, | 1836 true, |
| 1872 false, | |
| 1873 1}; | 1837 1}; |
| 1874 std::unique_ptr<PasswordForm> www_form = | 1838 std::unique_ptr<PasswordForm> www_form = |
| 1875 CreatePasswordFormFromDataForTesting(www_form_data1); | 1839 CreatePasswordFormFromDataForTesting(www_form_data1); |
| 1876 EXPECT_TRUE(owned_keychain_adapter.AddPassword(*www_form)); | 1840 EXPECT_TRUE(owned_keychain_adapter.AddPassword(*www_form)); |
| 1877 | 1841 |
| 1878 // Add a password from the current profile. | 1842 // Add a password from the current profile. |
| 1879 PasswordFormData www_form_data2 = {PasswordForm::SCHEME_HTML, | 1843 PasswordFormData www_form_data2 = {PasswordForm::SCHEME_HTML, |
| 1880 "http://www.facebook.com/", | 1844 "http://www.facebook.com/", |
| 1881 "http://www.facebook.com/index.html", | 1845 "http://www.facebook.com/index.html", |
| 1882 "login", | 1846 "login", |
| 1883 L"username", | 1847 L"username", |
| 1884 L"password", | 1848 L"password", |
| 1885 L"submit", | 1849 L"submit", |
| 1886 L"not_joe_user", | 1850 L"not_joe_user", |
| 1887 L"12345", | 1851 L"12345", |
| 1888 true, | 1852 true, |
| 1889 false, | |
| 1890 1}; | 1853 1}; |
| 1891 www_form = CreatePasswordFormFromDataForTesting(www_form_data2); | 1854 www_form = CreatePasswordFormFromDataForTesting(www_form_data2); |
| 1892 store_->AddLogin(*www_form); | 1855 store_->AddLogin(*www_form); |
| 1893 FinishAsyncProcessing(); | 1856 FinishAsyncProcessing(); |
| 1894 | 1857 |
| 1895 ScopedVector<PasswordForm> matching_items; | 1858 ScopedVector<PasswordForm> matching_items; |
| 1896 EXPECT_TRUE(login_db()->GetLogins(*www_form, &matching_items)); | 1859 EXPECT_TRUE(login_db()->GetLogins(*www_form, &matching_items)); |
| 1897 EXPECT_EQ(1u, matching_items.size()); | 1860 EXPECT_EQ(1u, matching_items.size()); |
| 1898 | 1861 |
| 1899 store_->RemoveLoginsCreatedBetween(base::Time(), base::Time(), | 1862 store_->RemoveLoginsCreatedBetween(base::Time(), base::Time(), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1929 PasswordFormData www_form_data = {PasswordForm::SCHEME_HTML, | 1892 PasswordFormData www_form_data = {PasswordForm::SCHEME_HTML, |
| 1930 "http://www.facebook.com/", | 1893 "http://www.facebook.com/", |
| 1931 "http://www.facebook.com/index.html", | 1894 "http://www.facebook.com/index.html", |
| 1932 "login", | 1895 "login", |
| 1933 L"username", | 1896 L"username", |
| 1934 L"password", | 1897 L"password", |
| 1935 L"submit", | 1898 L"submit", |
| 1936 L"joe_user", | 1899 L"joe_user", |
| 1937 L"", | 1900 L"", |
| 1938 true, | 1901 true, |
| 1939 false, | |
| 1940 1}; | 1902 1}; |
| 1941 std::unique_ptr<PasswordForm> www_form( | 1903 std::unique_ptr<PasswordForm> www_form( |
| 1942 CreatePasswordFormFromDataForTesting(www_form_data)); | 1904 CreatePasswordFormFromDataForTesting(www_form_data)); |
| 1943 EXPECT_EQ(AddChangeForForm(*www_form), login_db()->AddLogin(*www_form)); | 1905 EXPECT_EQ(AddChangeForForm(*www_form), login_db()->AddLogin(*www_form)); |
| 1944 | 1906 |
| 1945 // 2. Get a PSL-matched password for m.facebook.com. The observer isn't | 1907 // 2. Get a PSL-matched password for m.facebook.com. The observer isn't |
| 1946 // notified because the form isn't in the database. | 1908 // notified because the form isn't in the database. |
| 1947 PasswordForm m_form(*www_form); | 1909 PasswordForm m_form(*www_form); |
| 1948 m_form.signon_realm = "http://m.facebook.com"; | 1910 m_form.signon_realm = "http://m.facebook.com"; |
| 1949 m_form.origin = GURL("http://m.facebook.com/index.html"); | 1911 m_form.origin = GURL("http://m.facebook.com/index.html"); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 histogram_tester_->ExpectUniqueSample( | 2073 histogram_tester_->ExpectUniqueSample( |
| 2112 "PasswordManager.KeychainMigration.NumPasswordsOnFailure", 1, 1); | 2074 "PasswordManager.KeychainMigration.NumPasswordsOnFailure", 1, 1); |
| 2113 histogram_tester_->ExpectUniqueSample( | 2075 histogram_tester_->ExpectUniqueSample( |
| 2114 "PasswordManager.KeychainMigration.NumFailedPasswords", 1, 1); | 2076 "PasswordManager.KeychainMigration.NumFailedPasswords", 1, 1); |
| 2115 histogram_tester_->ExpectUniqueSample( | 2077 histogram_tester_->ExpectUniqueSample( |
| 2116 "PasswordManager.KeychainMigration.NumChromeOwnedInaccessiblePasswords", | 2078 "PasswordManager.KeychainMigration.NumChromeOwnedInaccessiblePasswords", |
| 2117 2, 1); | 2079 2, 1); |
| 2118 // Don't test the encryption key access. | 2080 // Don't test the encryption key access. |
| 2119 histogram_tester_.reset(); | 2081 histogram_tester_.reset(); |
| 2120 } | 2082 } |
| OLD | NEW |