OLD | NEW |
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> |
| 8 |
7 #include <string> | 9 #include <string> |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/bind.h" | 12 #include "base/bind.h" |
11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/macros.h" |
12 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
13 #include "base/prefs/testing_pref_service.h" | 16 #include "base/prefs/testing_pref_service.h" |
14 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
15 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
16 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
17 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
18 #include "components/password_manager/content/common/credential_manager_messages
.h" | 21 #include "components/password_manager/content/common/credential_manager_messages
.h" |
19 #include "components/password_manager/core/browser/credential_manager_password_f
orm_manager.h" | 22 #include "components/password_manager/core/browser/credential_manager_password_f
orm_manager.h" |
20 #include "components/password_manager/core/browser/mock_affiliated_match_helper.
h" | 23 #include "components/password_manager/core/browser/mock_affiliated_match_helper.
h" |
21 #include "components/password_manager/core/browser/password_manager.h" | 24 #include "components/password_manager/core/browser/password_manager.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 240 } |
238 | 241 |
239 void ExpectZeroClickSignInFailure() { | 242 void ExpectZeroClickSignInFailure() { |
240 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 243 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
241 .Times(testing::Exactly(0)); | 244 .Times(testing::Exactly(0)); |
242 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)) | 245 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)) |
243 .Times(testing::Exactly(0)); | 246 .Times(testing::Exactly(0)); |
244 | 247 |
245 RunAllPendingTasks(); | 248 RunAllPendingTasks(); |
246 | 249 |
247 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 250 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
248 const IPC::Message* message = | 251 const IPC::Message* message = |
249 process()->sink().GetFirstMessageMatching(kMsgID); | 252 process()->sink().GetFirstMessageMatching(kMsgID); |
250 ASSERT_TRUE(message); | 253 ASSERT_TRUE(message); |
251 CredentialManagerMsg_SendCredential::Param send_param; | 254 CredentialManagerMsg_SendCredential::Param send_param; |
252 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 255 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
253 | 256 |
254 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, | 257 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, |
255 base::get<1>(send_param).type); | 258 base::get<1>(send_param).type); |
256 } | 259 } |
257 | 260 |
258 void ExpectZeroClickSignInSuccess() { | 261 void ExpectZeroClickSignInSuccess() { |
259 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 262 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
260 .Times(testing::Exactly(0)); | 263 .Times(testing::Exactly(0)); |
261 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)) | 264 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)) |
262 .Times(testing::Exactly(1)); | 265 .Times(testing::Exactly(1)); |
263 | 266 |
264 RunAllPendingTasks(); | 267 RunAllPendingTasks(); |
265 | 268 |
266 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 269 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
267 const IPC::Message* message = | 270 const IPC::Message* message = |
268 process()->sink().GetFirstMessageMatching(kMsgID); | 271 process()->sink().GetFirstMessageMatching(kMsgID); |
269 ASSERT_TRUE(message); | 272 ASSERT_TRUE(message); |
270 CredentialManagerMsg_SendCredential::Param send_param; | 273 CredentialManagerMsg_SendCredential::Param send_param; |
271 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 274 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
272 | 275 |
273 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_PASSWORD, | 276 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_PASSWORD, |
274 base::get<1>(send_param).type); | 277 base::get<1>(send_param).type); |
275 } | 278 } |
276 | 279 |
(...skipping 12 matching lines...) Expand all Loading... |
289 }; | 292 }; |
290 | 293 |
291 TEST_F(CredentialManagerDispatcherTest, CredentialManagerOnStore) { | 294 TEST_F(CredentialManagerDispatcherTest, CredentialManagerOnStore) { |
292 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); | 295 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
293 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( | 296 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( |
294 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) | 297 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) |
295 .Times(testing::Exactly(1)); | 298 .Times(testing::Exactly(1)); |
296 | 299 |
297 dispatcher()->OnStore(kRequestId, info); | 300 dispatcher()->OnStore(kRequestId, info); |
298 | 301 |
299 const uint32 kMsgID = CredentialManagerMsg_AcknowledgeStore::ID; | 302 const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID; |
300 const IPC::Message* message = | 303 const IPC::Message* message = |
301 process()->sink().GetFirstMessageMatching(kMsgID); | 304 process()->sink().GetFirstMessageMatching(kMsgID); |
302 EXPECT_TRUE(message); | 305 EXPECT_TRUE(message); |
303 process()->sink().ClearMessages(); | 306 process()->sink().ClearMessages(); |
304 | 307 |
305 // Allow the PasswordFormManager to talk to the password store, determine | 308 // Allow the PasswordFormManager to talk to the password store, determine |
306 // that the form is new, and set it as pending. | 309 // that the form is new, and set it as pending. |
307 RunAllPendingTasks(); | 310 RunAllPendingTasks(); |
308 | 311 |
309 EXPECT_TRUE(client_->pending_manager()->HasCompletedMatching()); | 312 EXPECT_TRUE(client_->pending_manager()->HasCompletedMatching()); |
(...skipping 16 matching lines...) Expand all Loading... |
326 // Calling 'OnStore' with a credential that matches |form_| should update | 329 // Calling 'OnStore' with a credential that matches |form_| should update |
327 // the password without prompting the user. | 330 // the password without prompting the user. |
328 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); | 331 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
329 info.password = base::ASCIIToUTF16("Totally new password."); | 332 info.password = base::ASCIIToUTF16("Totally new password."); |
330 dispatcher()->OnStore(kRequestId, info); | 333 dispatcher()->OnStore(kRequestId, info); |
331 | 334 |
332 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( | 335 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( |
333 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) | 336 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) |
334 .Times(testing::Exactly(0)); | 337 .Times(testing::Exactly(0)); |
335 | 338 |
336 const uint32 kMsgID = CredentialManagerMsg_AcknowledgeStore::ID; | 339 const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID; |
337 const IPC::Message* message = | 340 const IPC::Message* message = |
338 process()->sink().GetFirstMessageMatching(kMsgID); | 341 process()->sink().GetFirstMessageMatching(kMsgID); |
339 EXPECT_TRUE(message); | 342 EXPECT_TRUE(message); |
340 process()->sink().ClearMessages(); | 343 process()->sink().ClearMessages(); |
341 | 344 |
342 // Allow the PasswordFormManager to talk to the password store, determine | 345 // Allow the PasswordFormManager to talk to the password store, determine |
343 // the form is a match for an existing form, and update the PasswordStore. | 346 // the form is a match for an existing form, and update the PasswordStore. |
344 RunAllPendingTasks(); | 347 RunAllPendingTasks(); |
345 | 348 |
346 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); | 349 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 CredentialManagerSignInWithSavingDisabledForCurrentPage) { | 382 CredentialManagerSignInWithSavingDisabledForCurrentPage) { |
380 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); | 383 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
381 EXPECT_CALL(*client_, IsSavingAndFillingEnabledForCurrentPage()) | 384 EXPECT_CALL(*client_, IsSavingAndFillingEnabledForCurrentPage()) |
382 .WillRepeatedly(testing::Return(false)); | 385 .WillRepeatedly(testing::Return(false)); |
383 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( | 386 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( |
384 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) | 387 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) |
385 .Times(testing::Exactly(0)); | 388 .Times(testing::Exactly(0)); |
386 | 389 |
387 dispatcher()->OnStore(kRequestId, info); | 390 dispatcher()->OnStore(kRequestId, info); |
388 | 391 |
389 const uint32 kMsgID = CredentialManagerMsg_AcknowledgeStore::ID; | 392 const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID; |
390 const IPC::Message* message = | 393 const IPC::Message* message = |
391 process()->sink().GetFirstMessageMatching(kMsgID); | 394 process()->sink().GetFirstMessageMatching(kMsgID); |
392 EXPECT_TRUE(message); | 395 EXPECT_TRUE(message); |
393 process()->sink().ClearMessages(); | 396 process()->sink().ClearMessages(); |
394 | 397 |
395 RunAllPendingTasks(); | 398 RunAllPendingTasks(); |
396 | 399 |
397 EXPECT_FALSE(client_->pending_manager()); | 400 EXPECT_FALSE(client_->pending_manager()); |
398 } | 401 } |
399 | 402 |
400 TEST_F(CredentialManagerDispatcherTest, | 403 TEST_F(CredentialManagerDispatcherTest, |
401 CredentialManagerOnRequireUserMediation) { | 404 CredentialManagerOnRequireUserMediation) { |
402 store_->AddLogin(form_); | 405 store_->AddLogin(form_); |
403 store_->AddLogin(cross_origin_form_); | 406 store_->AddLogin(cross_origin_form_); |
404 RunAllPendingTasks(); | 407 RunAllPendingTasks(); |
405 | 408 |
406 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); | 409 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); |
407 EXPECT_EQ(2U, passwords.size()); | 410 EXPECT_EQ(2U, passwords.size()); |
408 EXPECT_EQ(1U, passwords[form_.signon_realm].size()); | 411 EXPECT_EQ(1U, passwords[form_.signon_realm].size()); |
409 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size()); | 412 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size()); |
410 EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); | 413 EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); |
411 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click); | 414 EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click); |
412 | 415 |
413 dispatcher()->OnRequireUserMediation(kRequestId); | 416 dispatcher()->OnRequireUserMediation(kRequestId); |
414 RunAllPendingTasks(); | 417 RunAllPendingTasks(); |
415 | 418 |
416 const uint32 kMsgID = | 419 const uint32_t kMsgID = |
417 CredentialManagerMsg_AcknowledgeRequireUserMediation::ID; | 420 CredentialManagerMsg_AcknowledgeRequireUserMediation::ID; |
418 const IPC::Message* message = | 421 const IPC::Message* message = |
419 process()->sink().GetFirstMessageMatching(kMsgID); | 422 process()->sink().GetFirstMessageMatching(kMsgID); |
420 EXPECT_TRUE(message); | 423 EXPECT_TRUE(message); |
421 process()->sink().ClearMessages(); | 424 process()->sink().ClearMessages(); |
422 | 425 |
423 passwords = store_->stored_passwords(); | 426 passwords = store_->stored_passwords(); |
424 EXPECT_EQ(2U, passwords.size()); | 427 EXPECT_EQ(2U, passwords.size()); |
425 EXPECT_EQ(1U, passwords[form_.signon_realm].size()); | 428 EXPECT_EQ(1U, passwords[form_.signon_realm].size()); |
426 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size()); | 429 EXPECT_EQ(1U, passwords[cross_origin_form_.signon_realm].size()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) | 474 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) |
472 .Times(testing::Exactly(0)); | 475 .Times(testing::Exactly(0)); |
473 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 476 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
474 .Times(testing::Exactly(0)); | 477 .Times(testing::Exactly(0)); |
475 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); | 478 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); |
476 | 479 |
477 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 480 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
478 | 481 |
479 RunAllPendingTasks(); | 482 RunAllPendingTasks(); |
480 | 483 |
481 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 484 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
482 const IPC::Message* message = | 485 const IPC::Message* message = |
483 process()->sink().GetFirstMessageMatching(kMsgID); | 486 process()->sink().GetFirstMessageMatching(kMsgID); |
484 EXPECT_TRUE(message); | 487 EXPECT_TRUE(message); |
485 CredentialManagerMsg_SendCredential::Param param; | 488 CredentialManagerMsg_SendCredential::Param param; |
486 CredentialManagerMsg_SendCredential::Read(message, ¶m); | 489 CredentialManagerMsg_SendCredential::Read(message, ¶m); |
487 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, base::get<1>(param).type); | 490 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, base::get<1>(param).type); |
488 process()->sink().ClearMessages(); | 491 process()->sink().ClearMessages(); |
489 } | 492 } |
490 | 493 |
491 TEST_F(CredentialManagerDispatcherTest, | 494 TEST_F(CredentialManagerDispatcherTest, |
492 CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) { | 495 CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) { |
493 store_->AddLogin(cross_origin_form_); | 496 store_->AddLogin(cross_origin_form_); |
494 | 497 |
495 std::vector<GURL> federations; | 498 std::vector<GURL> federations; |
496 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( | 499 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( |
497 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) | 500 _, CredentialSourceType::CREDENTIAL_SOURCE_API)) |
498 .Times(testing::Exactly(0)); | 501 .Times(testing::Exactly(0)); |
499 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 502 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
500 .Times(testing::Exactly(0)); | 503 .Times(testing::Exactly(0)); |
501 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); | 504 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); |
502 | 505 |
503 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 506 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
504 | 507 |
505 RunAllPendingTasks(); | 508 RunAllPendingTasks(); |
506 | 509 |
507 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 510 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
508 const IPC::Message* message = | 511 const IPC::Message* message = |
509 process()->sink().GetFirstMessageMatching(kMsgID); | 512 process()->sink().GetFirstMessageMatching(kMsgID); |
510 EXPECT_TRUE(message); | 513 EXPECT_TRUE(message); |
511 CredentialManagerMsg_SendCredential::Param param; | 514 CredentialManagerMsg_SendCredential::Param param; |
512 CredentialManagerMsg_SendCredential::Read(message, ¶m); | 515 CredentialManagerMsg_SendCredential::Read(message, ¶m); |
513 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, base::get<1>(param).type); | 516 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, base::get<1>(param).type); |
514 process()->sink().ClearMessages(); | 517 process()->sink().ClearMessages(); |
515 } | 518 } |
516 | 519 |
517 TEST_F(CredentialManagerDispatcherTest, | 520 TEST_F(CredentialManagerDispatcherTest, |
518 CredentialManagerOnRequestCredentialWithFullPasswordStore) { | 521 CredentialManagerOnRequestCredentialWithFullPasswordStore) { |
519 client_->set_zero_click_enabled(false); | 522 client_->set_zero_click_enabled(false); |
520 store_->AddLogin(form_); | 523 store_->AddLogin(form_); |
521 | 524 |
522 std::vector<GURL> federations; | 525 std::vector<GURL> federations; |
523 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 526 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
524 .Times(testing::Exactly(1)); | 527 .Times(testing::Exactly(1)); |
525 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); | 528 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); |
526 | 529 |
527 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 530 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
528 | 531 |
529 RunAllPendingTasks(); | 532 RunAllPendingTasks(); |
530 | 533 |
531 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 534 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
532 const IPC::Message* message = | 535 const IPC::Message* message = |
533 process()->sink().GetFirstMessageMatching(kMsgID); | 536 process()->sink().GetFirstMessageMatching(kMsgID); |
534 EXPECT_TRUE(message); | 537 EXPECT_TRUE(message); |
535 } | 538 } |
536 | 539 |
537 TEST_F( | 540 TEST_F( |
538 CredentialManagerDispatcherTest, | 541 CredentialManagerDispatcherTest, |
539 CredentialManagerOnRequestCredentialWithZeroClickOnlyEmptyPasswordStore) { | 542 CredentialManagerOnRequestCredentialWithZeroClickOnlyEmptyPasswordStore) { |
540 std::vector<GURL> federations; | 543 std::vector<GURL> federations; |
541 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 544 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
542 .Times(testing::Exactly(0)); | 545 .Times(testing::Exactly(0)); |
543 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); | 546 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); |
544 | 547 |
545 dispatcher()->OnRequestCredential(kRequestId, true, federations); | 548 dispatcher()->OnRequestCredential(kRequestId, true, federations); |
546 | 549 |
547 RunAllPendingTasks(); | 550 RunAllPendingTasks(); |
548 | 551 |
549 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 552 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
550 const IPC::Message* message = | 553 const IPC::Message* message = |
551 process()->sink().GetFirstMessageMatching(kMsgID); | 554 process()->sink().GetFirstMessageMatching(kMsgID); |
552 EXPECT_TRUE(message); | 555 EXPECT_TRUE(message); |
553 CredentialManagerMsg_SendCredential::Param send_param; | 556 CredentialManagerMsg_SendCredential::Param send_param; |
554 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 557 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
555 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, | 558 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, |
556 base::get<1>(send_param).type); | 559 base::get<1>(send_param).type); |
557 } | 560 } |
558 | 561 |
559 TEST_F(CredentialManagerDispatcherTest, | 562 TEST_F(CredentialManagerDispatcherTest, |
(...skipping 26 matching lines...) Expand all Loading... |
586 | 589 |
587 std::vector<GURL> federations; | 590 std::vector<GURL> federations; |
588 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 591 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
589 .Times(testing::Exactly(0)); | 592 .Times(testing::Exactly(0)); |
590 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); | 593 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); |
591 | 594 |
592 dispatcher()->OnRequestCredential(kRequestId, true, federations); | 595 dispatcher()->OnRequestCredential(kRequestId, true, federations); |
593 | 596 |
594 RunAllPendingTasks(); | 597 RunAllPendingTasks(); |
595 | 598 |
596 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 599 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
597 const IPC::Message* message = | 600 const IPC::Message* message = |
598 process()->sink().GetFirstMessageMatching(kMsgID); | 601 process()->sink().GetFirstMessageMatching(kMsgID); |
599 EXPECT_TRUE(message); | 602 EXPECT_TRUE(message); |
600 CredentialManagerMsg_SendCredential::Param send_param; | 603 CredentialManagerMsg_SendCredential::Param send_param; |
601 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 604 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
602 | 605 |
603 // With two items in the password store, we shouldn't get credentials back. | 606 // With two items in the password store, we shouldn't get credentials back. |
604 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, | 607 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, |
605 base::get<1>(send_param).type); | 608 base::get<1>(send_param).type); |
606 } | 609 } |
607 | 610 |
608 TEST_F(CredentialManagerDispatcherTest, | 611 TEST_F(CredentialManagerDispatcherTest, |
609 OnRequestCredentialWithZeroClickOnlyAndSkipZeroClickPasswordStore) { | 612 OnRequestCredentialWithZeroClickOnlyAndSkipZeroClickPasswordStore) { |
610 form_.skip_zero_click = true; | 613 form_.skip_zero_click = true; |
611 store_->AddLogin(form_); | 614 store_->AddLogin(form_); |
612 store_->AddLogin(origin_path_form_); | 615 store_->AddLogin(origin_path_form_); |
613 | 616 |
614 std::vector<GURL> federations; | 617 std::vector<GURL> federations; |
615 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 618 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
616 .Times(testing::Exactly(0)); | 619 .Times(testing::Exactly(0)); |
617 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); | 620 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); |
618 | 621 |
619 dispatcher()->OnRequestCredential(kRequestId, true, federations); | 622 dispatcher()->OnRequestCredential(kRequestId, true, federations); |
620 | 623 |
621 RunAllPendingTasks(); | 624 RunAllPendingTasks(); |
622 | 625 |
623 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 626 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
624 const IPC::Message* message = | 627 const IPC::Message* message = |
625 process()->sink().GetFirstMessageMatching(kMsgID); | 628 process()->sink().GetFirstMessageMatching(kMsgID); |
626 EXPECT_TRUE(message); | 629 EXPECT_TRUE(message); |
627 CredentialManagerMsg_SendCredential::Param send_param; | 630 CredentialManagerMsg_SendCredential::Param send_param; |
628 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 631 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
629 | 632 |
630 // With two items in the password store, we shouldn't get credentials back, | 633 // With two items in the password store, we shouldn't get credentials back, |
631 // even though only one item has |skip_zero_click| set |false|. | 634 // even though only one item has |skip_zero_click| set |false|. |
632 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, | 635 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, |
633 base::get<1>(send_param).type); | 636 base::get<1>(send_param).type); |
634 } | 637 } |
635 | 638 |
636 TEST_F(CredentialManagerDispatcherTest, | 639 TEST_F(CredentialManagerDispatcherTest, |
637 OnRequestCredentialWithZeroClickOnlyCrossOriginPasswordStore) { | 640 OnRequestCredentialWithZeroClickOnlyCrossOriginPasswordStore) { |
638 store_->AddLogin(cross_origin_form_); | 641 store_->AddLogin(cross_origin_form_); |
639 | 642 |
640 form_.skip_zero_click = true; | 643 form_.skip_zero_click = true; |
641 store_->AddLogin(form_); | 644 store_->AddLogin(form_); |
642 | 645 |
643 std::vector<GURL> federations; | 646 std::vector<GURL> federations; |
644 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 647 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
645 .Times(testing::Exactly(0)); | 648 .Times(testing::Exactly(0)); |
646 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); | 649 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); |
647 | 650 |
648 dispatcher()->OnRequestCredential(kRequestId, true, federations); | 651 dispatcher()->OnRequestCredential(kRequestId, true, federations); |
649 | 652 |
650 RunAllPendingTasks(); | 653 RunAllPendingTasks(); |
651 | 654 |
652 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 655 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
653 const IPC::Message* message = | 656 const IPC::Message* message = |
654 process()->sink().GetFirstMessageMatching(kMsgID); | 657 process()->sink().GetFirstMessageMatching(kMsgID); |
655 EXPECT_TRUE(message); | 658 EXPECT_TRUE(message); |
656 CredentialManagerMsg_SendCredential::Param send_param; | 659 CredentialManagerMsg_SendCredential::Param send_param; |
657 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 660 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
658 | 661 |
659 // We only have cross-origin zero-click credentials; they should not be | 662 // We only have cross-origin zero-click credentials; they should not be |
660 // returned. | 663 // returned. |
661 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, | 664 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, |
662 base::get<1>(send_param).type); | 665 base::get<1>(send_param).type); |
663 } | 666 } |
664 | 667 |
665 TEST_F(CredentialManagerDispatcherTest, | 668 TEST_F(CredentialManagerDispatcherTest, |
666 CredentialManagerOnRequestCredentialWhileRequestPending) { | 669 CredentialManagerOnRequestCredentialWhileRequestPending) { |
667 client_->set_zero_click_enabled(false); | 670 client_->set_zero_click_enabled(false); |
668 store_->AddLogin(form_); | 671 store_->AddLogin(form_); |
669 | 672 |
670 std::vector<GURL> federations; | 673 std::vector<GURL> federations; |
671 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 674 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
672 .Times(testing::Exactly(0)); | 675 .Times(testing::Exactly(0)); |
673 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); | 676 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); |
674 | 677 |
675 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 678 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
676 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 679 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
677 | 680 |
678 // Check that the second request triggered a rejection. | 681 // Check that the second request triggered a rejection. |
679 uint32 kMsgID = CredentialManagerMsg_RejectCredentialRequest::ID; | 682 uint32_t kMsgID = CredentialManagerMsg_RejectCredentialRequest::ID; |
680 const IPC::Message* message = | 683 const IPC::Message* message = |
681 process()->sink().GetFirstMessageMatching(kMsgID); | 684 process()->sink().GetFirstMessageMatching(kMsgID); |
682 EXPECT_TRUE(message); | 685 EXPECT_TRUE(message); |
683 | 686 |
684 CredentialManagerMsg_RejectCredentialRequest::Param reject_param; | 687 CredentialManagerMsg_RejectCredentialRequest::Param reject_param; |
685 CredentialManagerMsg_RejectCredentialRequest::Read(message, &reject_param); | 688 CredentialManagerMsg_RejectCredentialRequest::Read(message, &reject_param); |
686 EXPECT_EQ(blink::WebCredentialManagerPendingRequestError, | 689 EXPECT_EQ(blink::WebCredentialManagerPendingRequestError, |
687 base::get<1>(reject_param)); | 690 base::get<1>(reject_param)); |
688 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 691 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
689 .Times(testing::Exactly(1)); | 692 .Times(testing::Exactly(1)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 758 |
756 std::vector<GURL> federations; | 759 std::vector<GURL> federations; |
757 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) | 760 EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) |
758 .Times(testing::Exactly(0)); | 761 .Times(testing::Exactly(0)); |
759 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); | 762 EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); |
760 | 763 |
761 dispatcher()->OnRequestCredential(kRequestId, true, federations); | 764 dispatcher()->OnRequestCredential(kRequestId, true, federations); |
762 | 765 |
763 RunAllPendingTasks(); | 766 RunAllPendingTasks(); |
764 | 767 |
765 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 768 const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; |
766 const IPC::Message* message = | 769 const IPC::Message* message = |
767 process()->sink().GetFirstMessageMatching(kMsgID); | 770 process()->sink().GetFirstMessageMatching(kMsgID); |
768 ASSERT_TRUE(message); | 771 ASSERT_TRUE(message); |
769 CredentialManagerMsg_SendCredential::Param param; | 772 CredentialManagerMsg_SendCredential::Param param; |
770 CredentialManagerMsg_SendCredential::Read(message, ¶m); | 773 CredentialManagerMsg_SendCredential::Read(message, ¶m); |
771 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, base::get<1>(param).type); | 774 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, base::get<1>(param).type); |
772 } | 775 } |
773 | 776 |
774 TEST_F(CredentialManagerDispatcherTest, | 777 TEST_F(CredentialManagerDispatcherTest, |
775 ZeroClickWithAffiliatedFormInPasswordStore) { | 778 ZeroClickWithAffiliatedFormInPasswordStore) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) { | 861 TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) { |
859 autofill::PasswordForm synthesized = | 862 autofill::PasswordForm synthesized = |
860 dispatcher_->GetSynthesizedFormForOrigin(); | 863 dispatcher_->GetSynthesizedFormForOrigin(); |
861 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec()); | 864 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec()); |
862 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm); | 865 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm); |
863 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme); | 866 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme); |
864 EXPECT_TRUE(synthesized.ssl_valid); | 867 EXPECT_TRUE(synthesized.ssl_valid); |
865 } | 868 } |
866 | 869 |
867 } // namespace password_manager | 870 } // namespace password_manager |
OLD | NEW |