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

Side by Side Diff: components/password_manager/content/browser/credential_manager_impl_unittest.cc

Issue 2598003002: Suppress save and update bubbles when storing a PSL matched credential (Closed)
Patch Set: Cleanup includes and update doc Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/password_manager/content/browser/credential_manager_impl.h" 5 #include "components/password_manager/content/browser/credential_manager_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <tuple> 10 #include <tuple>
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 514
515 EXPECT_TRUE(called); 515 EXPECT_TRUE(called);
516 516
517 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); 517 TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
518 EXPECT_EQ(1U, passwords.size()); 518 EXPECT_EQ(1U, passwords.size());
519 EXPECT_EQ(1U, passwords[form_.signon_realm].size()); 519 EXPECT_EQ(1U, passwords[form_.signon_realm].size());
520 EXPECT_EQ(base::ASCIIToUTF16("Totally new password."), 520 EXPECT_EQ(base::ASCIIToUTF16("Totally new password."),
521 passwords[form_.signon_realm][0].password_value); 521 passwords[form_.signon_realm][0].password_value);
522 } 522 }
523 523
524 TEST_F(CredentialManagerImplTest,
525 CredentialManagerStorePSLMatchDoesNotTriggerBubble) {
526 autofill::PasswordForm psl_form = subdomain_form_;
527 psl_form.username_value = form_.username_value;
528 psl_form.password_value = form_.password_value;
529 store_->AddLogin(psl_form);
530
531 // Calling 'Store' with a credential that PSL matches |form_| should update
532 // the password without prompting the user.
533 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
534 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(_, _))
535 .Times(testing::Exactly(0));
536 EXPECT_CALL(*client_, NotifyStorePasswordCalled());
537 bool called = false;
538 CallStore(info, base::Bind(&RespondCallback, &called));
539
540 // Allow the PasswordFormManager to talk to the password store, determine
541 // that there is an existing PSL match and update the PasswordStore.
542 RunAllPendingTasks();
543
544 EXPECT_TRUE(called);
545 }
vasilii 2016/12/22 13:24:59 Check that the credential was actually stored and
jdoerrie 2016/12/22 16:20:01 Done.
546
547 TEST_F(CredentialManagerImplTest,
548 CredentialManagerStoreNonPSLMatchWithDifferentUsernameTriggersBubble) {
vasilii 2016/12/22 13:24:59 should it be CredentialManagerStorePSLMatchWithDif
jdoerrie 2016/12/22 16:20:01 Done.
549 base::string16 delta = base::ASCIIToUTF16("_totally_different");
550 autofill::PasswordForm in_valid_psl_form = subdomain_form_;
vasilii 2016/12/22 13:24:59 What is 'in_'?
jdoerrie 2016/12/22 16:20:01 Dropped it, meant to say invalid, but the PSL matc
551 in_valid_psl_form.username_value = form_.username_value + delta;
552 in_valid_psl_form.password_value = form_.password_value;
553 store_->AddLogin(in_valid_psl_form);
554
555 // Calling 'Store' with a credential that does not PSL match |form_| should
556 // prompt the user for an update.
557 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
558 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(_, _))
559 .Times(testing::Exactly(1));
560 EXPECT_CALL(*client_, NotifyStorePasswordCalled());
561 bool called = false;
562 CallStore(info, base::Bind(&RespondCallback, &called));
563
564 // Allow the PasswordFormManager to talk to the password store, determine
565 // the form is not a (PSL) match for an existing form, and update the
vasilii 2016/12/22 13:24:59 What kind of 'update' are you expecting? i think i
jdoerrie 2016/12/22 16:20:01 Done.
566 // PasswordStore.
567 RunAllPendingTasks();
568
569 EXPECT_TRUE(called);
vasilii 2016/12/22 13:24:59 Check that client_->pending_manager()->pending_cre
jdoerrie 2016/12/22 16:20:01 Done.
570 }
571
572 TEST_F(CredentialManagerImplTest,
573 CredentialManagerStoreNonPSLMatchWithDifferentPasswordTriggersBubble) {
574 base::string16 delta = base::ASCIIToUTF16("_totally_different");
575 autofill::PasswordForm in_valid_psl_form = subdomain_form_;
576 in_valid_psl_form.username_value = form_.username_value;
577 in_valid_psl_form.password_value = form_.password_value + delta;
578 store_->AddLogin(in_valid_psl_form);
579
580 // Calling 'Store' with a credential that does not PSL match |form_| should
581 // prompt the user for an update.
582 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
583 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(_, _))
584 .Times(testing::Exactly(1));
585 EXPECT_CALL(*client_, NotifyStorePasswordCalled());
586 bool called = false;
587 CallStore(info, base::Bind(&RespondCallback, &called));
588
589 // Allow the PasswordFormManager to talk to the password store, determine
590 // the form is not a (PSL) match for an existing form, and update the
591 // PasswordStore.
592 RunAllPendingTasks();
593
594 EXPECT_TRUE(called);
595 }
596
524 TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwriteZeroClick) { 597 TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwriteZeroClick) {
525 form_.skip_zero_click = true; 598 form_.skip_zero_click = true;
526 store_->AddLogin(form_); 599 store_->AddLogin(form_);
527 RunAllPendingTasks(); 600 RunAllPendingTasks();
528 601
529 // Calling 'Store' with a credential that matches |form_| should update 602 // Calling 'Store' with a credential that matches |form_| should update
530 // the credential without prompting the user. 603 // the credential without prompting the user.
531 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); 604 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
532 bool called = false; 605 bool called = false;
533 EXPECT_CALL(*client_, NotifyStorePasswordCalled()); 606 EXPECT_CALL(*client_, NotifyStorePasswordCalled());
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 _, CredentialSourceType::CREDENTIAL_SOURCE_API)); 1532 _, CredentialSourceType::CREDENTIAL_SOURCE_API));
1460 CallStore(info, base::Bind(&RespondCallback, &called)); 1533 CallStore(info, base::Bind(&RespondCallback, &called));
1461 // Allow the PasswordFormManager to talk to the password store 1534 // Allow the PasswordFormManager to talk to the password store
1462 RunAllPendingTasks(); 1535 RunAllPendingTasks();
1463 1536
1464 ASSERT_TRUE(client_->pending_manager()); 1537 ASSERT_TRUE(client_->pending_manager());
1465 EXPECT_TRUE(client_->pending_manager()->IsBlacklisted()); 1538 EXPECT_TRUE(client_->pending_manager()->IsBlacklisted());
1466 } 1539 }
1467 1540
1468 } // namespace password_manager 1541 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698