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

Unified Diff: chrome/browser/password_manager/chrome_password_manager_client_unittest.cc

Issue 1260263002: Move ShouldFilterAutofillResult from ChromePasswordManagerClient to PasswordManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just rebased Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/password_manager/chrome_password_manager_client.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/chrome_password_manager_client_unittest.cc
diff --git a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc
index 04f82835b790b4040417afa2e39df62353811cdd..d6818ba59869150ec316cd1f6a8a401cef2ecae3 100644
--- a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc
+++ b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc
@@ -21,6 +21,7 @@
#include "components/password_manager/content/common/credential_manager_messages.h"
#include "components/password_manager/core/browser/log_receiver.h"
#include "components/password_manager/core/browser/password_manager_internals_service.h"
+#include "components/password_manager/core/browser/store_result_filter.h"
#include "components/password_manager/core/common/credential_manager_types.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/password_manager/core/common/password_manager_switches.h"
@@ -49,7 +50,6 @@ class MockLogReceiver : public password_manager::LogReceiver {
// http://crbug.com/474577.
class MockChromePasswordManagerClient : public ChromePasswordManagerClient {
public:
- MOCK_CONST_METHOD0(IsPasswordManagementEnabledForCurrentPage, bool());
MOCK_CONST_METHOD0(DidLastPageLoadEncounterSSLErrors, bool());
MOCK_CONST_METHOD2(IsSyncAccountCredential,
bool(const std::string& username,
@@ -59,8 +59,6 @@ class MockChromePasswordManagerClient : public ChromePasswordManagerClient {
: ChromePasswordManagerClient(web_contents, nullptr) {
ON_CALL(*this, DidLastPageLoadEncounterSSLErrors())
.WillByDefault(testing::Return(false));
- ON_CALL(*this, IsPasswordManagementEnabledForCurrentPage())
- .WillByDefault(testing::Return(true));
}
~MockChromePasswordManagerClient() override {}
@@ -238,61 +236,6 @@ TEST_F(ChromePasswordManagerClientTest, LogToAReceiver) {
EXPECT_FALSE(client->IsLoggingActive());
}
-TEST_F(ChromePasswordManagerClientTest, ShouldFilterAutofillResult_Reauth) {
- // Make client disallow only reauth requests.
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- command_line->AppendSwitch(
- password_manager::switches::kDisallowAutofillSyncCredentialForReauth);
- scoped_ptr<MockChromePasswordManagerClient> client(
- new MockChromePasswordManagerClient(web_contents()));
- autofill::PasswordForm form;
-
- EXPECT_CALL(*client, IsSyncAccountCredential(_, _))
- .WillRepeatedly(Return(false));
- NavigateAndCommit(
- GURL("https://accounts.google.com/login?rart=123&continue=blah"));
- EXPECT_FALSE(client->ShouldFilterAutofillResult(form));
-
- EXPECT_CALL(*client, IsSyncAccountCredential(_, _))
- .WillRepeatedly(Return(true));
- NavigateAndCommit(
- GURL("https://accounts.google.com/login?rart=123&continue=blah"));
- EXPECT_TRUE(client->ShouldFilterAutofillResult(form));
-
- // This counts as a reauth url, though a valid URL should have a value for
- // "rart"
- NavigateAndCommit(GURL("https://accounts.google.com/addlogin?rart"));
- EXPECT_TRUE(client->ShouldFilterAutofillResult(form));
-
- NavigateAndCommit(GURL("https://accounts.google.com/login?param=123"));
- EXPECT_FALSE(client->ShouldFilterAutofillResult(form));
-
- NavigateAndCommit(GURL("https://site.com/login?rart=678"));
- EXPECT_FALSE(client->ShouldFilterAutofillResult(form));
-}
-
-TEST_F(ChromePasswordManagerClientTest, ShouldFilterAutofillResult) {
- // Normally the client should allow any credentials through, even if they
- // are the sync credential.
- scoped_ptr<MockChromePasswordManagerClient> client(
- new MockChromePasswordManagerClient(web_contents()));
- autofill::PasswordForm form;
- EXPECT_CALL(*client, IsSyncAccountCredential(_, _))
- .WillRepeatedly(Return(true));
- NavigateAndCommit(GURL("https://accounts.google.com/Login"));
- EXPECT_FALSE(client->ShouldFilterAutofillResult(form));
-
- // Adding disallow switch should cause sync credential to be filtered.
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- command_line->AppendSwitch(
- password_manager::switches::kDisallowAutofillSyncCredential);
- client.reset(new MockChromePasswordManagerClient(web_contents()));
- EXPECT_CALL(*client, IsSyncAccountCredential(_, _))
- .WillRepeatedly(Return(true));
- NavigateAndCommit(GURL("https://accounts.google.com/Login"));
- EXPECT_TRUE(client->ShouldFilterAutofillResult(form));
-}
-
TEST_F(ChromePasswordManagerClientTest,
IsPasswordManagementEnabledForCurrentPage) {
ChromePasswordManagerClient* client = GetClient();
@@ -468,3 +411,25 @@ TEST_F(ChromePasswordManagerClientTest, IsSavingEnabledForCurrentPageTest) {
EXPECT_FALSE(client->IsSavingEnabledForCurrentPage());
profile()->ForceIncognito(false);
}
+
+TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL_Empty) {
+ EXPECT_EQ(GURL::EmptyGURL(), GetClient()->GetLastCommittedEntryURL());
+}
+
+TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL) {
+ GURL kUrl(
+ "https://accounts.google.com/ServiceLogin?continue="
+ "https://passwords.google.com/settings&rart=123");
+ NavigateAndCommit(kUrl);
+ EXPECT_EQ(kUrl, GetClient()->GetLastCommittedEntryURL());
+}
+
+TEST_F(ChromePasswordManagerClientTest, CreateStoreResulFilter) {
+ scoped_ptr<password_manager::StoreResultFilter> filter1 =
+ GetClient()->CreateStoreResultFilter();
+ scoped_ptr<password_manager::StoreResultFilter> filter2 =
+ GetClient()->CreateStoreResultFilter();
+ EXPECT_TRUE(filter1);
+ EXPECT_TRUE(filter2);
+ EXPECT_NE(filter1.get(), filter2.get());
+}
« no previous file with comments | « chrome/browser/password_manager/chrome_password_manager_client.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698