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

Side by Side Diff: chrome/browser/password_manager/password_store_mac_unittest.cc

Issue 896903003: [PasswordManager clean-up] Merge copies of CreatePasswordFormFromData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@451018_more_scoped_vector
Patch Set: Comments addressed Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/password_manager/password_store_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/scoped_observer.h" 9 #include "base/scoped_observer.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "chrome/browser/password_manager/password_store_mac_internal.h" 14 #include "chrome/browser/password_manager/password_store_mac_internal.h"
15 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
16 #include "components/password_manager/core/browser/login_database.h" 16 #include "components/password_manager/core/browser/login_database.h"
17 #include "components/password_manager/core/browser/password_form_data.h" 17 #include "components/password_manager/core/browser/password_manager_test_utils.h "
18 #include "components/password_manager/core/browser/password_store_consumer.h" 18 #include "components/password_manager/core/browser/password_store_consumer.h"
19 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
20 #include "crypto/mock_apple_keychain.h" 20 #include "crypto/mock_apple_keychain.h"
21 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 using autofill::PasswordForm; 24 using autofill::PasswordForm;
25 using base::ASCIIToUTF16; 25 using base::ASCIIToUTF16;
26 using base::WideToUTF16; 26 using base::WideToUTF16;
27 using content::BrowserThread; 27 using content::BrowserThread;
28 using crypto::MockAppleKeychain; 28 using crypto::MockAppleKeychain;
29 using internal_keychain_helpers::FormsMatchForMerge; 29 using internal_keychain_helpers::FormsMatchForMerge;
30 using internal_keychain_helpers::STRICT_FORM_MATCH; 30 using internal_keychain_helpers::STRICT_FORM_MATCH;
31 using password_manager::CreatePasswordFormFromDataForTestingForTesting;
31 using password_manager::LoginDatabase; 32 using password_manager::LoginDatabase;
32 using password_manager::PasswordStore; 33 using password_manager::PasswordStore;
33 using password_manager::PasswordStoreConsumer; 34 using password_manager::PasswordStoreConsumer;
34 using testing::_; 35 using testing::_;
35 using testing::DoAll; 36 using testing::DoAll;
36 using testing::ElementsAre; 37 using testing::ElementsAre;
37 using testing::Invoke; 38 using testing::Invoke;
38 using testing::SizeIs; 39 using testing::SizeIs;
39 using testing::WithArg; 40 using testing::WithArg;
40 41
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 const wchar_t* submit_element; 215 const wchar_t* submit_element;
215 const wchar_t* username_element; 216 const wchar_t* username_element;
216 const wchar_t* password_element; 217 const wchar_t* password_element;
217 const wchar_t* username_value; // Set to NULL for a blacklist entry. 218 const wchar_t* username_value; // Set to NULL for a blacklist entry.
218 const wchar_t* password_value; 219 const wchar_t* password_value;
219 const bool preferred; 220 const bool preferred;
220 const bool ssl_valid; 221 const bool ssl_valid;
221 const double creation_time; 222 const double creation_time;
222 }; 223 };
223 224
224 // Creates and returns a new PasswordForm built from form_data.
225 static scoped_ptr<PasswordForm> CreatePasswordFormFromData(
226 const PasswordFormData& form_data) {
227 scoped_ptr<PasswordForm> form(new PasswordForm());
228 form->scheme = form_data.scheme;
229 form->preferred = form_data.preferred;
230 form->ssl_valid = form_data.ssl_valid;
231 form->date_created = base::Time::FromDoubleT(form_data.creation_time);
232 form->date_synced = form->date_created + base::TimeDelta::FromDays(1);
233 if (form_data.signon_realm)
234 form->signon_realm = std::string(form_data.signon_realm);
235 if (form_data.origin)
236 form->origin = GURL(form_data.origin);
237 if (form_data.action)
238 form->action = GURL(form_data.action);
239 if (form_data.submit_element)
240 form->submit_element = WideToUTF16(form_data.submit_element);
241 if (form_data.username_element)
242 form->username_element = WideToUTF16(form_data.username_element);
243 if (form_data.password_element)
244 form->password_element = WideToUTF16(form_data.password_element);
245 if (form_data.username_value) {
246 form->username_value = WideToUTF16(form_data.username_value);
247 form->display_name = form->username_value;
248 form->is_zero_click = true;
249 if (form_data.password_value)
250 form->password_value = WideToUTF16(form_data.password_value);
251 } else {
252 form->blacklisted_by_user = true;
253 }
254 form->avatar_url = GURL("https://accounts.google.com/Avatar");
255 form->federation_url = GURL("https://accounts.google.com/login");
256 return form.Pass();
257 }
258
259 // Macro to simplify calling CheckFormsAgainstExpectations with a useful label. 225 // Macro to simplify calling CheckFormsAgainstExpectations with a useful label.
260 #define CHECK_FORMS(forms, expectations, i) \ 226 #define CHECK_FORMS(forms, expectations, i) \
261 CheckFormsAgainstExpectations(forms, expectations, #forms, i) 227 CheckFormsAgainstExpectations(forms, expectations, #forms, i)
262 228
263 // Ensures that the data in |forms| match |expectations|, causing test failures 229 // Ensures that the data in |forms| match |expectations|, causing test failures
264 // for any discrepencies. 230 // for any discrepencies.
265 // TODO(stuartmorgan): This is current order-dependent; ideally it shouldn't 231 // TODO(stuartmorgan): This is current order-dependent; ideally it shouldn't
266 // matter if |forms| and |expectations| are scrambled. 232 // matter if |forms| and |expectations| are scrambled.
267 static void CheckFormsAgainstExpectations( 233 static void CheckFormsAgainstExpectations(
268 const std::vector<PasswordForm*>& forms, 234 const std::vector<PasswordForm*>& forms,
269 const std::vector<PasswordFormData*>& expectations, 235 const std::vector<PasswordFormData*>& expectations,
270 const char* forms_label, unsigned int test_number) { 236 const char* forms_label, unsigned int test_number) {
271 const unsigned int kBufferSize = 128; 237 EXPECT_EQ(expectations.size(), forms.size()) << forms_label << " in test "
272 char test_label[kBufferSize]; 238 << test_number;
273 snprintf(test_label, kBufferSize, "%s in test %u", forms_label, test_number);
274
275 EXPECT_EQ(expectations.size(), forms.size()) << test_label;
276 if (expectations.size() != forms.size()) 239 if (expectations.size() != forms.size())
277 return; 240 return;
278 241
279 for (unsigned int i = 0; i < expectations.size(); ++i) { 242 for (unsigned int i = 0; i < expectations.size(); ++i) {
280 snprintf(test_label, kBufferSize, "%s in test %u, item %u", 243 SCOPED_TRACE(testing::Message << forms_label << " in test " << test_number
engedy 2015/02/04 16:18:31 Nice, thanks!
281 forms_label, test_number, i); 244 << ", item " << i);
282 PasswordForm* form = forms[i]; 245 PasswordForm* form = forms[i];
283 PasswordFormData* expectation = expectations[i]; 246 PasswordFormData* expectation = expectations[i];
284 EXPECT_EQ(expectation->scheme, form->scheme) << test_label; 247 EXPECT_EQ(expectation->scheme, form->scheme);
285 EXPECT_EQ(std::string(expectation->signon_realm), form->signon_realm) 248 EXPECT_EQ(std::string(expectation->signon_realm), form->signon_realm);
286 << test_label; 249 EXPECT_EQ(GURL(expectation->origin), form->origin);
287 EXPECT_EQ(GURL(expectation->origin), form->origin) << test_label; 250 EXPECT_EQ(GURL(expectation->action), form->action);
288 EXPECT_EQ(GURL(expectation->action), form->action) << test_label; 251 EXPECT_EQ(WideToUTF16(expectation->submit_element), form->submit_element);
289 EXPECT_EQ(WideToUTF16(expectation->submit_element), form->submit_element)
290 << test_label;
291 EXPECT_EQ(WideToUTF16(expectation->username_element), 252 EXPECT_EQ(WideToUTF16(expectation->username_element),
292 form->username_element) << test_label; 253 form->username_element);
293 EXPECT_EQ(WideToUTF16(expectation->password_element), 254 EXPECT_EQ(WideToUTF16(expectation->password_element),
294 form->password_element) << test_label; 255 form->password_element);
295 if (expectation->username_value) { 256 if (expectation->username_value) {
296 EXPECT_EQ(WideToUTF16(expectation->username_value), 257 EXPECT_EQ(WideToUTF16(expectation->username_value), form->username_value);
297 form->username_value) << test_label; 258 EXPECT_EQ(WideToUTF16(expectation->username_value), form->display_name);
298 EXPECT_EQ(WideToUTF16(expectation->username_value), 259 EXPECT_TRUE(form->is_zero_click);
299 form->display_name) << test_label; 260 EXPECT_EQ(WideToUTF16(expectation->password_value), form->password_value);
300 EXPECT_TRUE(form->is_zero_click) << test_label;
301 EXPECT_EQ(WideToUTF16(expectation->password_value),
302 form->password_value) << test_label;
303 } else { 261 } else {
304 EXPECT_TRUE(form->blacklisted_by_user) << test_label; 262 EXPECT_TRUE(form->blacklisted_by_user);
305 } 263 }
306 EXPECT_EQ(expectation->preferred, form->preferred) << test_label; 264 EXPECT_EQ(expectation->preferred, form->preferred);
307 EXPECT_EQ(expectation->ssl_valid, form->ssl_valid) << test_label; 265 EXPECT_EQ(expectation->ssl_valid, form->ssl_valid);
308 EXPECT_DOUBLE_EQ(expectation->creation_time, 266 EXPECT_DOUBLE_EQ(expectation->creation_time,
309 form->date_created.ToDoubleT()) << test_label; 267 form->date_created.ToDoubleT());
310 base::Time created = base::Time::FromDoubleT(expectation->creation_time); 268 base::Time created = base::Time::FromDoubleT(expectation->creation_time);
311 EXPECT_EQ(created + base::TimeDelta::FromDays(1), 269 EXPECT_EQ(
312 form->date_synced) << test_label; 270 created + base::TimeDelta::FromDays(
313 EXPECT_EQ(GURL("https://accounts.google.com/Avatar"), form->avatar_url); 271 password_manager::kTestingDaysAfterPasswordsAreSynced),
314 EXPECT_EQ(GURL("https://accounts.google.com/login"), form->federation_url); 272 form->date_synced);
273 EXPECT_EQ(GURL(password_manager::kTestingAvatarUrlSpec), form->avatar_url);
274 EXPECT_EQ(GURL(password_manager::kTestingFederationUrlSpec),
275 form->federation_url);
315 } 276 }
316 } 277 }
317 278
318 #pragma mark - 279 #pragma mark -
319 280
320 TEST_F(PasswordStoreMacInternalsTest, TestKeychainToFormTranslation) { 281 TEST_F(PasswordStoreMacInternalsTest, TestKeychainToFormTranslation) {
321 typedef struct { 282 typedef struct {
322 const PasswordForm::Scheme scheme; 283 const PasswordForm::Scheme scheme;
323 const char* signon_realm; 284 const char* signon_realm;
324 const char* origin; 285 const char* origin;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 // Garbage forms should have no matches. 422 // Garbage forms should have no matches.
462 { { PasswordForm::SCHEME_HTML, "foo/bar/baz", 423 { { PasswordForm::SCHEME_HTML, "foo/bar/baz",
463 NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, false, 0 }, 0, 0 }, 424 NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, false, 0 }, 0, 0 },
464 }; 425 };
465 426
466 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); 427 MacKeychainPasswordFormAdapter keychain_adapter(keychain_);
467 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); 428 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_);
468 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); 429 owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
469 for (unsigned int i = 0; i < arraysize(test_data); ++i) { 430 for (unsigned int i = 0; i < arraysize(test_data); ++i) {
470 scoped_ptr<PasswordForm> query_form = 431 scoped_ptr<PasswordForm> query_form =
471 CreatePasswordFormFromData(test_data[i].data); 432 CreatePasswordFormFromDataForTestingForTesting(test_data[i].data);
472 433
473 // Check matches treating the form as a fill target. 434 // Check matches treating the form as a fill target.
474 ScopedVector<autofill::PasswordForm> matching_items = 435 ScopedVector<autofill::PasswordForm> matching_items =
475 keychain_adapter.PasswordsFillingForm(query_form->signon_realm, 436 keychain_adapter.PasswordsFillingForm(query_form->signon_realm,
476 query_form->scheme); 437 query_form->scheme);
477 EXPECT_EQ(test_data[i].expected_fill_matches, matching_items.size()); 438 EXPECT_EQ(test_data[i].expected_fill_matches, matching_items.size());
478 matching_items.clear(); 439 matching_items.clear();
479 440
480 // Check matches treating the form as a merging target. 441 // Check matches treating the form as a merging target.
481 EXPECT_EQ(test_data[i].expected_merge_matches > 0, 442 EXPECT_EQ(test_data[i].expected_merge_matches > 0,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 "http://some.domain.com:4567/insecure.html", 502 "http://some.domain.com:4567/insecure.html",
542 NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, true, false, 0 }, 503 NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, true, false, 0 },
543 { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security", 504 { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security",
544 "https://some.domain.com", 505 "https://some.domain.com",
545 NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, true, true, 0 }, 506 NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, true, true, 0 },
546 }; 507 };
547 508
548 for (unsigned int i = 0; i < arraysize(base_form_data); ++i) { 509 for (unsigned int i = 0; i < arraysize(base_form_data); ++i) {
549 // Create a base form and make sure we find a match. 510 // Create a base form and make sure we find a match.
550 scoped_ptr<PasswordForm> base_form = 511 scoped_ptr<PasswordForm> base_form =
551 CreatePasswordFormFromData(base_form_data[i]); 512 CreatePasswordFormFromDataForTesting(base_form_data[i]);
552 EXPECT_TRUE(keychain_adapter.HasPasswordsMergeableWithForm(*base_form)); 513 EXPECT_TRUE(keychain_adapter.HasPasswordsMergeableWithForm(*base_form));
553 EXPECT_TRUE(keychain_adapter.HasPasswordExactlyMatchingForm(*base_form)); 514 EXPECT_TRUE(keychain_adapter.HasPasswordExactlyMatchingForm(*base_form));
554 515
555 // Make sure that the matching isn't looser than it should be by checking 516 // Make sure that the matching isn't looser than it should be by checking
556 // that slightly altered forms don't match. 517 // that slightly altered forms don't match.
557 ScopedVector<autofill::PasswordForm> modified_forms; 518 ScopedVector<autofill::PasswordForm> modified_forms;
558 519
559 modified_forms.push_back(new PasswordForm(*base_form)); 520 modified_forms.push_back(new PasswordForm(*base_form));
560 modified_forms.back()->username_value = ASCIIToUTF16("wrong_user"); 521 modified_forms.back()->username_value = ASCIIToUTF16("wrong_user");
561 522
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 { { PasswordForm::SCHEME_HTML, "http://some.domain.com", 576 { { PasswordForm::SCHEME_HTML, "http://some.domain.com",
616 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, 577 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL,
617 L"joe_user", L"fail_me", false, false, 0 }, false }, 578 L"joe_user", L"fail_me", false, false, 0 }, false },
618 }; 579 };
619 580
620 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); 581 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_);
621 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); 582 owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
622 583
623 for (unsigned int i = 0; i < arraysize(test_data); ++i) { 584 for (unsigned int i = 0; i < arraysize(test_data); ++i) {
624 scoped_ptr<PasswordForm> in_form = 585 scoped_ptr<PasswordForm> in_form =
625 CreatePasswordFormFromData(test_data[i].data); 586 CreatePasswordFormFromDataForTesting(test_data[i].data);
626 bool add_succeeded = owned_keychain_adapter.AddPassword(*in_form); 587 bool add_succeeded = owned_keychain_adapter.AddPassword(*in_form);
627 EXPECT_EQ(test_data[i].should_succeed, add_succeeded); 588 EXPECT_EQ(test_data[i].should_succeed, add_succeeded);
628 if (add_succeeded) { 589 if (add_succeeded) {
629 EXPECT_TRUE(owned_keychain_adapter.HasPasswordsMergeableWithForm( 590 EXPECT_TRUE(owned_keychain_adapter.HasPasswordsMergeableWithForm(
630 *in_form)); 591 *in_form));
631 EXPECT_TRUE(owned_keychain_adapter.HasPasswordExactlyMatchingForm( 592 EXPECT_TRUE(owned_keychain_adapter.HasPasswordExactlyMatchingForm(
632 *in_form)); 593 *in_form));
633 } 594 }
634 } 595 }
635 596
636 // Test that adding duplicate item updates the existing item. 597 // Test that adding duplicate item updates the existing item.
637 { 598 {
638 PasswordFormData data = { 599 PasswordFormData data = {
639 PasswordForm::SCHEME_HTML, "http://some.domain.com", 600 PasswordForm::SCHEME_HTML, "http://some.domain.com",
640 "http://some.domain.com/insecure.html", NULL, 601 "http://some.domain.com/insecure.html", NULL,
641 NULL, NULL, NULL, L"joe_user", L"updated_password", false, false, 0 602 NULL, NULL, NULL, L"joe_user", L"updated_password", false, false, 0
642 }; 603 };
643 scoped_ptr<PasswordForm> update_form = CreatePasswordFormFromData(data); 604 scoped_ptr<PasswordForm> update_form =
605 CreatePasswordFormFromDataForTesting(data);
644 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); 606 MacKeychainPasswordFormAdapter keychain_adapter(keychain_);
645 EXPECT_TRUE(keychain_adapter.AddPassword(*update_form)); 607 EXPECT_TRUE(keychain_adapter.AddPassword(*update_form));
646 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(2); 608 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(2);
647 PasswordForm stored_form; 609 PasswordForm stored_form;
648 internal_keychain_helpers::FillPasswordFormFromKeychainItem(*keychain_, 610 internal_keychain_helpers::FillPasswordFormFromKeychainItem(*keychain_,
649 keychain_item, 611 keychain_item,
650 &stored_form, 612 &stored_form,
651 true); 613 true);
652 EXPECT_EQ(update_form->password_value, stored_form.password_value); 614 EXPECT_EQ(update_form->password_value, stored_form.password_value);
653 } 615 }
(...skipping 13 matching lines...) Expand all
667 { { PasswordForm::SCHEME_HTML, "http://some.domain.com/", 629 { { PasswordForm::SCHEME_HTML, "http://some.domain.com/",
668 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL, 630 "http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL,
669 L"joe_user", NULL, true, false, 0 }, false }, 631 L"joe_user", NULL, true, false, 0 }, false },
670 }; 632 };
671 633
672 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_); 634 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_);
673 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); 635 owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
674 636
675 // Add our test item so that we can delete it. 637 // Add our test item so that we can delete it.
676 scoped_ptr<PasswordForm> add_form = 638 scoped_ptr<PasswordForm> add_form =
677 CreatePasswordFormFromData(test_data[0].data); 639 CreatePasswordFormFromDataForTesting(test_data[0].data);
678 EXPECT_TRUE(owned_keychain_adapter.AddPassword(*add_form)); 640 EXPECT_TRUE(owned_keychain_adapter.AddPassword(*add_form));
679 641
680 for (unsigned int i = 0; i < arraysize(test_data); ++i) { 642 for (unsigned int i = 0; i < arraysize(test_data); ++i) {
681 scoped_ptr<PasswordForm> form = 643 scoped_ptr<PasswordForm> form =
682 CreatePasswordFormFromData(test_data[i].data); 644 CreatePasswordFormFromDataForTesting(test_data[i].data);
683 EXPECT_EQ(test_data[i].should_succeed, 645 EXPECT_EQ(test_data[i].should_succeed,
684 owned_keychain_adapter.RemovePassword(*form)); 646 owned_keychain_adapter.RemovePassword(*form));
685 647
686 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); 648 MacKeychainPasswordFormAdapter keychain_adapter(keychain_);
687 bool match = keychain_adapter.HasPasswordExactlyMatchingForm(*form); 649 bool match = keychain_adapter.HasPasswordExactlyMatchingForm(*form);
688 EXPECT_EQ(test_data[i].should_succeed, !match); 650 EXPECT_EQ(test_data[i].should_succeed, !match);
689 } 651 }
690 } 652 }
691 653
692 TEST_F(PasswordStoreMacInternalsTest, TestFormMatch) { 654 TEST_F(PasswordStoreMacInternalsTest, TestFormMatch) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 test_data[DATABASE_INPUT][current_test].push_back(&db_user_1_with_path); 835 test_data[DATABASE_INPUT][current_test].push_back(&db_user_1_with_path);
874 test_data[MERGE_OUTPUT][current_test].push_back(&merged_user_1); 836 test_data[MERGE_OUTPUT][current_test].push_back(&merged_user_1);
875 test_data[MERGE_OUTPUT][current_test].push_back( 837 test_data[MERGE_OUTPUT][current_test].push_back(
876 &merged_user_1_with_both_paths); 838 &merged_user_1_with_both_paths);
877 839
878 for (unsigned int test_case = 0; test_case <= current_test; ++test_case) { 840 for (unsigned int test_case = 0; test_case <= current_test; ++test_case) {
879 ScopedVector<autofill::PasswordForm> keychain_forms; 841 ScopedVector<autofill::PasswordForm> keychain_forms;
880 for (std::vector<PasswordFormData*>::iterator i = 842 for (std::vector<PasswordFormData*>::iterator i =
881 test_data[KEYCHAIN_INPUT][test_case].begin(); 843 test_data[KEYCHAIN_INPUT][test_case].begin();
882 i != test_data[KEYCHAIN_INPUT][test_case].end(); ++i) { 844 i != test_data[KEYCHAIN_INPUT][test_case].end(); ++i) {
883 keychain_forms.push_back(CreatePasswordFormFromData(*(*i)).release()); 845 keychain_forms.push_back(
846 CreatePasswordFormFromDataForTesting(*(*i)).release());
884 } 847 }
885 ScopedVector<autofill::PasswordForm> database_forms; 848 ScopedVector<autofill::PasswordForm> database_forms;
886 for (std::vector<PasswordFormData*>::iterator i = 849 for (std::vector<PasswordFormData*>::iterator i =
887 test_data[DATABASE_INPUT][test_case].begin(); 850 test_data[DATABASE_INPUT][test_case].begin();
888 i != test_data[DATABASE_INPUT][test_case].end(); ++i) { 851 i != test_data[DATABASE_INPUT][test_case].end(); ++i) {
889 database_forms.push_back(CreatePasswordFormFromData(*(*i)).release()); 852 database_forms.push_back(
853 CreatePasswordFormFromDataForTesting(*(*i)).release());
890 } 854 }
891 855
892 ScopedVector<autofill::PasswordForm> merged_forms; 856 ScopedVector<autofill::PasswordForm> merged_forms;
893 internal_keychain_helpers::MergePasswordForms(&keychain_forms, 857 internal_keychain_helpers::MergePasswordForms(&keychain_forms,
894 &database_forms, 858 &database_forms,
895 &merged_forms); 859 &merged_forms);
896 860
897 CHECK_FORMS(keychain_forms.get(), test_data[KEYCHAIN_OUTPUT][test_case], 861 CHECK_FORMS(keychain_forms.get(), test_data[KEYCHAIN_OUTPUT][test_case],
898 test_case); 862 test_case);
899 CHECK_FORMS(database_forms.get(), test_data[DATABASE_OUTPUT][test_case], 863 CHECK_FORMS(database_forms.get(), test_data[DATABASE_OUTPUT][test_case],
(...skipping 24 matching lines...) Expand all
924 "http://dont.remember.com/handlepage.cgi", 888 "http://dont.remember.com/handlepage.cgi",
925 L"submit", L"username", L"password", L"joe_user", L"", 889 L"submit", L"username", L"password", L"joe_user", L"",
926 true, false, 1240000000 }, 890 true, false, 1240000000 },
927 { PasswordForm::SCHEME_HTML, "http://some.domain.com/", 891 { PasswordForm::SCHEME_HTML, "http://some.domain.com/",
928 "http://some.domain.com/path.html", "http://some.domain.com/action.cgi", 892 "http://some.domain.com/path.html", "http://some.domain.com/action.cgi",
929 L"submit", L"username", L"password", NULL, NULL, 893 L"submit", L"username", L"password", NULL, NULL,
930 true, false, 1212121212 }, 894 true, false, 1212121212 },
931 }; 895 };
932 ScopedVector<autofill::PasswordForm> database_forms; 896 ScopedVector<autofill::PasswordForm> database_forms;
933 for (unsigned int i = 0; i < arraysize(db_data); ++i) { 897 for (unsigned int i = 0; i < arraysize(db_data); ++i) {
934 database_forms.push_back(CreatePasswordFormFromData(db_data[i]).release()); 898 database_forms.push_back(
899 CreatePasswordFormFromDataForTesting(db_data[i]).release());
935 } 900 }
936 ScopedVector<autofill::PasswordForm> merged_forms; 901 ScopedVector<autofill::PasswordForm> merged_forms;
937 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, 902 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms,
938 &merged_forms); 903 &merged_forms);
939 EXPECT_EQ(2U, database_forms.size()); 904 EXPECT_EQ(2U, database_forms.size());
940 ASSERT_EQ(3U, merged_forms.size()); 905 ASSERT_EQ(3U, merged_forms.size());
941 EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[0]->password_value); 906 EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[0]->password_value);
942 EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[1]->password_value); 907 EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[1]->password_value);
943 EXPECT_TRUE(merged_forms[2]->blacklisted_by_user); 908 EXPECT_TRUE(merged_forms[2]->blacklisted_by_user);
944 } 909 }
945 910
946 TEST_F(PasswordStoreMacInternalsTest, TestBlacklistedFiltering) { 911 TEST_F(PasswordStoreMacInternalsTest, TestBlacklistedFiltering) {
947 PasswordFormData db_data[] = { 912 PasswordFormData db_data[] = {
948 { PasswordForm::SCHEME_HTML, "http://dont.remember.com/", 913 { PasswordForm::SCHEME_HTML, "http://dont.remember.com/",
949 "http://dont.remember.com/", 914 "http://dont.remember.com/",
950 "http://dont.remember.com/handlepage.cgi", 915 "http://dont.remember.com/handlepage.cgi",
951 L"submit", L"username", L"password", L"joe_user", L"non_empty_password", 916 L"submit", L"username", L"password", L"joe_user", L"non_empty_password",
952 true, false, 1240000000 }, 917 true, false, 1240000000 },
953 { PasswordForm::SCHEME_HTML, "https://dont.remember.com/", 918 { PasswordForm::SCHEME_HTML, "https://dont.remember.com/",
954 "https://dont.remember.com/", 919 "https://dont.remember.com/",
955 "https://dont.remember.com/handlepage_secure.cgi", 920 "https://dont.remember.com/handlepage_secure.cgi",
956 L"submit", L"username", L"password", L"joe_user", L"non_empty_password", 921 L"submit", L"username", L"password", L"joe_user", L"non_empty_password",
957 true, false, 1240000000 }, 922 true, false, 1240000000 },
958 }; 923 };
959 ScopedVector<autofill::PasswordForm> database_forms; 924 ScopedVector<autofill::PasswordForm> database_forms;
960 for (unsigned int i = 0; i < arraysize(db_data); ++i) { 925 for (unsigned int i = 0; i < arraysize(db_data); ++i) {
961 database_forms.push_back(CreatePasswordFormFromData(db_data[i]).release()); 926 database_forms.push_back(
927 CreatePasswordFormFromDataForTesting(db_data[i]).release());
962 } 928 }
963 ScopedVector<autofill::PasswordForm> merged_forms; 929 ScopedVector<autofill::PasswordForm> merged_forms;
964 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, 930 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms,
965 &merged_forms); 931 &merged_forms);
966 EXPECT_EQ(2U, database_forms.size()); 932 EXPECT_EQ(2U, database_forms.size());
967 ASSERT_EQ(0U, merged_forms.size()); 933 ASSERT_EQ(0U, merged_forms.size());
968 } 934 }
969 935
970 TEST_F(PasswordStoreMacInternalsTest, TestFillPasswordFormFromKeychainItem) { 936 TEST_F(PasswordStoreMacInternalsTest, TestFillPasswordFormFromKeychainItem) {
971 // When |extract_password_data| is false, the password field must be empty, 937 // When |extract_password_data| is false, the password field must be empty,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 L"anonymous", L"knock-knock", false, false, 0 }, 1019 L"anonymous", L"knock-knock", false, false, 0 },
1054 { PasswordForm::SCHEME_BASIC, "http://a.site.com:2222/therealm", 1020 { PasswordForm::SCHEME_BASIC, "http://a.site.com:2222/therealm",
1055 "http://a.site.com:2222/", NULL, NULL, NULL, NULL, 1021 "http://a.site.com:2222/", NULL, NULL, NULL, NULL,
1056 L"username", L"password", false, false, 0 }, 1022 L"username", L"password", false, false, 0 },
1057 { PasswordForm::SCHEME_DIGEST, "https://digest.site.com/differentrealm", 1023 { PasswordForm::SCHEME_DIGEST, "https://digest.site.com/differentrealm",
1058 "https://digest.site.com/secure.html", NULL, NULL, NULL, NULL, 1024 "https://digest.site.com/secure.html", NULL, NULL, NULL, NULL,
1059 L"testname", L"testpass", false, false, 0 }, 1025 L"testname", L"testpass", false, false, 0 },
1060 }; 1026 };
1061 for (unsigned int i = 0; i < arraysize(owned_password_data); ++i) { 1027 for (unsigned int i = 0; i < arraysize(owned_password_data); ++i) {
1062 scoped_ptr<PasswordForm> form = 1028 scoped_ptr<PasswordForm> form =
1063 CreatePasswordFormFromData(owned_password_data[i]); 1029 CreatePasswordFormFromDataForTesting(owned_password_data[i]);
1064 owned_keychain_adapter.AddPassword(*form); 1030 owned_keychain_adapter.AddPassword(*form);
1065 } 1031 }
1066 1032
1067 ScopedVector<autofill::PasswordForm> all_passwords = 1033 ScopedVector<autofill::PasswordForm> all_passwords =
1068 keychain_adapter.GetAllPasswordFormPasswords(); 1034 keychain_adapter.GetAllPasswordFormPasswords();
1069 EXPECT_EQ(8 + arraysize(owned_password_data), all_passwords.size()); 1035 EXPECT_EQ(8 + arraysize(owned_password_data), all_passwords.size());
1070 1036
1071 ScopedVector<autofill::PasswordForm> owned_passwords = 1037 ScopedVector<autofill::PasswordForm> owned_passwords =
1072 owned_keychain_adapter.GetAllPasswordFormPasswords(); 1038 owned_keychain_adapter.GetAllPasswordFormPasswords();
1073 EXPECT_EQ(arraysize(owned_password_data), owned_passwords.size()); 1039 EXPECT_EQ(arraysize(owned_password_data), owned_passwords.size());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 // Insert a password into both the database and the keychain. 1112 // Insert a password into both the database and the keychain.
1147 // This is done manually, rather than through store_->AddLogin, because the 1113 // This is done manually, rather than through store_->AddLogin, because the
1148 // Mock Keychain isn't smart enough to be able to support update generically, 1114 // Mock Keychain isn't smart enough to be able to support update generically,
1149 // so some.domain.com triggers special handling to test it that make inserting 1115 // so some.domain.com triggers special handling to test it that make inserting
1150 // fail. 1116 // fail.
1151 PasswordFormData joint_data = { 1117 PasswordFormData joint_data = {
1152 PasswordForm::SCHEME_HTML, "http://some.domain.com/", 1118 PasswordForm::SCHEME_HTML, "http://some.domain.com/",
1153 "http://some.domain.com/insecure.html", "login.cgi", 1119 "http://some.domain.com/insecure.html", "login.cgi",
1154 L"username", L"password", L"submit", L"joe_user", L"sekrit", true, false, 1 1120 L"username", L"password", L"submit", L"joe_user", L"sekrit", true, false, 1
1155 }; 1121 };
1156 scoped_ptr<PasswordForm> joint_form = CreatePasswordFormFromData(joint_data); 1122 scoped_ptr<PasswordForm> joint_form =
1123 CreatePasswordFormFromDataForTesting(joint_data);
1157 login_db()->AddLogin(*joint_form); 1124 login_db()->AddLogin(*joint_form);
1158 MockAppleKeychain::KeychainTestData joint_keychain_data = { 1125 MockAppleKeychain::KeychainTestData joint_keychain_data = {
1159 kSecAuthenticationTypeHTMLForm, "some.domain.com", 1126 kSecAuthenticationTypeHTMLForm, "some.domain.com",
1160 kSecProtocolTypeHTTP, "/insecure.html", 0, NULL, "20020601171500Z", 1127 kSecProtocolTypeHTTP, "/insecure.html", 0, NULL, "20020601171500Z",
1161 "joe_user", "sekrit", false }; 1128 "joe_user", "sekrit", false };
1162 keychain()->AddTestItem(joint_keychain_data); 1129 keychain()->AddTestItem(joint_keychain_data);
1163 1130
1164 // Insert a password into the keychain only. 1131 // Insert a password into the keychain only.
1165 MockAppleKeychain::KeychainTestData keychain_only_data = { 1132 MockAppleKeychain::KeychainTestData keychain_only_data = {
1166 kSecAuthenticationTypeHTMLForm, "keychain.only.com", 1133 kSecAuthenticationTypeHTMLForm, "keychain.only.com",
(...skipping 29 matching lines...) Expand all
1196 // form is submitted. 1163 // form is submitted.
1197 { { PasswordForm::SCHEME_HTML, "http://different.com/", 1164 { { PasswordForm::SCHEME_HTML, "http://different.com/",
1198 "http://different.com/index.html", "login.cgi", 1165 "http://different.com/index.html", "login.cgi",
1199 L"username", L"password", L"submit", L"abc", L"123", 1166 L"username", L"password", L"submit", L"abc", L"123",
1200 true, false, 2 }, 1167 true, false, 2 },
1201 NULL, 1168 NULL,
1202 }, 1169 },
1203 }; 1170 };
1204 for (unsigned int i = 0; i < arraysize(updates); ++i) { 1171 for (unsigned int i = 0; i < arraysize(updates); ++i) {
1205 scoped_ptr<PasswordForm> form = 1172 scoped_ptr<PasswordForm> form =
1206 CreatePasswordFormFromData(updates[i].form_data); 1173 CreatePasswordFormFromDataForTesting(updates[i].form_data);
1207 store_->UpdateLogin(*form); 1174 store_->UpdateLogin(*form);
1208 } 1175 }
1209 1176
1210 FinishAsyncProcessing(); 1177 FinishAsyncProcessing();
1211 1178
1212 MacKeychainPasswordFormAdapter keychain_adapter(keychain()); 1179 MacKeychainPasswordFormAdapter keychain_adapter(keychain());
1213 for (unsigned int i = 0; i < arraysize(updates); ++i) { 1180 for (unsigned int i = 0; i < arraysize(updates); ++i) {
1214 scoped_ptr<PasswordForm> query_form = 1181 scoped_ptr<PasswordForm> query_form =
1215 CreatePasswordFormFromData(updates[i].form_data); 1182 CreatePasswordFormFromDataForTesting(updates[i].form_data);
1216 1183
1217 ScopedVector<autofill::PasswordForm> matching_items = 1184 ScopedVector<autofill::PasswordForm> matching_items =
1218 keychain_adapter.PasswordsFillingForm(query_form->signon_realm, 1185 keychain_adapter.PasswordsFillingForm(query_form->signon_realm,
1219 query_form->scheme); 1186 query_form->scheme);
1220 if (updates[i].password) { 1187 if (updates[i].password) {
1221 EXPECT_GT(matching_items.size(), 0U) << "iteration " << i; 1188 EXPECT_GT(matching_items.size(), 0U) << "iteration " << i;
1222 if (matching_items.size() >= 1) 1189 if (matching_items.size() >= 1)
1223 EXPECT_EQ(ASCIIToUTF16(updates[i].password), 1190 EXPECT_EQ(ASCIIToUTF16(updates[i].password),
1224 matching_items[0]->password_value) << "iteration " << i; 1191 matching_items[0]->password_value) << "iteration " << i;
1225 } else { 1192 } else {
(...skipping 22 matching lines...) Expand all
1248 // www.facebook.com password from the login database, we should not be blocked 1215 // www.facebook.com password from the login database, we should not be blocked
1249 // from deleting it from the keystore just becaus the m.facebook.com password 1216 // from deleting it from the keystore just becaus the m.facebook.com password
1250 // fuzzy-matches the www.facebook.com one.) 1217 // fuzzy-matches the www.facebook.com one.)
1251 1218
1252 // 1. Add a password for www.facebook.com 1219 // 1. Add a password for www.facebook.com
1253 PasswordFormData www_form_data = { 1220 PasswordFormData www_form_data = {
1254 PasswordForm::SCHEME_HTML, "http://www.facebook.com/", 1221 PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
1255 "http://www.facebook.com/index.html", "login", 1222 "http://www.facebook.com/index.html", "login",
1256 L"username", L"password", L"submit", L"joe_user", L"sekrit", true, false, 1 1223 L"username", L"password", L"submit", L"joe_user", L"sekrit", true, false, 1
1257 }; 1224 };
1258 scoped_ptr<PasswordForm> www_form = CreatePasswordFormFromData(www_form_data); 1225 scoped_ptr<PasswordForm> www_form =
1226 CreatePasswordFormFromDataForTesting(www_form_data);
1259 login_db()->AddLogin(*www_form); 1227 login_db()->AddLogin(*www_form);
1260 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain()); 1228 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain());
1261 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); 1229 owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
1262 owned_keychain_adapter.AddPassword(*www_form); 1230 owned_keychain_adapter.AddPassword(*www_form);
1263 1231
1264 // 2. Get a password for m.facebook.com. 1232 // 2. Get a password for m.facebook.com.
1265 PasswordForm m_form(*www_form); 1233 PasswordForm m_form(*www_form);
1266 m_form.signon_realm = "http://m.facebook.com"; 1234 m_form.signon_realm = "http://m.facebook.com";
1267 m_form.origin = GURL("http://m.facebook.com/index.html"); 1235 m_form.origin = GURL("http://m.facebook.com/index.html");
1268 1236
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 // The old form doesn't have elements names. 1307 // The old form doesn't have elements names.
1340 PasswordFormData www_form_data_facebook_old = { 1308 PasswordFormData www_form_data_facebook_old = {
1341 PasswordForm::SCHEME_HTML, "http://www.facebook.com/", 1309 PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
1342 "http://www.facebook.com/index.html", "login", L"", L"", 1310 "http://www.facebook.com/index.html", "login", L"", L"",
1343 L"", L"joe_user", L"oldsekrit", true, false, 0 }; 1311 L"", L"joe_user", L"oldsekrit", true, false, 0 };
1344 PasswordFormData www_form_data_other = { 1312 PasswordFormData www_form_data_other = {
1345 PasswordForm::SCHEME_HTML, "http://different.com/", 1313 PasswordForm::SCHEME_HTML, "http://different.com/",
1346 "http://different.com/index.html", "login", L"submit", L"username", 1314 "http://different.com/index.html", "login", L"submit", L"username",
1347 L"password", L"different_joe_user", L"sekrit", true, false, 0 }; 1315 L"password", L"different_joe_user", L"sekrit", true, false, 0 };
1348 scoped_ptr<PasswordForm> form_facebook = 1316 scoped_ptr<PasswordForm> form_facebook =
1349 CreatePasswordFormFromData(www_form_data_facebook); 1317 CreatePasswordFormFromDataForTesting(www_form_data_facebook);
1350 scoped_ptr<PasswordForm> form_facebook_old = 1318 scoped_ptr<PasswordForm> form_facebook_old =
1351 CreatePasswordFormFromData(www_form_data_facebook_old); 1319 CreatePasswordFormFromDataForTesting(www_form_data_facebook_old);
1352 scoped_ptr<PasswordForm> form_other = 1320 scoped_ptr<PasswordForm> form_other =
1353 CreatePasswordFormFromData(www_form_data_other); 1321 CreatePasswordFormFromDataForTesting(www_form_data_other);
1354 base::Time now = base::Time::Now(); 1322 base::Time now = base::Time::Now();
1355 // TODO(vasilii): remove the next line once crbug/374132 is fixed. 1323 // TODO(vasilii): remove the next line once crbug/374132 is fixed.
1356 now = base::Time::FromTimeT(now.ToTimeT()); 1324 now = base::Time::FromTimeT(now.ToTimeT());
1357 base::Time next_day = now + base::TimeDelta::FromDays(1); 1325 base::Time next_day = now + base::TimeDelta::FromDays(1);
1358 if (check_created) { 1326 if (check_created) {
1359 form_facebook_old->date_created = now; 1327 form_facebook_old->date_created = now;
1360 form_facebook->date_created = next_day; 1328 form_facebook->date_created = next_day;
1361 form_other->date_created = next_day; 1329 form_other->date_created = next_day;
1362 } else { 1330 } else {
1363 form_facebook_old->date_synced = now; 1331 form_facebook_old->date_synced = now;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 1411
1444 // Add a password through the adapter. It has the "Chrome" creator tag. 1412 // Add a password through the adapter. It has the "Chrome" creator tag.
1445 // However, it's not referenced by the password database. 1413 // However, it's not referenced by the password database.
1446 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain()); 1414 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain());
1447 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); 1415 owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
1448 PasswordFormData www_form_data1 = { 1416 PasswordFormData www_form_data1 = {
1449 PasswordForm::SCHEME_HTML, "http://www.facebook.com/", 1417 PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
1450 "http://www.facebook.com/index.html", "login", L"username", L"password", 1418 "http://www.facebook.com/index.html", "login", L"username", L"password",
1451 L"submit", L"joe_user", L"sekrit", true, false, 1 }; 1419 L"submit", L"joe_user", L"sekrit", true, false, 1 };
1452 scoped_ptr<PasswordForm> www_form = 1420 scoped_ptr<PasswordForm> www_form =
1453 CreatePasswordFormFromData(www_form_data1); 1421 CreatePasswordFormFromDataForTesting(www_form_data1);
1454 EXPECT_TRUE(owned_keychain_adapter.AddPassword(*www_form)); 1422 EXPECT_TRUE(owned_keychain_adapter.AddPassword(*www_form));
1455 1423
1456 // Add a password from the current profile. 1424 // Add a password from the current profile.
1457 PasswordFormData www_form_data2 = { 1425 PasswordFormData www_form_data2 = {
1458 PasswordForm::SCHEME_HTML, "http://www.facebook.com/", 1426 PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
1459 "http://www.facebook.com/index.html", "login", L"username", L"password", 1427 "http://www.facebook.com/index.html", "login", L"username", L"password",
1460 L"submit", L"not_joe_user", L"12345", true, false, 1 }; 1428 L"submit", L"not_joe_user", L"12345", true, false, 1 };
1461 www_form = CreatePasswordFormFromData(www_form_data2); 1429 www_form = CreatePasswordFormFromDataForTesting(www_form_data2);
1462 store_->AddLogin(*www_form); 1430 store_->AddLogin(*www_form);
1463 FinishAsyncProcessing(); 1431 FinishAsyncProcessing();
1464 1432
1465 ScopedVector<PasswordForm> matching_items; 1433 ScopedVector<PasswordForm> matching_items;
1466 login_db()->GetLogins(*www_form, &matching_items); 1434 login_db()->GetLogins(*www_form, &matching_items);
1467 EXPECT_EQ(1u, matching_items.size()); 1435 EXPECT_EQ(1u, matching_items.size());
1468 matching_items.clear(); 1436 matching_items.clear();
1469 1437
1470 store_->RemoveLoginsCreatedBetween(base::Time(), base::Time()); 1438 store_->RemoveLoginsCreatedBetween(base::Time(), base::Time());
1471 FinishAsyncProcessing(); 1439 FinishAsyncProcessing();
(...skipping 24 matching lines...) Expand all
1496 ClosePasswordStore(); 1464 ClosePasswordStore();
1497 1465
1498 base::WaitableEvent event(false, false); 1466 base::WaitableEvent event(false, false);
1499 CreateAndInitPasswordStore(make_scoped_ptr<password_manager::LoginDatabase>( 1467 CreateAndInitPasswordStore(make_scoped_ptr<password_manager::LoginDatabase>(
1500 new SlowToInitLoginDatabase(test_login_db_file_path(), &event))); 1468 new SlowToInitLoginDatabase(test_login_db_file_path(), &event)));
1501 1469
1502 PasswordFormData www_form_data = { 1470 PasswordFormData www_form_data = {
1503 PasswordForm::SCHEME_HTML, "http://www.facebook.com/", 1471 PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
1504 "http://www.facebook.com/index.html", "login", L"username", L"password", 1472 "http://www.facebook.com/index.html", "login", L"username", L"password",
1505 L"submit", L"not_joe_user", L"12345", true, false, 1}; 1473 L"submit", L"not_joe_user", L"12345", true, false, 1};
1506 scoped_ptr<PasswordForm> form = CreatePasswordFormFromData(www_form_data); 1474 scoped_ptr<PasswordForm> form =
1475 CreatePasswordFormFromDataForTesting(www_form_data);
1507 store()->AddLogin(*form); 1476 store()->AddLogin(*form);
1508 1477
1509 MockPasswordStoreConsumer mock_consumer; 1478 MockPasswordStoreConsumer mock_consumer;
1510 store()->GetLogins(*form, PasswordStore::ALLOW_PROMPT, &mock_consumer); 1479 store()->GetLogins(*form, PasswordStore::ALLOW_PROMPT, &mock_consumer);
1511 1480
1512 // Now the read/write tasks are scheduled, let the DB initialization proceed. 1481 // Now the read/write tasks are scheduled, let the DB initialization proceed.
1513 event.Signal(); 1482 event.Signal();
1514 1483
1515 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u))) 1484 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u)))
1516 .WillOnce(QuitUIMessageLoop()); 1485 .WillOnce(QuitUIMessageLoop());
(...skipping 12 matching lines...) Expand all
1529 EXPECT_FALSE(login_db()); 1498 EXPECT_FALSE(login_db());
1530 1499
1531 testing::StrictMock<MockPasswordStoreObserver> mock_observer; 1500 testing::StrictMock<MockPasswordStoreObserver> mock_observer;
1532 store()->AddObserver(&mock_observer); 1501 store()->AddObserver(&mock_observer);
1533 1502
1534 // Add a new autofillable login + a blacklisted login. 1503 // Add a new autofillable login + a blacklisted login.
1535 PasswordFormData www_form_data = { 1504 PasswordFormData www_form_data = {
1536 PasswordForm::SCHEME_HTML, "http://www.facebook.com/", 1505 PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
1537 "http://www.facebook.com/index.html", "login", L"username", L"password", 1506 "http://www.facebook.com/index.html", "login", L"username", L"password",
1538 L"submit", L"not_joe_user", L"12345", true, false, 1}; 1507 L"submit", L"not_joe_user", L"12345", true, false, 1};
1539 scoped_ptr<PasswordForm> form = CreatePasswordFormFromData(www_form_data); 1508 scoped_ptr<PasswordForm> form =
1509 CreatePasswordFormFromDataForTesting(www_form_data);
1540 scoped_ptr<PasswordForm> blacklisted_form(new PasswordForm(*form)); 1510 scoped_ptr<PasswordForm> blacklisted_form(new PasswordForm(*form));
1541 blacklisted_form->signon_realm = "http://foo.example.com"; 1511 blacklisted_form->signon_realm = "http://foo.example.com";
1542 blacklisted_form->origin = GURL("http://foo.example.com/origin"); 1512 blacklisted_form->origin = GURL("http://foo.example.com/origin");
1543 blacklisted_form->action = GURL("http://foo.example.com/action"); 1513 blacklisted_form->action = GURL("http://foo.example.com/action");
1544 blacklisted_form->blacklisted_by_user = true; 1514 blacklisted_form->blacklisted_by_user = true;
1545 store()->AddLogin(*form); 1515 store()->AddLogin(*form);
1546 store()->AddLogin(*blacklisted_form); 1516 store()->AddLogin(*blacklisted_form);
1547 FinishAsyncProcessing(); 1517 FinishAsyncProcessing();
1548 1518
1549 // Get all logins; autofillable logins; blacklisted logins. 1519 // Get all logins; autofillable logins; blacklisted logins.
(...skipping 24 matching lines...) Expand all
1574 1544
1575 // Delete one login; a range of logins. 1545 // Delete one login; a range of logins.
1576 store()->RemoveLogin(*form); 1546 store()->RemoveLogin(*form);
1577 store()->RemoveLoginsCreatedBetween(base::Time(), base::Time::Max()); 1547 store()->RemoveLoginsCreatedBetween(base::Time(), base::Time::Max());
1578 store()->RemoveLoginsSyncedBetween(base::Time(), base::Time::Max()); 1548 store()->RemoveLoginsSyncedBetween(base::Time(), base::Time::Max());
1579 FinishAsyncProcessing(); 1549 FinishAsyncProcessing();
1580 1550
1581 // Verify no notifications are fired during shutdown either. 1551 // Verify no notifications are fired during shutdown either.
1582 ClosePasswordStore(); 1552 ClosePasswordStore();
1583 } 1553 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/password_manager/password_store_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698