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

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

Issue 1785273002: CREDENTIAL: Persist PasswordForm's primary key through CredentialInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another test Created 4 years, 9 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
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_dispatc her.h" 5 #include "components/password_manager/content/browser/credential_manager_dispatc her.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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // Allow the PasswordFormManager to talk to the password store, determine 405 // Allow the PasswordFormManager to talk to the password store, determine
406 // the form is a match for an existing form, and update the PasswordStore. 406 // the form is a match for an existing form, and update the PasswordStore.
407 RunAllPendingTasks(); 407 RunAllPendingTasks();
408 408
409 // Verify that the update didn't toggle the skip_zero_click flag off. 409 // Verify that the update didn't toggle the skip_zero_click flag off.
410 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); 410 TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
411 EXPECT_TRUE(passwords[form_.signon_realm][0].skip_zero_click); 411 EXPECT_TRUE(passwords[form_.signon_realm][0].skip_zero_click);
412 } 412 }
413 413
414 TEST_F(CredentialManagerDispatcherTest, 414 TEST_F(CredentialManagerDispatcherTest,
415 CredentialManagerGetOverwriteZeroClick) {
416 // Set the global zero click flag on, and populate the PasswordStore with a
417 // form that's set to skip zero click and has a primary key that won't match
418 // credentials initially created via `store()`.
419 client_->set_zero_click_enabled(true);
420 form_.skip_zero_click = true;
421 form_.username_element = base::ASCIIToUTF16("username-element");
422 form_.password_element = base::ASCIIToUTF16("password-element");
423 form_.signon_realm = "this is a realm";
vasilii 2016/03/11 14:29:48 I want another origin_url too. It's a part of the
424 store_->AddLogin(form_);
425 RunAllPendingTasks();
426
427 std::vector<GURL> federations;
428 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _))
429 .Times(testing::Exactly(1));
430 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
431
432 dispatcher()->OnRequestCredential(kRequestId, false, true, federations);
433
434 RunAllPendingTasks();
435
436 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
437 const IPC::Message* message =
438 process()->sink().GetFirstMessageMatching(kMsgID);
439 EXPECT_TRUE(message);
440
441 // Verify that the update toggled the skip_zero_click flag.
442 TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
443 EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click);
444 }
445
446 TEST_F(CredentialManagerDispatcherTest,
415 CredentialManagerSignInWithSavingDisabledForCurrentPage) { 447 CredentialManagerSignInWithSavingDisabledForCurrentPage) {
416 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); 448 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
417 EXPECT_CALL(*client_, IsSavingAndFillingEnabledForCurrentPage()) 449 EXPECT_CALL(*client_, IsSavingAndFillingEnabledForCurrentPage())
418 .WillRepeatedly(testing::Return(false)); 450 .WillRepeatedly(testing::Return(false));
419 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( 451 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
420 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) 452 _, CredentialSourceType::CREDENTIAL_SOURCE_API))
421 .Times(testing::Exactly(0)); 453 .Times(testing::Exactly(0));
422 454
423 dispatcher()->OnStore(kRequestId, info); 455 dispatcher()->OnStore(kRequestId, info);
424 456
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) { 1153 TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) {
1122 autofill::PasswordForm synthesized = 1154 autofill::PasswordForm synthesized =
1123 dispatcher_->GetSynthesizedFormForOrigin(); 1155 dispatcher_->GetSynthesizedFormForOrigin();
1124 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec()); 1156 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec());
1125 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm); 1157 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm);
1126 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme); 1158 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme);
1127 EXPECT_TRUE(synthesized.ssl_valid); 1159 EXPECT_TRUE(synthesized.ssl_valid);
1128 } 1160 }
1129 1161
1130 } // namespace password_manager 1162 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698