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

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

Issue 1942723002: CREDENTIAL: Tighten the behavior of 'requireUserMediation()' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
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_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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 affiliated_form2_.ssl_valid = true; 231 affiliated_form2_.ssl_valid = true;
232 232
233 origin_path_form_.username_value = base::ASCIIToUTF16("Username 2"); 233 origin_path_form_.username_value = base::ASCIIToUTF16("Username 2");
234 origin_path_form_.display_name = base::ASCIIToUTF16("Display Name 2"); 234 origin_path_form_.display_name = base::ASCIIToUTF16("Display Name 2");
235 origin_path_form_.password_value = base::ASCIIToUTF16("Password 2"); 235 origin_path_form_.password_value = base::ASCIIToUTF16("Password 2");
236 origin_path_form_.origin = GURL("https://example.com/path"); 236 origin_path_form_.origin = GURL("https://example.com/path");
237 origin_path_form_.signon_realm = origin_path_form_.origin.spec(); 237 origin_path_form_.signon_realm = origin_path_form_.origin.spec();
238 origin_path_form_.scheme = autofill::PasswordForm::SCHEME_HTML; 238 origin_path_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
239 origin_path_form_.skip_zero_click = false; 239 origin_path_form_.skip_zero_click = false;
240 240
241 subdomain_form_.username_value = base::ASCIIToUTF16("Username 2");
242 subdomain_form_.display_name = base::ASCIIToUTF16("Display Name 2");
243 subdomain_form_.password_value = base::ASCIIToUTF16("Password 2");
244 subdomain_form_.origin = GURL("https://subdomain.example.com/path");
245 subdomain_form_.signon_realm = subdomain_form_.origin.spec();
246 subdomain_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
247 subdomain_form_.skip_zero_click = false;
248
241 cross_origin_form_.username_value = base::ASCIIToUTF16("Username"); 249 cross_origin_form_.username_value = base::ASCIIToUTF16("Username");
242 cross_origin_form_.display_name = base::ASCIIToUTF16("Display Name"); 250 cross_origin_form_.display_name = base::ASCIIToUTF16("Display Name");
243 cross_origin_form_.password_value = base::ASCIIToUTF16("Password"); 251 cross_origin_form_.password_value = base::ASCIIToUTF16("Password");
244 cross_origin_form_.origin = GURL("https://example.net/"); 252 cross_origin_form_.origin = GURL("https://example.net/");
245 cross_origin_form_.signon_realm = cross_origin_form_.origin.spec(); 253 cross_origin_form_.signon_realm = cross_origin_form_.origin.spec();
246 cross_origin_form_.scheme = autofill::PasswordForm::SCHEME_HTML; 254 cross_origin_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
247 cross_origin_form_.skip_zero_click = false; 255 cross_origin_form_.skip_zero_click = false;
248 256
249 store_->Clear(); 257 store_->Clear();
250 EXPECT_TRUE(store_->IsEmpty()); 258 EXPECT_TRUE(store_->IsEmpty());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 EXPECT_EQ(type, std::get<1>(send_param).type); 300 EXPECT_EQ(type, std::get<1>(send_param).type);
293 } 301 }
294 302
295 CredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); } 303 CredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); }
296 304
297 protected: 305 protected:
298 autofill::PasswordForm form_; 306 autofill::PasswordForm form_;
299 autofill::PasswordForm affiliated_form1_; 307 autofill::PasswordForm affiliated_form1_;
300 autofill::PasswordForm affiliated_form2_; 308 autofill::PasswordForm affiliated_form2_;
301 autofill::PasswordForm origin_path_form_; 309 autofill::PasswordForm origin_path_form_;
310 autofill::PasswordForm subdomain_form_;
302 autofill::PasswordForm cross_origin_form_; 311 autofill::PasswordForm cross_origin_form_;
303 scoped_refptr<TestPasswordStore> store_; 312 scoped_refptr<TestPasswordStore> store_;
304 std::unique_ptr<testing::NiceMock<MockPasswordManagerClient>> client_; 313 std::unique_ptr<testing::NiceMock<MockPasswordManagerClient>> client_;
305 std::unique_ptr<SlightlyLessStubbyPasswordManagerDriver> stub_driver_; 314 std::unique_ptr<SlightlyLessStubbyPasswordManagerDriver> stub_driver_;
306 std::unique_ptr<CredentialManagerDispatcher> dispatcher_; 315 std::unique_ptr<CredentialManagerDispatcher> dispatcher_;
307 }; 316 };
308 317
309 TEST_F(CredentialManagerDispatcherTest, IsZeroClickAllowed) { 318 TEST_F(CredentialManagerDispatcherTest, IsZeroClickAllowed) {
310 // IsZeroClickAllowed is uneffected by the first-run status. 319 // IsZeroClickAllowed is uneffected by the first-run status.
311 client_->set_zero_click_enabled(true); 320 client_->set_zero_click_enabled(true);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 process()->sink().ClearMessages(); 499 process()->sink().ClearMessages();
491 500
492 RunAllPendingTasks(); 501 RunAllPendingTasks();
493 502
494 EXPECT_FALSE(client_->pending_manager()); 503 EXPECT_FALSE(client_->pending_manager());
495 } 504 }
496 505
497 TEST_F(CredentialManagerDispatcherTest, 506 TEST_F(CredentialManagerDispatcherTest,
498 CredentialManagerOnRequireUserMediation) { 507 CredentialManagerOnRequireUserMediation) {
499 store_->AddLogin(form_); 508 store_->AddLogin(form_);
509 store_->AddLogin(subdomain_form_);
500 store_->AddLogin(cross_origin_form_); 510 store_->AddLogin(cross_origin_form_);
501 RunAllPendingTasks(); 511 RunAllPendingTasks();
502 512
503 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); 513 TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
504 EXPECT_EQ(2U, passwords.size()); 514 EXPECT_EQ(3U, passwords.size());
505 EXPECT_EQ(1U, passwords[form_.signon_realm].size()); 515 EXPECT_EQ(1U, passwords[form_.signon_realm].size());
516 EXPECT_EQ(1U, passwords[subdomain_form_.signon_realm].size());
506 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size()); 517 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size());
507 EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); 518 EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click);
519 EXPECT_FALSE(passwords[subdomain_form_.signon_realm][0].skip_zero_click);
508 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click); 520 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click);
509 521
510 dispatcher()->OnRequireUserMediation(kRequestId); 522 dispatcher()->OnRequireUserMediation(kRequestId);
511 RunAllPendingTasks(); 523 RunAllPendingTasks();
512 524
513 const uint32_t kMsgID = 525 const uint32_t kMsgID =
514 CredentialManagerMsg_AcknowledgeRequireUserMediation::ID; 526 CredentialManagerMsg_AcknowledgeRequireUserMediation::ID;
515 const IPC::Message* message = 527 const IPC::Message* message =
516 process()->sink().GetFirstMessageMatching(kMsgID); 528 process()->sink().GetFirstMessageMatching(kMsgID);
517 EXPECT_TRUE(message); 529 EXPECT_TRUE(message);
518 process()->sink().ClearMessages(); 530 process()->sink().ClearMessages();
519 531
520 passwords = store_->stored_passwords(); 532 passwords = store_->stored_passwords();
521 EXPECT_EQ(2U, passwords.size()); 533 EXPECT_EQ(3U, passwords.size());
522 EXPECT_EQ(1U, passwords[form_.signon_realm].size()); 534 EXPECT_EQ(1U, passwords[form_.signon_realm].size());
535 EXPECT_EQ(1U, passwords[subdomain_form_.signon_realm].size());
523 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size()); 536 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size());
524 EXPECT_TRUE(passwords[form_.signon_realm][0].skip_zero_click); 537 EXPECT_TRUE(passwords[form_.signon_realm][0].skip_zero_click);
538 EXPECT_TRUE(passwords[subdomain_form_.signon_realm][0].skip_zero_click);
525 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click); 539 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click);
526 } 540 }
527 541
528 TEST_F(CredentialManagerDispatcherTest, 542 TEST_F(CredentialManagerDispatcherTest,
529 CredentialManagerOnRequireUserMediationIncognito) { 543 CredentialManagerOnRequireUserMediationIncognito) {
530 EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true)); 544 EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true));
531 store_->AddLogin(form_); 545 store_->AddLogin(form_);
532 RunAllPendingTasks(); 546 RunAllPendingTasks();
533 547
534 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); 548 TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) { 1196 TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) {
1183 autofill::PasswordForm synthesized = 1197 autofill::PasswordForm synthesized =
1184 dispatcher_->GetSynthesizedFormForOrigin(); 1198 dispatcher_->GetSynthesizedFormForOrigin();
1185 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec()); 1199 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec());
1186 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm); 1200 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm);
1187 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme); 1201 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme);
1188 EXPECT_TRUE(synthesized.ssl_valid); 1202 EXPECT_TRUE(synthesized.ssl_valid);
1189 } 1203 }
1190 1204
1191 } // namespace password_manager 1205 } // 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