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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc

Issue 1723583004: CREDENTIAL: Convert federations from URLs to origins throughout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iOS2 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 <utility> 5 #include <utility>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // |test_web_contents_|, and will be retrieved correctly via 199 // |test_web_contents_|, and will be retrieved correctly via
200 // ManagePasswordsUIController::FromWebContents in |controller()|. 200 // ManagePasswordsUIController::FromWebContents in |controller()|.
201 new TestManagePasswordsUIController(web_contents(), &client_); 201 new TestManagePasswordsUIController(web_contents(), &client_);
202 202
203 test_local_form_.origin = GURL("http://example.com/login"); 203 test_local_form_.origin = GURL("http://example.com/login");
204 test_local_form_.username_value = base::ASCIIToUTF16("username"); 204 test_local_form_.username_value = base::ASCIIToUTF16("username");
205 test_local_form_.password_value = base::ASCIIToUTF16("12345"); 205 test_local_form_.password_value = base::ASCIIToUTF16("12345");
206 206
207 test_federated_form_.origin = GURL("http://example.com/login"); 207 test_federated_form_.origin = GURL("http://example.com/login");
208 test_federated_form_.username_value = base::ASCIIToUTF16("username"); 208 test_federated_form_.username_value = base::ASCIIToUTF16("username");
209 test_federated_form_.federation_url = GURL("https://federation.test/"); 209 test_federated_form_.federation_origin =
210 url::Origin(GURL("https://federation.test/"));
210 211
211 // We need to be on a "webby" URL for most tests. 212 // We need to be on a "webby" URL for most tests.
212 content::WebContentsTester::For(web_contents()) 213 content::WebContentsTester::For(web_contents())
213 ->NavigateAndCommit(GURL("http://example.com")); 214 ->NavigateAndCommit(GURL("http://example.com"));
214 } 215 }
215 216
216 void ManagePasswordsUIControllerTest::ExpectIconStateIs( 217 void ManagePasswordsUIControllerTest::ExpectIconStateIs(
217 password_manager::ui::State state) { 218 password_manager::ui::State state) {
218 TestManagePasswordsIconView view; 219 TestManagePasswordsIconView view;
219 controller()->UpdateIconAndBubbleState(&view); 220 controller()->UpdateIconAndBubbleState(&view);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE); 489 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE);
489 490
490 EXPECT_CALL(dialog_prompt(), ControllerGone()); 491 EXPECT_CALL(dialog_prompt(), ControllerGone());
491 dialog_controller->OnChooseCredentials( 492 dialog_controller->OnChooseCredentials(
492 *dialog_controller->GetLocalForms()[0], 493 *dialog_controller->GetLocalForms()[0],
493 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); 494 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD);
494 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState()); 495 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState());
495 ASSERT_TRUE(credential_info()); 496 ASSERT_TRUE(credential_info());
496 EXPECT_EQ(test_local_form().username_value, credential_info()->id); 497 EXPECT_EQ(test_local_form().username_value, credential_info()->id);
497 EXPECT_EQ(test_local_form().password_value, credential_info()->password); 498 EXPECT_EQ(test_local_form().password_value, credential_info()->password);
498 EXPECT_TRUE(credential_info()->federation.is_empty()); 499 EXPECT_TRUE(credential_info()->federation.unique());
499 EXPECT_EQ(password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD, 500 EXPECT_EQ(password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD,
500 credential_info()->type); 501 credential_info()->type);
501 } 502 }
502 503
503 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialLocalButFederated) { 504 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialLocalButFederated) {
504 ScopedVector<autofill::PasswordForm> local_credentials; 505 ScopedVector<autofill::PasswordForm> local_credentials;
505 local_credentials.push_back( 506 local_credentials.push_back(
506 new autofill::PasswordForm(test_federated_form())); 507 new autofill::PasswordForm(test_federated_form()));
507 ScopedVector<autofill::PasswordForm> federated_credentials; 508 ScopedVector<autofill::PasswordForm> federated_credentials;
508 GURL origin("http://example.com"); 509 GURL origin("http://example.com");
(...skipping 15 matching lines...) Expand all
524 EXPECT_THAT(dialog_controller->GetFederationsForms(), testing::IsEmpty()); 525 EXPECT_THAT(dialog_controller->GetFederationsForms(), testing::IsEmpty());
525 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE); 526 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE);
526 527
527 EXPECT_CALL(dialog_prompt(), ControllerGone()); 528 EXPECT_CALL(dialog_prompt(), ControllerGone());
528 dialog_controller->OnChooseCredentials( 529 dialog_controller->OnChooseCredentials(
529 *dialog_controller->GetLocalForms()[0], 530 *dialog_controller->GetLocalForms()[0],
530 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); 531 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD);
531 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState()); 532 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState());
532 ASSERT_TRUE(credential_info()); 533 ASSERT_TRUE(credential_info());
533 EXPECT_EQ(test_federated_form().username_value, credential_info()->id); 534 EXPECT_EQ(test_federated_form().username_value, credential_info()->id);
534 EXPECT_EQ(test_federated_form().federation_url, 535 EXPECT_EQ(test_federated_form().federation_origin,
535 credential_info()->federation); 536 credential_info()->federation);
536 EXPECT_TRUE(credential_info()->password.empty()); 537 EXPECT_TRUE(credential_info()->password.empty());
537 EXPECT_EQ(password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED, 538 EXPECT_EQ(password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED,
538 credential_info()->type); 539 credential_info()->type);
539 } 540 }
540 541
541 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialFederated) { 542 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialFederated) {
542 ScopedVector<autofill::PasswordForm> local_credentials; 543 ScopedVector<autofill::PasswordForm> local_credentials;
543 ScopedVector<autofill::PasswordForm> federated_credentials; 544 ScopedVector<autofill::PasswordForm> federated_credentials;
544 federated_credentials.push_back( 545 federated_credentials.push_back(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback, 589 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback,
589 base::Unretained(this)))); 590 base::Unretained(this))));
590 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, 591 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE,
591 controller()->GetState()); 592 controller()->GetState());
592 EXPECT_EQ(origin, controller()->GetOrigin()); 593 EXPECT_EQ(origin, controller()->GetOrigin());
593 594
594 EXPECT_CALL(dialog_prompt(), ControllerGone()).Times(0); 595 EXPECT_CALL(dialog_prompt(), ControllerGone()).Times(0);
595 dialog_controller->OnCloseDialog(); 596 dialog_controller->OnCloseDialog();
596 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState()); 597 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState());
597 ASSERT_TRUE(credential_info()); 598 ASSERT_TRUE(credential_info());
598 EXPECT_TRUE(credential_info()->federation.is_empty()); 599 EXPECT_TRUE(credential_info()->federation.unique());
599 EXPECT_TRUE(credential_info()->password.empty()); 600 EXPECT_TRUE(credential_info()->password.empty());
600 EXPECT_EQ(password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY, 601 EXPECT_EQ(password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY,
601 credential_info()->type); 602 credential_info()->type);
602 } 603 }
603 604
604 TEST_F(ManagePasswordsUIControllerTest, AutoSignin) { 605 TEST_F(ManagePasswordsUIControllerTest, AutoSignin) {
605 ScopedVector<autofill::PasswordForm> local_credentials; 606 ScopedVector<autofill::PasswordForm> local_credentials;
606 local_credentials.push_back(new autofill::PasswordForm(test_local_form())); 607 local_credentials.push_back(new autofill::PasswordForm(test_local_form()));
607 controller()->OnAutoSignin(std::move(local_credentials)); 608 controller()->OnAutoSignin(std::move(local_credentials));
608 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState()); 609 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState());
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 CreateFormManager()); 707 CreateFormManager());
707 test_form_manager->ProvisionallySave( 708 test_form_manager->ProvisionallySave(
708 test_local_form(), 709 test_local_form(),
709 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); 710 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
710 controller()->OnUpdatePasswordSubmitted(std::move(test_form_manager)); 711 controller()->OnUpdatePasswordSubmitted(std::move(test_form_manager));
711 712
712 ExpectIconStateIs(password_manager::ui::PENDING_PASSWORD_UPDATE_STATE); 713 ExpectIconStateIs(password_manager::ui::PENDING_PASSWORD_UPDATE_STATE);
713 controller()->UpdatePassword(autofill::PasswordForm()); 714 controller()->UpdatePassword(autofill::PasswordForm());
714 ExpectIconStateIs(password_manager::ui::MANAGE_STATE); 715 ExpectIconStateIs(password_manager::ui::MANAGE_STATE);
715 } 716 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698