Commit 6651993b authored by vasilii@chromium.org's avatar vasilii@chromium.org

LoginDatabase::Update should touch all the fields which are synced.

BUG=354210

Review URL: https://codereview.chromium.org/377223003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282340 0039d316-1c4b-4281-b951-d872f2087c98
parent 73da669d
...@@ -388,7 +388,11 @@ PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) { ...@@ -388,7 +388,11 @@ PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) {
"possible_usernames = ?, " "possible_usernames = ?, "
"times_used = ?, " "times_used = ?, "
"submit_element = ?, " "submit_element = ?, "
"date_synced = ? " "date_synced = ?, "
"date_created = ?, "
"blacklisted_by_user = ?, "
"scheme = ?, "
"password_type = ? "
"WHERE origin_url = ? AND " "WHERE origin_url = ? AND "
"username_element = ? AND " "username_element = ? AND "
"username_value = ? AND " "username_value = ? AND "
...@@ -404,12 +408,16 @@ PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) { ...@@ -404,12 +408,16 @@ PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) {
s.BindInt(5, form.times_used); s.BindInt(5, form.times_used);
s.BindString16(6, form.submit_element); s.BindString16(6, form.submit_element);
s.BindInt64(7, form.date_synced.ToInternalValue()); s.BindInt64(7, form.date_synced.ToInternalValue());
s.BindInt64(8, form.date_created.ToTimeT());
s.BindString(8, form.origin.spec()); s.BindInt(9, form.blacklisted_by_user);
s.BindString16(9, form.username_element); s.BindInt(10, form.scheme);
s.BindString16(10, form.username_value); s.BindInt(11, form.type);
s.BindString16(11, form.password_element);
s.BindString(12, form.signon_realm); s.BindString(12, form.origin.spec());
s.BindString16(13, form.username_element);
s.BindString16(14, form.username_value);
s.BindString16(15, form.password_element);
s.BindString(16, form.signon_realm);
if (!s.Run()) if (!s.Run())
return PasswordStoreChangeList(); return PasswordStoreChangeList();
......
...@@ -901,6 +901,45 @@ TEST_F(LoginDatabaseTest, DoubleAdd) { ...@@ -901,6 +901,45 @@ TEST_F(LoginDatabaseTest, DoubleAdd) {
EXPECT_EQ(list, db_.AddLogin(form)); EXPECT_EQ(list, db_.AddLogin(form));
} }
TEST_F(LoginDatabaseTest, UpdateLogin) {
PasswordForm form;
form.origin = GURL("http://accounts.google.com/LoginAuth");
form.signon_realm = "http://accounts.google.com/";
form.username_value = ASCIIToUTF16("my_username");
form.password_value = ASCIIToUTF16("my_password");
form.ssl_valid = false;
form.preferred = true;
form.blacklisted_by_user = false;
form.scheme = PasswordForm::SCHEME_HTML;
EXPECT_EQ(AddChangeForForm(form), db_.AddLogin(form));
form.action = GURL("http://accounts.google.com/login");
form.password_value = ASCIIToUTF16("my_new_password");
form.ssl_valid = true;
form.preferred = false;
form.other_possible_usernames.push_back(ASCIIToUTF16("my_new_username"));
form.times_used = 20;
form.submit_element = ASCIIToUTF16("submit_element");
form.date_synced = base::Time::Now();
form.date_created = base::Time::Now() - base::TimeDelta::FromDays(1);
// Remove this line after crbug/374132 is fixed.
form.date_created = base::Time::FromTimeT(form.date_created.ToTimeT());
form.blacklisted_by_user = true;
form.scheme = PasswordForm::SCHEME_BASIC;
form.type = PasswordForm::TYPE_GENERATED;
EXPECT_EQ(UpdateChangeForForm(form), db_.UpdateLogin(form));
ScopedVector<autofill::PasswordForm> result;
EXPECT_TRUE(db_.GetLogins(form, &result.get()));
ASSERT_EQ(1U, result.size());
#if defined(OS_MACOSX) && !defined(OS_IOS)
// On Mac, passwords are not stored in login database, instead they're in
// the keychain.
form.password_value.clear();
#endif // OS_MACOSX && !OS_IOS
EXPECT_EQ(form, *result[0]);
}
#if defined(OS_POSIX) #if defined(OS_POSIX)
// Only the current user has permission to read the database. // Only the current user has permission to read the database.
// //
......
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