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

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

Issue 1928323002: CREDENTIAL: Tighten the behavior of 'requireUserMediation()' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | components/password_manager/core/browser/credential_manager_pending_require_user_mediation_task.h » ('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 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 affiliated_form2_.ssl_valid = true; 242 affiliated_form2_.ssl_valid = true;
243 243
244 origin_path_form_.username_value = base::ASCIIToUTF16("Username 2"); 244 origin_path_form_.username_value = base::ASCIIToUTF16("Username 2");
245 origin_path_form_.display_name = base::ASCIIToUTF16("Display Name 2"); 245 origin_path_form_.display_name = base::ASCIIToUTF16("Display Name 2");
246 origin_path_form_.password_value = base::ASCIIToUTF16("Password 2"); 246 origin_path_form_.password_value = base::ASCIIToUTF16("Password 2");
247 origin_path_form_.origin = GURL("https://example.com/path"); 247 origin_path_form_.origin = GURL("https://example.com/path");
248 origin_path_form_.signon_realm = origin_path_form_.origin.spec(); 248 origin_path_form_.signon_realm = origin_path_form_.origin.spec();
249 origin_path_form_.scheme = autofill::PasswordForm::SCHEME_HTML; 249 origin_path_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
250 origin_path_form_.skip_zero_click = false; 250 origin_path_form_.skip_zero_click = false;
251 251
252 subdomain_form_.username_value = base::ASCIIToUTF16("Username 2");
253 subdomain_form_.display_name = base::ASCIIToUTF16("Display Name 2");
254 subdomain_form_.password_value = base::ASCIIToUTF16("Password 2");
255 subdomain_form_.origin = GURL("https://subdomain.example.com/path");
256 subdomain_form_.signon_realm = subdomain_form_.origin.spec();
257 subdomain_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
258 subdomain_form_.skip_zero_click = false;
259
252 cross_origin_form_.username_value = base::ASCIIToUTF16("Username"); 260 cross_origin_form_.username_value = base::ASCIIToUTF16("Username");
253 cross_origin_form_.display_name = base::ASCIIToUTF16("Display Name"); 261 cross_origin_form_.display_name = base::ASCIIToUTF16("Display Name");
254 cross_origin_form_.password_value = base::ASCIIToUTF16("Password"); 262 cross_origin_form_.password_value = base::ASCIIToUTF16("Password");
255 cross_origin_form_.origin = GURL("https://example.net/"); 263 cross_origin_form_.origin = GURL("https://example.net/");
256 cross_origin_form_.signon_realm = cross_origin_form_.origin.spec(); 264 cross_origin_form_.signon_realm = cross_origin_form_.origin.spec();
257 cross_origin_form_.scheme = autofill::PasswordForm::SCHEME_HTML; 265 cross_origin_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
258 cross_origin_form_.skip_zero_click = false; 266 cross_origin_form_.skip_zero_click = false;
259 267
260 store_->Clear(); 268 store_->Clear();
261 EXPECT_TRUE(store_->IsEmpty()); 269 EXPECT_TRUE(store_->IsEmpty());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 cm_service_impl_->Get(zero_click_only, include_passwords, 355 cm_service_impl_->Get(zero_click_only, include_passwords,
348 mojo::Array<mojo::String>::From(federations), 356 mojo::Array<mojo::String>::From(federations),
349 callback); 357 callback);
350 } 358 }
351 359
352 protected: 360 protected:
353 autofill::PasswordForm form_; 361 autofill::PasswordForm form_;
354 autofill::PasswordForm affiliated_form1_; 362 autofill::PasswordForm affiliated_form1_;
355 autofill::PasswordForm affiliated_form2_; 363 autofill::PasswordForm affiliated_form2_;
356 autofill::PasswordForm origin_path_form_; 364 autofill::PasswordForm origin_path_form_;
365 autofill::PasswordForm subdomain_form_;
357 autofill::PasswordForm cross_origin_form_; 366 autofill::PasswordForm cross_origin_form_;
358 scoped_refptr<TestPasswordStore> store_; 367 scoped_refptr<TestPasswordStore> store_;
359 std::unique_ptr<testing::NiceMock<MockPasswordManagerClient>> client_; 368 std::unique_ptr<testing::NiceMock<MockPasswordManagerClient>> client_;
360 std::unique_ptr<SlightlyLessStubbyPasswordManagerDriver> stub_driver_; 369 std::unique_ptr<SlightlyLessStubbyPasswordManagerDriver> stub_driver_;
361 std::unique_ptr<CredentialManagerImpl> cm_service_impl_; 370 std::unique_ptr<CredentialManagerImpl> cm_service_impl_;
362 }; 371 };
363 372
364 TEST_F(CredentialManagerImplTest, IsZeroClickAllowed) { 373 TEST_F(CredentialManagerImplTest, IsZeroClickAllowed) {
365 // IsZeroClickAllowed is uneffected by the first-run status. 374 // IsZeroClickAllowed is uneffected by the first-run status.
366 client_->set_zero_click_enabled(true); 375 client_->set_zero_click_enabled(true);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 CallStore(info, base::Bind(&RespondCallback, &called)); 542 CallStore(info, base::Bind(&RespondCallback, &called));
534 543
535 RunAllPendingTasks(); 544 RunAllPendingTasks();
536 545
537 EXPECT_TRUE(called); 546 EXPECT_TRUE(called);
538 EXPECT_FALSE(client_->pending_manager()); 547 EXPECT_FALSE(client_->pending_manager());
539 } 548 }
540 549
541 TEST_F(CredentialManagerImplTest, CredentialManagerOnRequireUserMediation) { 550 TEST_F(CredentialManagerImplTest, CredentialManagerOnRequireUserMediation) {
542 store_->AddLogin(form_); 551 store_->AddLogin(form_);
552 store_->AddLogin(subdomain_form_);
543 store_->AddLogin(cross_origin_form_); 553 store_->AddLogin(cross_origin_form_);
544 RunAllPendingTasks(); 554 RunAllPendingTasks();
545 555
546 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); 556 TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
547 EXPECT_EQ(2U, passwords.size()); 557 EXPECT_EQ(3U, passwords.size());
548 EXPECT_EQ(1U, passwords[form_.signon_realm].size()); 558 EXPECT_EQ(1U, passwords[form_.signon_realm].size());
559 EXPECT_EQ(1U, passwords[subdomain_form_.signon_realm].size());
549 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size()); 560 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size());
550 EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); 561 EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click);
562 EXPECT_FALSE(passwords[subdomain_form_.signon_realm][0].skip_zero_click);
551 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click); 563 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click);
552 564
553 bool called = false; 565 bool called = false;
554 CallRequireUserMediation(base::Bind(&RespondCallback, &called)); 566 CallRequireUserMediation(base::Bind(&RespondCallback, &called));
555 567
556 RunAllPendingTasks(); 568 RunAllPendingTasks();
557 569
558 EXPECT_TRUE(called); 570 EXPECT_TRUE(called);
559 571
560 passwords = store_->stored_passwords(); 572 passwords = store_->stored_passwords();
561 EXPECT_EQ(2U, passwords.size()); 573 EXPECT_EQ(3U, passwords.size());
562 EXPECT_EQ(1U, passwords[form_.signon_realm].size()); 574 EXPECT_EQ(1U, passwords[form_.signon_realm].size());
575 EXPECT_EQ(1U, passwords[subdomain_form_.signon_realm].size());
563 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size()); 576 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size());
564 EXPECT_TRUE(passwords[form_.signon_realm][0].skip_zero_click); 577 EXPECT_TRUE(passwords[form_.signon_realm][0].skip_zero_click);
578 EXPECT_TRUE(passwords[subdomain_form_.signon_realm][0].skip_zero_click);
565 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click); 579 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click);
566 } 580 }
567 581
568 TEST_F(CredentialManagerImplTest, 582 TEST_F(CredentialManagerImplTest,
569 CredentialManagerOnRequireUserMediationIncognito) { 583 CredentialManagerOnRequireUserMediationIncognito) {
570 EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true)); 584 EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true));
571 store_->AddLogin(form_); 585 store_->AddLogin(form_);
572 RunAllPendingTasks(); 586 RunAllPendingTasks();
573 587
574 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); 588 TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 TEST_F(CredentialManagerImplTest, GetSynthesizedFormForOrigin) { 1154 TEST_F(CredentialManagerImplTest, GetSynthesizedFormForOrigin) {
1141 autofill::PasswordForm synthesized = 1155 autofill::PasswordForm synthesized =
1142 cm_service_impl_->GetSynthesizedFormForOrigin(); 1156 cm_service_impl_->GetSynthesizedFormForOrigin();
1143 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec()); 1157 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec());
1144 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm); 1158 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm);
1145 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme); 1159 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme);
1146 EXPECT_TRUE(synthesized.ssl_valid); 1160 EXPECT_TRUE(synthesized.ssl_valid);
1147 } 1161 }
1148 1162
1149 } // namespace password_manager 1163 } // namespace password_manager
OLDNEW
« no previous file with comments | « no previous file | components/password_manager/core/browser/credential_manager_pending_require_user_mediation_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698