Commit fe723362 authored by Matthias Körber's avatar Matthias Körber Committed by Commit Bot

Removed unused methods from password_sync_util.

Change-Id: I37bd0562cd3b66147764c4edbe6c0c5d9c0ea52d
Bug: 875768
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824892
Auto-Submit: Matthias Körber <koerber@google.com>
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699815}
parent e427f7c9
......@@ -64,38 +64,6 @@ bool IsSyncAccountCredential(const autofill::PasswordForm& form,
GetSyncUsernameIfSyncingPasswords(sync_service, identity_manager));
}
bool ShouldSavePasswordHash(const autofill::PasswordForm& form,
const signin::IdentityManager* identity_manager,
PrefService* prefs) {
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
bool is_protected_credential_url =
gaia::IsGaiaSignonRealm(GURL(form.signon_realm)) ||
form.signon_realm == kGoogleChangePasswordSignonRealm ||
safe_browsing::MatchesPasswordProtectionLoginURL(form.origin, *prefs) ||
safe_browsing::MatchesPasswordProtectionChangePasswordURL(form.origin,
*prefs);
if (!is_protected_credential_url)
return false;
std::string sync_email = identity_manager->GetPrimaryAccountInfo().email;
std::string username = base::UTF16ToUTF8(form.username_value);
if (sync_email.empty() || username.empty())
return false;
// Add @domain.name to the username if it is absent.
std::string email =
username + (username.find('@') == std::string::npos
? "@" + gaia::ExtractDomainName(sync_email)
: std::string());
return email == sync_email;
#else
return false;
#endif // SYNC_PASSWORD_REUSE_DETECTION_ENABLED
}
bool IsSyncAccountEmail(const std::string& username,
const signin::IdentityManager* identity_manager) {
// |identity_manager| can be null if user is not signed in.
......
......@@ -34,12 +34,6 @@ bool IsSyncAccountCredential(const autofill::PasswordForm& form,
const syncer::SyncService* sync_service,
const signin::IdentityManager* identity_manager);
// If |form| doesn't match GAIA sign-on realm or enterprise-specified password
// protection URL, returns false. Otherwise, return true.
bool ShouldSavePasswordHash(const autofill::PasswordForm& form,
const signin::IdentityManager* identity_manager,
PrefService* prefs);
// If |username| matches sync account.
bool IsSyncAccountEmail(const std::string& username,
const signin::IdentityManager* identity_manager);
......
......@@ -149,58 +149,6 @@ class PasswordSyncUtilEnterpriseTest : public SyncUsernameTestBase {
TestingPrefServiceSimple prefs_;
};
TEST_F(PasswordSyncUtilEnterpriseTest, ShouldSavePasswordHash) {
prefs_.SetString(prefs::kPasswordProtectionChangePasswordURL,
"https://pwchange.mydomain.com/");
base::ListValue login_url;
login_url.AppendString("https://login.mydomain.com/");
prefs_.Set(prefs::kPasswordProtectionLoginURLs, login_url);
const struct {
PasswordForm form;
std::string fake_sync_username;
bool expected_result;
} kTestCases[] = {
{SimpleNonGaiaForm("sync_user@mydomain.com",
"https://pwchange.mydomain.com/"),
"sync_user@mydomain.com", true},
{SimpleNonGaiaForm("sync_user@mydomain.com",
"https://login.mydomain.com/"),
"sync_user@mydomain.com", true},
{SimpleNonGaiaForm("non_sync_user@mydomain.com",
"https://pwchange.mydomain.com/"),
"sync_user@mydomain.com", false},
{SimpleNonGaiaForm("non_sync_user@mydomain.com",
"https://login.mydomain.com/"),
"sync_user@mydomain.com", false},
{SimpleNonGaiaForm("sync_user", "https://pwchange.mydomain.com/"),
"sync_user@mydomain.com", true},
{SimpleNonGaiaForm("sync_user", "https://login.mydomain.com/"),
"sync_user@mydomain.com", true},
{SimpleNonGaiaForm("non_sync_user", "https://pwchange.mydomain.com/"),
"sync_user@mydomain.com", false},
{SimpleNonGaiaForm("non_sync_user", "https://login.mydomain.com/"),
"sync_user@mydomain.com", false},
{SimpleNonGaiaForm("", "https://pwchange.mydomain.com/"),
"sync_user@mydomain.com", false},
{SimpleNonGaiaForm("", "https://login.mydomain.com/"),
"sync_user@mydomain.com", false},
{SimpleNonGaiaForm("sync_user@mydomain.com", "https://otherdomain.com/"),
"sync_user@mydomain.com", false},
{SimpleNonGaiaForm("sync_user", "https://otherdomain.com/"),
"sync_user@mydomain.com", false},
};
for (bool syncing_passwords : {false, true}) {
for (size_t i = 0; i < base::size(kTestCases); ++i) {
SCOPED_TRACE(testing::Message() << "i=" << i);
SetSyncingPasswords(syncing_passwords);
FakeSigninAs(kTestCases[i].fake_sync_username);
EXPECT_EQ(kTestCases[i].expected_result,
ShouldSavePasswordHash(kTestCases[i].form, identity_manager(),
&prefs_));
}
}
}
#endif // SYNC_PASSWORD_REUSE_DETECTION_ENABLED
} // namespace sync_util
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment