| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "chrome/browser/keychain_mock_mac.h" | 9 #include "chrome/browser/keychain_mock_mac.h" |
| 10 #include "chrome/browser/password_manager/password_store_mac.h" | 10 #include "chrome/browser/password_manager/password_store_mac.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 { { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", | 313 { { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", |
| 314 NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, true, 0 }, 1 }, | 314 NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, true, 0 }, 1 }, |
| 315 // Digest auth with the wrong domain. | 315 // Digest auth with the wrong domain. |
| 316 { { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/other_domain", | 316 { { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/other_domain", |
| 317 NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, true, 0 }, 0 }, | 317 NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, true, 0 }, 0 }, |
| 318 // Garbage forms should have no matches. | 318 // Garbage forms should have no matches. |
| 319 { { PasswordForm::SCHEME_HTML, "foo/bar/baz", | 319 { { PasswordForm::SCHEME_HTML, "foo/bar/baz", |
| 320 NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, false, 0 }, 0 }, | 320 NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, false, 0 }, 0 }, |
| 321 }; | 321 }; |
| 322 | 322 |
| 323 MacKeychainPasswordFormAdapter keychainAdapter(keychain_); | 323 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); |
| 324 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); |
| 325 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 324 for (unsigned int i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { | 326 for (unsigned int i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { |
| 325 scoped_ptr<PasswordForm> query_form( | 327 scoped_ptr<PasswordForm> query_form( |
| 326 CreatePasswordFormFromData(test_data[i].data)); | 328 CreatePasswordFormFromData(test_data[i].data)); |
| 327 std::vector<PasswordForm*> matching_items = | 329 std::vector<PasswordForm*> matching_items = |
| 328 keychainAdapter.PasswordsMatchingForm(*query_form); | 330 keychain_adapter.PasswordsMatchingForm(*query_form); |
| 329 EXPECT_EQ(test_data[i].expected_matches, matching_items.size()); | 331 EXPECT_EQ(test_data[i].expected_matches, matching_items.size()); |
| 330 STLDeleteElements(&matching_items); | 332 STLDeleteElements(&matching_items); |
| 333 |
| 334 // None of the pre-seeded items are owned by us, so none should match an |
| 335 // owned-passwords-only search. |
| 336 matching_items = owned_keychain_adapter.PasswordsMatchingForm(*query_form); |
| 337 EXPECT_EQ(0U, matching_items.size()); |
| 338 STLDeleteElements(&matching_items); |
| 331 } | 339 } |
| 332 } | 340 } |
| 333 | 341 |
| 334 // Changes just the origin path of |form|. | 342 // Changes just the origin path of |form|. |
| 335 static void SetPasswordFormPath(PasswordForm* form, const char* path) { | 343 static void SetPasswordFormPath(PasswordForm* form, const char* path) { |
| 336 GURL::Replacements replacement; | 344 GURL::Replacements replacement; |
| 337 std::string new_value(path); | 345 std::string new_value(path); |
| 338 replacement.SetPathStr(new_value); | 346 replacement.SetPathStr(new_value); |
| 339 form->origin = form->origin.ReplaceComponents(replacement); | 347 form->origin = form->origin.ReplaceComponents(replacement); |
| 340 } | 348 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 351 // Changes just the signon_ream auth realm of |form|. | 359 // Changes just the signon_ream auth realm of |form|. |
| 352 static void SetPasswordFormRealm(PasswordForm* form, const char* realm) { | 360 static void SetPasswordFormRealm(PasswordForm* form, const char* realm) { |
| 353 GURL::Replacements replacement; | 361 GURL::Replacements replacement; |
| 354 std::string new_value(realm); | 362 std::string new_value(realm); |
| 355 replacement.SetPathStr(new_value); | 363 replacement.SetPathStr(new_value); |
| 356 GURL signon_gurl = GURL(form->signon_realm); | 364 GURL signon_gurl = GURL(form->signon_realm); |
| 357 form->signon_realm = signon_gurl.ReplaceComponents(replacement).spec(); | 365 form->signon_realm = signon_gurl.ReplaceComponents(replacement).spec(); |
| 358 } | 366 } |
| 359 | 367 |
| 360 TEST_F(PasswordStoreMacTest, TestKeychainExactSearch) { | 368 TEST_F(PasswordStoreMacTest, TestKeychainExactSearch) { |
| 361 MacKeychainPasswordFormAdapter keychainAdapter(keychain_); | 369 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); |
| 362 | 370 |
| 363 PasswordFormData base_form_data[] = { | 371 PasswordFormData base_form_data[] = { |
| 364 { PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 372 { PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 365 "http://some.domain.com/insecure.html", | 373 "http://some.domain.com/insecure.html", |
| 366 NULL, NULL, NULL, NULL, L"joe_user", NULL, true, false, 0 }, | 374 NULL, NULL, NULL, NULL, L"joe_user", NULL, true, false, 0 }, |
| 367 { PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security", | 375 { PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security", |
| 368 "http://some.domain.com:4567/insecure.html", | 376 "http://some.domain.com:4567/insecure.html", |
| 369 NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, true, false, 0 }, | 377 NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, true, false, 0 }, |
| 370 { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", | 378 { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", |
| 371 "https://some.domain.com", | 379 "https://some.domain.com", |
| 372 NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, true, true, 0 }, | 380 NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, true, true, 0 }, |
| 373 }; | 381 }; |
| 374 | 382 |
| 375 for (unsigned int i = 0; i < arraysize(base_form_data); ++i) { | 383 for (unsigned int i = 0; i < arraysize(base_form_data); ++i) { |
| 376 // Create a base form and make sure we find a match. | 384 // Create a base form and make sure we find a match. |
| 377 scoped_ptr<PasswordForm> base_form(CreatePasswordFormFromData( | 385 scoped_ptr<PasswordForm> base_form(CreatePasswordFormFromData( |
| 378 base_form_data[i])); | 386 base_form_data[i])); |
| 379 PasswordForm* match = | 387 PasswordForm* match = |
| 380 keychainAdapter.PasswordExactlyMatchingForm(*base_form); | 388 keychain_adapter.PasswordExactlyMatchingForm(*base_form); |
| 381 EXPECT_TRUE(match != NULL); | 389 EXPECT_TRUE(match != NULL); |
| 382 if (match) { | 390 if (match) { |
| 383 EXPECT_EQ(base_form->scheme, match->scheme); | 391 EXPECT_EQ(base_form->scheme, match->scheme); |
| 384 EXPECT_EQ(base_form->origin, match->origin); | 392 EXPECT_EQ(base_form->origin, match->origin); |
| 385 EXPECT_EQ(base_form->username_value, match->username_value); | 393 EXPECT_EQ(base_form->username_value, match->username_value); |
| 386 delete match; | 394 delete match; |
| 387 } | 395 } |
| 388 | 396 |
| 389 // Make sure that the matching isn't looser than it should be by checking | 397 // Make sure that the matching isn't looser than it should be by checking |
| 390 // that slightly altered forms don't match. | 398 // that slightly altered forms don't match. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 406 modified_forms.back()->blacklisted_by_user = true; | 414 modified_forms.back()->blacklisted_by_user = true; |
| 407 | 415 |
| 408 if (base_form->scheme == PasswordForm::SCHEME_BASIC || | 416 if (base_form->scheme == PasswordForm::SCHEME_BASIC || |
| 409 base_form->scheme == PasswordForm::SCHEME_DIGEST) { | 417 base_form->scheme == PasswordForm::SCHEME_DIGEST) { |
| 410 modified_forms.push_back(new PasswordForm(*base_form)); | 418 modified_forms.push_back(new PasswordForm(*base_form)); |
| 411 SetPasswordFormRealm(modified_forms.back(), "incorrect"); | 419 SetPasswordFormRealm(modified_forms.back(), "incorrect"); |
| 412 } | 420 } |
| 413 | 421 |
| 414 for (unsigned int j = 0; j < modified_forms.size(); ++j) { | 422 for (unsigned int j = 0; j < modified_forms.size(); ++j) { |
| 415 PasswordForm* match = | 423 PasswordForm* match = |
| 416 keychainAdapter.PasswordExactlyMatchingForm(*modified_forms[j]); | 424 keychain_adapter.PasswordExactlyMatchingForm(*modified_forms[j]); |
| 417 EXPECT_EQ(NULL, match) << "In modified version " << j << " of base form " | 425 EXPECT_EQ(NULL, match) << "In modified version " << j << " of base form " |
| 418 << i; | 426 << i; |
| 419 } | 427 } |
| 420 STLDeleteElements(&modified_forms); | 428 STLDeleteElements(&modified_forms); |
| 421 } | 429 } |
| 422 } | 430 } |
| 423 | 431 |
| 424 TEST_F(PasswordStoreMacTest, TestKeychainAdd) { | 432 TEST_F(PasswordStoreMacTest, TestKeychainAdd) { |
| 425 struct TestDataAndExpectation { | 433 struct TestDataAndExpectation { |
| 426 PasswordFormData data; | 434 PasswordFormData data; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 444 { { PasswordForm::SCHEME_HTML, "gobbledygook", | 452 { { PasswordForm::SCHEME_HTML, "gobbledygook", |
| 445 "gobbledygook", NULL, NULL, NULL, NULL, | 453 "gobbledygook", NULL, NULL, NULL, NULL, |
| 446 L"anonymous", L"knock-knock", false, false, 0 }, false }, | 454 L"anonymous", L"knock-knock", false, false, 0 }, false }, |
| 447 // Test that failing to update a duplicate (forced using the magic failure | 455 // Test that failing to update a duplicate (forced using the magic failure |
| 448 // password; see MockKeychain::ItemModifyAttributesAndData) is reported. | 456 // password; see MockKeychain::ItemModifyAttributesAndData) is reported. |
| 449 { { PasswordForm::SCHEME_HTML, "http://some.domain.com", | 457 { { PasswordForm::SCHEME_HTML, "http://some.domain.com", |
| 450 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, | 458 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, |
| 451 L"joe_user", L"fail_me", false, false, 0 }, false }, | 459 L"joe_user", L"fail_me", false, false, 0 }, false }, |
| 452 }; | 460 }; |
| 453 | 461 |
| 454 MacKeychainPasswordFormAdapter keychainAdapter(keychain_); | 462 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); |
| 463 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 455 | 464 |
| 456 for (unsigned int i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { | 465 for (unsigned int i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { |
| 457 PasswordForm* in_form = CreatePasswordFormFromData(test_data[i].data); | 466 PasswordForm* in_form = CreatePasswordFormFromData(test_data[i].data); |
| 458 bool add_succeeded = keychainAdapter.AddLogin(*in_form); | 467 bool add_succeeded = owned_keychain_adapter.AddPassword(*in_form); |
| 459 EXPECT_EQ(test_data[i].should_succeed, add_succeeded); | 468 EXPECT_EQ(test_data[i].should_succeed, add_succeeded); |
| 460 if (add_succeeded) { | 469 if (add_succeeded) { |
| 461 scoped_ptr<PasswordForm> out_form( | 470 scoped_ptr<PasswordForm> out_form( |
| 462 keychainAdapter.PasswordExactlyMatchingForm(*in_form)); | 471 owned_keychain_adapter.PasswordExactlyMatchingForm(*in_form)); |
| 463 EXPECT_TRUE(out_form.get() != NULL); | 472 EXPECT_TRUE(out_form.get() != NULL); |
| 464 EXPECT_EQ(out_form->scheme, in_form->scheme); | 473 EXPECT_EQ(out_form->scheme, in_form->scheme); |
| 465 EXPECT_EQ(out_form->signon_realm, in_form->signon_realm); | 474 EXPECT_EQ(out_form->signon_realm, in_form->signon_realm); |
| 466 EXPECT_EQ(out_form->origin, in_form->origin); | 475 EXPECT_EQ(out_form->origin, in_form->origin); |
| 467 EXPECT_EQ(out_form->username_value, in_form->username_value); | 476 EXPECT_EQ(out_form->username_value, in_form->username_value); |
| 468 EXPECT_EQ(out_form->password_value, in_form->password_value); | 477 EXPECT_EQ(out_form->password_value, in_form->password_value); |
| 469 } | 478 } |
| 470 delete in_form; | 479 delete in_form; |
| 471 } | 480 } |
| 472 | 481 |
| 473 // Test that adding duplicate item updates the existing item. | 482 // Test that adding duplicate item updates the existing item. |
| 474 { | 483 { |
| 475 PasswordFormData data = { | 484 PasswordFormData data = { |
| 476 PasswordForm::SCHEME_HTML, "http://some.domain.com", | 485 PasswordForm::SCHEME_HTML, "http://some.domain.com", |
| 477 "http://some.domain.com/insecure.html", NULL, | 486 "http://some.domain.com/insecure.html", NULL, |
| 478 NULL, NULL, NULL, L"joe_user", L"updated_password", false, false, 0 | 487 NULL, NULL, NULL, L"joe_user", L"updated_password", false, false, 0 |
| 479 }; | 488 }; |
| 480 PasswordForm* update_form = CreatePasswordFormFromData(data); | 489 PasswordForm* update_form = CreatePasswordFormFromData(data); |
| 481 EXPECT_TRUE(keychainAdapter.AddLogin(*update_form)); | 490 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); |
| 491 EXPECT_TRUE(keychain_adapter.AddPassword(*update_form)); |
| 482 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(2); | 492 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(2); |
| 483 PasswordForm stored_form; | 493 PasswordForm stored_form; |
| 484 internal_keychain_helpers::FillPasswordFormFromKeychainItem(*keychain_, | 494 internal_keychain_helpers::FillPasswordFormFromKeychainItem(*keychain_, |
| 485 keychain_item, | 495 keychain_item, |
| 486 &stored_form); | 496 &stored_form); |
| 487 EXPECT_EQ(update_form->password_value, stored_form.password_value); | 497 EXPECT_EQ(update_form->password_value, stored_form.password_value); |
| 488 delete update_form; | 498 delete update_form; |
| 489 } | 499 } |
| 490 } | 500 } |
| 491 | 501 |
| 502 TEST_F(PasswordStoreMacTest, TestKeychainRemove) { |
| 503 struct TestDataAndExpectation { |
| 504 PasswordFormData data; |
| 505 bool should_succeed; |
| 506 }; |
| 507 TestDataAndExpectation test_data[] = { |
| 508 // Test deletion of an item that we add. |
| 509 { { PasswordForm::SCHEME_HTML, "http://web.site.com/", |
| 510 "http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL, |
| 511 L"anonymous", L"knock-knock", false, false, 0 }, true }, |
| 512 // Make sure we don't delete items we don't own. |
| 513 { { PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 514 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, |
| 515 L"joe_user", NULL, true, false, 0 }, false }, |
| 516 }; |
| 517 |
| 518 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); |
| 519 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 520 |
| 521 // Add our test item so that we can delete it. |
| 522 PasswordForm* add_form = CreatePasswordFormFromData(test_data[0].data); |
| 523 EXPECT_TRUE(owned_keychain_adapter.AddPassword(*add_form)); |
| 524 delete add_form; |
| 525 |
| 526 for (unsigned int i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { |
| 527 scoped_ptr<PasswordForm> form(CreatePasswordFormFromData( |
| 528 test_data[i].data)); |
| 529 EXPECT_EQ(test_data[i].should_succeed, |
| 530 owned_keychain_adapter.RemovePassword(*form)); |
| 531 |
| 532 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); |
| 533 PasswordForm* match = keychain_adapter.PasswordExactlyMatchingForm(*form); |
| 534 EXPECT_EQ(test_data[i].should_succeed, match == NULL); |
| 535 if (match) { |
| 536 delete match; |
| 537 } |
| 538 } |
| 539 } |
| 540 |
| 492 TEST_F(PasswordStoreMacTest, TestFormMatch) { | 541 TEST_F(PasswordStoreMacTest, TestFormMatch) { |
| 493 PasswordForm base_form; | 542 PasswordForm base_form; |
| 494 base_form.signon_realm = std::string("http://some.domain.com/"); | 543 base_form.signon_realm = std::string("http://some.domain.com/"); |
| 495 base_form.origin = GURL("http://some.domain.com/page.html"); | 544 base_form.origin = GURL("http://some.domain.com/page.html"); |
| 496 base_form.username_value = std::wstring(L"joe_user"); | 545 base_form.username_value = std::wstring(L"joe_user"); |
| 497 | 546 |
| 498 { | 547 { |
| 499 // Check that everything unimportant can be changed. | 548 // Check that everything unimportant can be changed. |
| 500 PasswordForm different_form(base_form); | 549 PasswordForm different_form(base_form); |
| 501 different_form.username_element = std::wstring(L"username"); | 550 different_form.username_element = std::wstring(L"username"); |
| 502 different_form.submit_element = std::wstring(L"submit"); | 551 different_form.submit_element = std::wstring(L"submit"); |
| 503 different_form.username_element = std::wstring(L"password"); | 552 different_form.username_element = std::wstring(L"password"); |
| 504 different_form.password_value = std::wstring(L"sekrit"); | 553 different_form.password_value = std::wstring(L"sekrit"); |
| 505 different_form.action = GURL("http://some.domain.com/action.cgi"); | 554 different_form.action = GURL("http://some.domain.com/action.cgi"); |
| 506 different_form.ssl_valid = true; | 555 different_form.ssl_valid = true; |
| 507 different_form.preferred = true; | 556 different_form.preferred = true; |
| 508 different_form.date_created = base::Time::Now(); | 557 different_form.date_created = base::Time::Now(); |
| 509 bool paths_match = false; | |
| 510 EXPECT_TRUE(internal_keychain_helpers::FormsMatchForMerge(base_form, | 558 EXPECT_TRUE(internal_keychain_helpers::FormsMatchForMerge(base_form, |
| 511 different_form, | 559 different_form)); |
| 512 &paths_match)); | |
| 513 EXPECT_TRUE(paths_match); | |
| 514 | 560 |
| 515 // Check that we detect path differences, but still match. | 561 // Check that path differences don't prevent a match. |
| 516 base_form.origin = GURL("http://some.domain.com/other_page.html"); | 562 base_form.origin = GURL("http://some.domain.com/other_page.html"); |
| 517 EXPECT_TRUE(internal_keychain_helpers::FormsMatchForMerge(base_form, | 563 EXPECT_TRUE(internal_keychain_helpers::FormsMatchForMerge(base_form, |
| 518 different_form, | 564 different_form)); |
| 519 &paths_match)); | |
| 520 EXPECT_FALSE(paths_match); | |
| 521 } | 565 } |
| 522 | 566 |
| 523 // Check that any one primary key changing is enough to prevent matching. | 567 // Check that any one primary key changing is enough to prevent matching. |
| 524 { | 568 { |
| 525 PasswordForm different_form(base_form); | 569 PasswordForm different_form(base_form); |
| 526 different_form.scheme = PasswordForm::SCHEME_DIGEST; | 570 different_form.scheme = PasswordForm::SCHEME_DIGEST; |
| 527 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(base_form, | 571 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(base_form, |
| 528 different_form, | 572 different_form)); |
| 529 NULL)); | |
| 530 } | 573 } |
| 531 { | 574 { |
| 532 PasswordForm different_form(base_form); | 575 PasswordForm different_form(base_form); |
| 533 different_form.signon_realm = std::string("http://some.domain.com:8080/"); | 576 different_form.signon_realm = std::string("http://some.domain.com:8080/"); |
| 534 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(base_form, | 577 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(base_form, |
| 535 different_form, | 578 different_form)); |
| 536 NULL)); | |
| 537 } | 579 } |
| 538 { | 580 { |
| 539 PasswordForm different_form(base_form); | 581 PasswordForm different_form(base_form); |
| 540 different_form.username_value = std::wstring(L"john.doe"); | 582 different_form.username_value = std::wstring(L"john.doe"); |
| 541 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(base_form, | 583 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(base_form, |
| 542 different_form, | 584 different_form)); |
| 543 NULL)); | |
| 544 } | 585 } |
| 545 { | 586 { |
| 546 PasswordForm different_form(base_form); | 587 PasswordForm different_form(base_form); |
| 547 different_form.blacklisted_by_user = true; | 588 different_form.blacklisted_by_user = true; |
| 548 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(base_form, | 589 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(base_form, |
| 549 different_form, | 590 different_form)); |
| 550 NULL)); | |
| 551 } | 591 } |
| 552 | 592 |
| 553 // Blacklist forms should *never* match for merging, even when identical | 593 // Blacklist forms should *never* match for merging, even when identical |
| 554 // (and certainly not when only one is a blacklist entry). | 594 // (and certainly not when only one is a blacklist entry). |
| 555 { | 595 { |
| 556 PasswordForm form_a(base_form); | 596 PasswordForm form_a(base_form); |
| 557 form_a.blacklisted_by_user = true; | 597 form_a.blacklisted_by_user = true; |
| 558 PasswordForm form_b(form_a); | 598 PasswordForm form_b(form_a); |
| 559 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(form_a, form_b, | 599 EXPECT_FALSE(internal_keychain_helpers::FormsMatchForMerge(form_a, form_b)); |
| 560 NULL)); | |
| 561 } | 600 } |
| 562 } | 601 } |
| 563 | 602 |
| 564 TEST_F(PasswordStoreMacTest, TestFormMerge) { | 603 TEST_F(PasswordStoreMacTest, TestFormMerge) { |
| 565 // Set up a bunch of test data to use in varying combinations. | 604 // Set up a bunch of test data to use in varying combinations. |
| 566 PasswordFormData keychain_user_1 = | 605 PasswordFormData keychain_user_1 = |
| 567 { PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 606 { PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
| 568 "http://some.domain.com/", "", L"", L"", L"", L"joe_user", L"sekrit", | 607 "http://some.domain.com/", "", L"", L"", L"", L"joe_user", L"sekrit", |
| 569 false, false, 1010101010 }; | 608 false, false, 1010101010 }; |
| 570 PasswordFormData keychain_user_1_with_path = | 609 PasswordFormData keychain_user_1_with_path = |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 test_case); | 747 test_case); |
| 709 CHECK_FORMS(database_forms, test_data[DATABASE_OUTPUT][test_case], | 748 CHECK_FORMS(database_forms, test_data[DATABASE_OUTPUT][test_case], |
| 710 test_case); | 749 test_case); |
| 711 CHECK_FORMS(merged_forms, test_data[MERGE_OUTPUT][test_case], test_case); | 750 CHECK_FORMS(merged_forms, test_data[MERGE_OUTPUT][test_case], test_case); |
| 712 | 751 |
| 713 STLDeleteElements(&keychain_forms); | 752 STLDeleteElements(&keychain_forms); |
| 714 STLDeleteElements(&database_forms); | 753 STLDeleteElements(&database_forms); |
| 715 STLDeleteElements(&merged_forms); | 754 STLDeleteElements(&merged_forms); |
| 716 } | 755 } |
| 717 } | 756 } |
| OLD | NEW |