| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <stdarg.h> | 5 #include <stdarg.h> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 bool IsStringAttribute(const SecretSchema* schema, const std::string& name) { | 73 bool IsStringAttribute(const SecretSchema* schema, const std::string& name) { |
| 74 for (size_t i = 0; schema->attributes[i].name; ++i) | 74 for (size_t i = 0; schema->attributes[i].name; ++i) |
| 75 if (name == schema->attributes[i].name) | 75 if (name == schema->attributes[i].name) |
| 76 return schema->attributes[i].type == SECRET_SCHEMA_ATTRIBUTE_STRING; | 76 return schema->attributes[i].type == SECRET_SCHEMA_ATTRIBUTE_STRING; |
| 77 NOTREACHED() << "Requested type of nonexistent attribute"; | 77 NOTREACHED() << "Requested type of nonexistent attribute"; |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 | 80 |
| 81 // The list of all libsecret items we have stored. | 81 // The list of all libsecret items we have stored. |
| 82 std::vector<MockSecretItem*> global_mock_libsecret_items; | 82 ScopedVector<MockSecretItem>* global_mock_libsecret_items; |
| 83 bool global_mock_libsecret_reject_local_ids = false; | 83 bool global_mock_libsecret_reject_local_ids = false; |
| 84 | 84 |
| 85 void ClearMockObjects() { | |
| 86 for (size_t i = 0; i < global_mock_libsecret_items.size(); ++i) | |
| 87 delete global_mock_libsecret_items[i]; | |
| 88 global_mock_libsecret_items.clear(); | |
| 89 } | |
| 90 | |
| 91 gboolean mock_secret_password_store_sync(const SecretSchema* schema, | 85 gboolean mock_secret_password_store_sync(const SecretSchema* schema, |
| 92 const gchar* collection, | 86 const gchar* collection, |
| 93 const gchar* label, | 87 const gchar* label, |
| 94 const gchar* password, | 88 const gchar* password, |
| 95 GCancellable* cancellable, | 89 GCancellable* cancellable, |
| 96 GError** error, | 90 GError** error, |
| 97 ...) { | 91 ...) { |
| 98 GHashTable* attributes = | 92 GHashTable* attributes = |
| 99 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 93 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
| 100 va_list ap; | 94 va_list ap; |
| 101 va_start(ap, error); | 95 va_start(ap, error); |
| 102 char* name; | 96 char* name; |
| 103 while ((name = va_arg(ap, gchar*))) { | 97 while ((name = va_arg(ap, gchar*))) { |
| 104 char* value; | 98 char* value; |
| 105 if (IsStringAttribute(schema, name)) { | 99 if (IsStringAttribute(schema, name)) { |
| 106 value = g_strdup(va_arg(ap, gchar*)); | 100 value = g_strdup(va_arg(ap, gchar*)); |
| 107 VLOG(1) << "Adding item attribute " << name << ", value '" << value | 101 VLOG(1) << "Adding item attribute " << name << ", value '" << value |
| 108 << "'"; | 102 << "'"; |
| 109 } else { | 103 } else { |
| 110 uint32_t intvalue = va_arg(ap, uint32_t); | 104 uint32_t intvalue = va_arg(ap, uint32_t); |
| 111 VLOG(1) << "Adding item attribute " << name << ", value " << intvalue; | 105 VLOG(1) << "Adding item attribute " << name << ", value " << intvalue; |
| 112 value = g_strdup_printf("%u", intvalue); | 106 value = g_strdup_printf("%u", intvalue); |
| 113 } | 107 } |
| 114 g_hash_table_insert(attributes, g_strdup(name), value); | 108 g_hash_table_insert(attributes, g_strdup(name), value); |
| 115 } | 109 } |
| 116 va_end(ap); | 110 va_end(ap); |
| 117 MockSecretValue* secret_value = new MockSecretValue(g_strdup(password)); | 111 MockSecretValue* secret_value = new MockSecretValue(g_strdup(password)); |
| 118 MockSecretItem* item = new MockSecretItem(secret_value, attributes); | 112 MockSecretItem* item = new MockSecretItem(secret_value, attributes); |
| 119 global_mock_libsecret_items.push_back(item); | 113 global_mock_libsecret_items->push_back(item); |
| 120 return true; | 114 return true; |
| 121 } | 115 } |
| 122 | 116 |
| 123 GList* mock_secret_service_search_sync(SecretService* service, | 117 GList* mock_secret_service_search_sync(SecretService* service, |
| 124 const SecretSchema* schema, | 118 const SecretSchema* schema, |
| 125 GHashTable* attributes, | 119 GHashTable* attributes, |
| 126 SecretSearchFlags flags, | 120 SecretSearchFlags flags, |
| 127 GCancellable* cancellable, | 121 GCancellable* cancellable, |
| 128 GError** error) { | 122 GError** error) { |
| 129 GList* result = nullptr; | 123 GList* result = nullptr; |
| 130 for (uint32_t i = 0; i < global_mock_libsecret_items.size(); ++i) { | 124 for (MockSecretItem* item : *global_mock_libsecret_items) { |
| 131 if (Matches(global_mock_libsecret_items[i], attributes)) | 125 if (Matches(item, attributes)) |
| 132 result = g_list_append(result, global_mock_libsecret_items[i]); | 126 result = g_list_append(result, item); |
| 133 } | 127 } |
| 134 return result; | 128 return result; |
| 135 } | 129 } |
| 136 | 130 |
| 137 gboolean mock_secret_password_clear_sync(const SecretSchema* schema, | 131 gboolean mock_secret_password_clear_sync(const SecretSchema* schema, |
| 138 GCancellable* cancellable, | 132 GCancellable* cancellable, |
| 139 GError** error, | 133 GError** error, |
| 140 ...) { | 134 ...) { |
| 141 GHashTable* attributes = | 135 GHashTable* attributes = |
| 142 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 136 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
| 143 va_list ap; | 137 va_list ap; |
| 144 va_start(ap, error); | 138 va_start(ap, error); |
| 145 char* name; | 139 char* name; |
| 146 while ((name = va_arg(ap, gchar*))) { | 140 while ((name = va_arg(ap, gchar*))) { |
| 147 char* value; | 141 char* value; |
| 148 if (IsStringAttribute(schema, name)) { | 142 if (IsStringAttribute(schema, name)) { |
| 149 value = g_strdup(va_arg(ap, gchar*)); | 143 value = g_strdup(va_arg(ap, gchar*)); |
| 150 VLOG(1) << "Adding item attribute " << name << ", value '" << value | 144 VLOG(1) << "Adding item attribute " << name << ", value '" << value |
| 151 << "'"; | 145 << "'"; |
| 152 } else { | 146 } else { |
| 153 uint32_t intvalue = va_arg(ap, uint32_t); | 147 uint32_t intvalue = va_arg(ap, uint32_t); |
| 154 VLOG(1) << "Adding item attribute " << name << ", value " << intvalue; | 148 VLOG(1) << "Adding item attribute " << name << ", value " << intvalue; |
| 155 value = g_strdup_printf("%u", intvalue); | 149 value = g_strdup_printf("%u", intvalue); |
| 156 } | 150 } |
| 157 g_hash_table_insert(attributes, g_strdup(name), value); | 151 g_hash_table_insert(attributes, g_strdup(name), value); |
| 158 } | 152 } |
| 159 va_end(ap); | 153 va_end(ap); |
| 160 for (uint32_t i = 0; i < global_mock_libsecret_items.size();) | 154 for (uint32_t i = 0; i < global_mock_libsecret_items->size();) |
| 161 if (Matches(global_mock_libsecret_items[i], attributes)) { | 155 if (Matches((*global_mock_libsecret_items)[i], attributes)) { |
| 162 delete global_mock_libsecret_items[i]; | 156 global_mock_libsecret_items->erase(global_mock_libsecret_items->begin() + |
| 163 global_mock_libsecret_items.erase(global_mock_libsecret_items.begin() + | 157 i); |
| 164 i); | |
| 165 } else { | 158 } else { |
| 166 ++i; | 159 ++i; |
| 167 } | 160 } |
| 168 g_hash_table_unref(attributes); | 161 g_hash_table_unref(attributes); |
| 169 return true; | 162 return true; |
| 170 } | 163 } |
| 171 | 164 |
| 172 MockSecretValue* mock_secret_item_get_secret(MockSecretItem* self) { | 165 MockSecretValue* mock_secret_item_get_secret(MockSecretItem* self) { |
| 173 return self->value; | 166 return self->value; |
| 174 } | 167 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 205 secret_value_get_text = | 198 secret_value_get_text = |
| 206 (decltype(&::secret_value_get_text)) & mock_secret_value_get_text; | 199 (decltype(&::secret_value_get_text)) & mock_secret_value_get_text; |
| 207 secret_item_get_attributes = (decltype(&::secret_item_get_attributes)) & | 200 secret_item_get_attributes = (decltype(&::secret_item_get_attributes)) & |
| 208 mock_secret_item_get_attributes; | 201 mock_secret_item_get_attributes; |
| 209 secret_item_load_secret_sync = (decltype(&::secret_item_load_secret_sync)) & | 202 secret_item_load_secret_sync = (decltype(&::secret_item_load_secret_sync)) & |
| 210 mock_secret_item_load_secret_sync; | 203 mock_secret_item_load_secret_sync; |
| 211 secret_value_unref = | 204 secret_value_unref = |
| 212 (decltype(&::secret_value_unref)) & mock_secret_value_unref; | 205 (decltype(&::secret_value_unref)) & mock_secret_value_unref; |
| 213 libsecret_loaded = true; | 206 libsecret_loaded = true; |
| 214 // Reset the state of the mock library. | 207 // Reset the state of the mock library. |
| 215 ClearMockObjects(); | 208 global_mock_libsecret_items->clear(); |
| 216 global_mock_libsecret_reject_local_ids = false; | 209 global_mock_libsecret_reject_local_ids = false; |
| 217 return true; | 210 return true; |
| 218 } | 211 } |
| 219 }; | 212 }; |
| 220 | 213 |
| 221 void CheckPasswordChanges(const PasswordStoreChangeList& expected_list, | 214 void CheckPasswordChanges(const PasswordStoreChangeList& expected_list, |
| 222 const PasswordStoreChangeList& actual_list) { | 215 const PasswordStoreChangeList& actual_list) { |
| 223 ASSERT_EQ(expected_list.size(), actual_list.size()); | 216 ASSERT_EQ(expected_list.size(), actual_list.size()); |
| 224 for (size_t i = 0; i < expected_list.size(); ++i) { | 217 for (size_t i = 0; i < expected_list.size(); ++i) { |
| 225 EXPECT_EQ(expected_list[i].type(), actual_list[i].type()); | 218 EXPECT_EQ(expected_list[i].type(), actual_list[i].type()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 244 EXPECT_EQ(expected.date_synced, actual.date_synced); | 237 EXPECT_EQ(expected.date_synced, actual.date_synced); |
| 245 EXPECT_EQ(expected.display_name, actual.display_name); | 238 EXPECT_EQ(expected.display_name, actual.display_name); |
| 246 EXPECT_EQ(expected.avatar_url, actual.avatar_url); | 239 EXPECT_EQ(expected.avatar_url, actual.avatar_url); |
| 247 EXPECT_EQ(expected.federation_url, actual.federation_url); | 240 EXPECT_EQ(expected.federation_url, actual.federation_url); |
| 248 EXPECT_EQ(expected.skip_zero_click, actual.skip_zero_click); | 241 EXPECT_EQ(expected.skip_zero_click, actual.skip_zero_click); |
| 249 EXPECT_EQ(expected.generation_upload_status, | 242 EXPECT_EQ(expected.generation_upload_status, |
| 250 actual.generation_upload_status); | 243 actual.generation_upload_status); |
| 251 } | 244 } |
| 252 } | 245 } |
| 253 | 246 |
| 254 void CheckPasswordChangesWithResult(const PasswordStoreChangeList* expected, | |
| 255 const PasswordStoreChangeList* actual, | |
| 256 bool result) { | |
| 257 EXPECT_TRUE(result); | |
| 258 CheckPasswordChanges(*expected, *actual); | |
| 259 } | |
| 260 | |
| 261 } // anonymous namespace | 247 } // anonymous namespace |
| 262 | 248 |
| 263 class NativeBackendLibsecretTest : public testing::Test { | 249 class NativeBackendLibsecretTest : public testing::Test { |
| 264 protected: | 250 protected: |
| 265 enum UpdateType { // Used in CheckPSLUpdate(). | 251 enum UpdateType { // Used in CheckPSLUpdate(). |
| 266 UPDATE_BY_UPDATELOGIN, | 252 UPDATE_BY_UPDATELOGIN, |
| 267 UPDATE_BY_ADDLOGIN, | 253 UPDATE_BY_ADDLOGIN, |
| 268 }; | 254 }; |
| 269 enum RemoveBetweenMethod { // Used in CheckRemoveLoginsBetween(). | 255 enum RemoveBetweenMethod { // Used in CheckRemoveLoginsBetween(). |
| 270 CREATED, | 256 CREATED, |
| 271 SYNCED, | 257 SYNCED, |
| 272 }; | 258 }; |
| 273 | 259 |
| 274 NativeBackendLibsecretTest() {} | 260 NativeBackendLibsecretTest() {} |
| 275 | 261 |
| 276 void SetUp() override { | 262 void SetUp() override { |
| 263 ASSERT_FALSE(global_mock_libsecret_items); |
| 264 global_mock_libsecret_items = &mock_libsecret_items_; |
| 265 |
| 277 ASSERT_TRUE(MockLibsecretLoader::LoadMockLibsecret()); | 266 ASSERT_TRUE(MockLibsecretLoader::LoadMockLibsecret()); |
| 278 | 267 |
| 279 form_google_.origin = GURL("http://www.google.com/"); | 268 form_google_.origin = GURL("http://www.google.com/"); |
| 280 form_google_.action = GURL("http://www.google.com/login"); | 269 form_google_.action = GURL("http://www.google.com/login"); |
| 281 form_google_.username_element = UTF8ToUTF16("user"); | 270 form_google_.username_element = UTF8ToUTF16("user"); |
| 282 form_google_.username_value = UTF8ToUTF16("joeschmoe"); | 271 form_google_.username_value = UTF8ToUTF16("joeschmoe"); |
| 283 form_google_.password_element = UTF8ToUTF16("pass"); | 272 form_google_.password_element = UTF8ToUTF16("pass"); |
| 284 form_google_.password_value = UTF8ToUTF16("seekrit"); | 273 form_google_.password_value = UTF8ToUTF16("seekrit"); |
| 285 form_google_.submit_element = UTF8ToUTF16("submit"); | 274 form_google_.submit_element = UTF8ToUTF16("submit"); |
| 286 form_google_.signon_realm = "http://www.google.com/"; | 275 form_google_.signon_realm = "http://www.google.com/"; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 other_auth_.password_value = UTF8ToUTF16("pass"); | 314 other_auth_.password_value = UTF8ToUTF16("pass"); |
| 326 other_auth_.signon_realm = "http://www.example.com/Realm"; | 315 other_auth_.signon_realm = "http://www.example.com/Realm"; |
| 327 other_auth_.date_created = base::Time::Now(); | 316 other_auth_.date_created = base::Time::Now(); |
| 328 other_auth_.date_synced = base::Time::Now(); | 317 other_auth_.date_synced = base::Time::Now(); |
| 329 } | 318 } |
| 330 | 319 |
| 331 void TearDown() override { | 320 void TearDown() override { |
| 332 base::MessageLoop::current()->PostTask(FROM_HERE, | 321 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 333 base::MessageLoop::QuitClosure()); | 322 base::MessageLoop::QuitClosure()); |
| 334 base::MessageLoop::current()->Run(); | 323 base::MessageLoop::current()->Run(); |
| 335 ClearMockObjects(); | 324 ASSERT_TRUE(global_mock_libsecret_items); |
| 325 global_mock_libsecret_items = nullptr; |
| 336 } | 326 } |
| 337 | 327 |
| 338 void RunUIThread() { base::MessageLoop::current()->Run(); } | 328 void RunUIThread() { base::MessageLoop::current()->Run(); } |
| 339 | 329 |
| 340 void CheckUint32Attribute(const MockSecretItem* item, | 330 void CheckUint32Attribute(const MockSecretItem* item, |
| 341 const std::string& attribute, | 331 const std::string& attribute, |
| 342 uint32_t value) { | 332 uint32_t value) { |
| 343 gpointer item_value = | 333 gpointer item_value = |
| 344 g_hash_table_lookup(item->attributes, attribute.c_str()); | 334 g_hash_table_lookup(item->attributes, attribute.c_str()); |
| 345 EXPECT_TRUE(item_value) << " in attribute " << attribute; | 335 EXPECT_TRUE(item_value) << " in attribute " << attribute; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 if (scheme != PasswordForm::SCHEME_HTML) { | 405 if (scheme != PasswordForm::SCHEME_HTML) { |
| 416 // For non-HTML forms, the realm used for authentication | 406 // For non-HTML forms, the realm used for authentication |
| 417 // (http://tools.ietf.org/html/rfc1945#section-10.2) is appended to the | 407 // (http://tools.ietf.org/html/rfc1945#section-10.2) is appended to the |
| 418 // signon_realm. Just use a default value for now. | 408 // signon_realm. Just use a default value for now. |
| 419 target_form.signon_realm.append("Realm"); | 409 target_form.signon_realm.append("Realm"); |
| 420 target_form.scheme = scheme; | 410 target_form.scheme = scheme; |
| 421 } | 411 } |
| 422 ScopedVector<autofill::PasswordForm> form_list; | 412 ScopedVector<autofill::PasswordForm> form_list; |
| 423 backend.GetLogins(target_form, &form_list); | 413 backend.GetLogins(target_form, &form_list); |
| 424 | 414 |
| 425 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 415 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 426 if (global_mock_libsecret_items.size() > 0) | 416 if (!global_mock_libsecret_items->empty()) |
| 427 CheckMockSecretItem(global_mock_libsecret_items[0], credentials, | 417 CheckMockSecretItem((*global_mock_libsecret_items)[0], credentials, |
| 428 "chrome-321"); | 418 "chrome-321"); |
| 429 ClearMockObjects(); | 419 global_mock_libsecret_items->clear(); |
| 430 | 420 |
| 431 if (form_list.empty()) | 421 if (form_list.empty()) |
| 432 return false; | 422 return false; |
| 433 EXPECT_EQ(1u, form_list.size()); | 423 EXPECT_EQ(1u, form_list.size()); |
| 434 if (result) | 424 if (result) |
| 435 *result = *form_list[0]; | 425 *result = *form_list[0]; |
| 436 return true; | 426 return true; |
| 437 } | 427 } |
| 438 | 428 |
| 439 // Test that updating does not use PSL matching: Add a www.facebook.com | 429 // Test that updating does not use PSL matching: Add a www.facebook.com |
| 440 // password, then use PSL matching to get a copy of it for m.facebook.com, and | 430 // password, then use PSL matching to get a copy of it for m.facebook.com, and |
| 441 // add that copy as well. Now update the www.facebook.com password -- the | 431 // add that copy as well. Now update the www.facebook.com password -- the |
| 442 // m.facebook.com password should not get updated. Depending on the argument, | 432 // m.facebook.com password should not get updated. Depending on the argument, |
| 443 // the credential update is done via UpdateLogin or AddLogin. | 433 // the credential update is done via UpdateLogin or AddLogin. |
| 444 void CheckPSLUpdate(UpdateType update_type) { | 434 void CheckPSLUpdate(UpdateType update_type) { |
| 445 NativeBackendLibsecret backend(321); | 435 NativeBackendLibsecret backend(321); |
| 446 | 436 |
| 447 backend.AddLogin(form_facebook_); | 437 backend.AddLogin(form_facebook_); |
| 448 | 438 |
| 449 // Get the PSL-matched copy of the saved login for m.facebook. | 439 // Get the PSL-matched copy of the saved login for m.facebook. |
| 450 const GURL kMobileURL("http://m.facebook.com/"); | 440 const GURL kMobileURL("http://m.facebook.com/"); |
| 451 PasswordForm m_facebook_lookup; | 441 PasswordForm m_facebook_lookup; |
| 452 m_facebook_lookup.origin = kMobileURL; | 442 m_facebook_lookup.origin = kMobileURL; |
| 453 m_facebook_lookup.signon_realm = kMobileURL.spec(); | 443 m_facebook_lookup.signon_realm = kMobileURL.spec(); |
| 454 ScopedVector<autofill::PasswordForm> form_list; | 444 ScopedVector<autofill::PasswordForm> form_list; |
| 455 backend.GetLogins(m_facebook_lookup, &form_list); | 445 backend.GetLogins(m_facebook_lookup, &form_list); |
| 456 | 446 |
| 457 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 447 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 458 EXPECT_EQ(1u, form_list.size()); | 448 EXPECT_EQ(1u, form_list.size()); |
| 459 PasswordForm m_facebook = *form_list[0]; | 449 PasswordForm m_facebook = *form_list[0]; |
| 460 form_list.clear(); | 450 form_list.clear(); |
| 461 EXPECT_EQ(kMobileURL, m_facebook.origin); | 451 EXPECT_EQ(kMobileURL, m_facebook.origin); |
| 462 EXPECT_EQ(kMobileURL.spec(), m_facebook.signon_realm); | 452 EXPECT_EQ(kMobileURL.spec(), m_facebook.signon_realm); |
| 463 | 453 |
| 464 // Add the PSL-matched copy to saved logins. | 454 // Add the PSL-matched copy to saved logins. |
| 465 backend.AddLogin(m_facebook); | 455 backend.AddLogin(m_facebook); |
| 466 EXPECT_EQ(2u, global_mock_libsecret_items.size()); | 456 EXPECT_EQ(2u, global_mock_libsecret_items->size()); |
| 467 | 457 |
| 468 // Update www.facebook.com login. | 458 // Update www.facebook.com login. |
| 469 PasswordForm new_facebook(form_facebook_); | 459 PasswordForm new_facebook(form_facebook_); |
| 470 const base::string16 kOldPassword(form_facebook_.password_value); | 460 const base::string16 kOldPassword(form_facebook_.password_value); |
| 471 const base::string16 kNewPassword(UTF8ToUTF16("new_b")); | 461 const base::string16 kNewPassword(UTF8ToUTF16("new_b")); |
| 472 EXPECT_NE(kOldPassword, kNewPassword); | 462 EXPECT_NE(kOldPassword, kNewPassword); |
| 473 new_facebook.password_value = kNewPassword; | 463 new_facebook.password_value = kNewPassword; |
| 474 scoped_ptr<PasswordStoreChangeList> not_used(new PasswordStoreChangeList()); | 464 scoped_ptr<PasswordStoreChangeList> not_used(new PasswordStoreChangeList()); |
| 475 switch (update_type) { | 465 switch (update_type) { |
| 476 case UPDATE_BY_UPDATELOGIN: | 466 case UPDATE_BY_UPDATELOGIN: |
| 477 backend.UpdateLogin(new_facebook, not_used.get()); | 467 backend.UpdateLogin(new_facebook, not_used.get()); |
| 478 break; | 468 break; |
| 479 case UPDATE_BY_ADDLOGIN: | 469 case UPDATE_BY_ADDLOGIN: |
| 480 backend.AddLogin(new_facebook); | 470 backend.AddLogin(new_facebook); |
| 481 break; | 471 break; |
| 482 } | 472 } |
| 483 | 473 |
| 484 EXPECT_EQ(2u, global_mock_libsecret_items.size()); | 474 EXPECT_EQ(2u, global_mock_libsecret_items->size()); |
| 485 | 475 |
| 486 // Check that m.facebook.com login was not modified by the update. | 476 // Check that m.facebook.com login was not modified by the update. |
| 487 backend.GetLogins(m_facebook_lookup, &form_list); | 477 backend.GetLogins(m_facebook_lookup, &form_list); |
| 488 | 478 |
| 489 // There should be two results -- the exact one, and the PSL-matched one. | 479 // There should be two results -- the exact one, and the PSL-matched one. |
| 490 EXPECT_EQ(2u, form_list.size()); | 480 EXPECT_EQ(2u, form_list.size()); |
| 491 size_t index_non_psl = 0; | 481 size_t index_non_psl = 0; |
| 492 if (!form_list[index_non_psl]->original_signon_realm.empty()) | 482 if (!form_list[index_non_psl]->original_signon_realm.empty()) |
| 493 index_non_psl = 1; | 483 index_non_psl = 1; |
| 494 EXPECT_EQ(kMobileURL, form_list[index_non_psl]->origin); | 484 EXPECT_EQ(kMobileURL, form_list[index_non_psl]->origin); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 PasswordStoreChangeList expected_changes; | 543 PasswordStoreChangeList expected_changes; |
| 554 expected_changes.push_back( | 544 expected_changes.push_back( |
| 555 PasswordStoreChange(PasswordStoreChange::REMOVE, form_google_)); | 545 PasswordStoreChange(PasswordStoreChange::REMOVE, form_google_)); |
| 556 PasswordStoreChangeList changes; | 546 PasswordStoreChangeList changes; |
| 557 bool (NativeBackendLibsecret::*method)( | 547 bool (NativeBackendLibsecret::*method)( |
| 558 base::Time, base::Time, password_manager::PasswordStoreChangeList*) = | 548 base::Time, base::Time, password_manager::PasswordStoreChangeList*) = |
| 559 date_to_test == CREATED | 549 date_to_test == CREATED |
| 560 ? &NativeBackendLibsecret::RemoveLoginsCreatedBetween | 550 ? &NativeBackendLibsecret::RemoveLoginsCreatedBetween |
| 561 : &NativeBackendLibsecret::RemoveLoginsSyncedBetween; | 551 : &NativeBackendLibsecret::RemoveLoginsSyncedBetween; |
| 562 | 552 |
| 563 bool result = base::Bind(method, base::Unretained(&backend), base::Time(), | 553 EXPECT_TRUE(base::Bind(method, base::Unretained(&backend), base::Time(), |
| 564 next_day, &changes).Run(); | 554 next_day, &changes).Run()); |
| 565 CheckPasswordChangesWithResult(&expected_changes, &changes, result); | 555 CheckPasswordChanges(expected_changes, changes); |
| 566 | 556 |
| 567 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 557 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 568 if (global_mock_libsecret_items.size() > 0) | 558 if (!global_mock_libsecret_items->empty() > 0) |
| 569 CheckMockSecretItem(global_mock_libsecret_items[0], form_isc_, | 559 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_isc_, |
| 570 "chrome-42"); | 560 "chrome-42"); |
| 571 | 561 |
| 572 // Remove form_isc_. | 562 // Remove form_isc_. |
| 573 expected_changes.clear(); | 563 expected_changes.clear(); |
| 574 expected_changes.push_back( | 564 expected_changes.push_back( |
| 575 PasswordStoreChange(PasswordStoreChange::REMOVE, form_isc_)); | 565 PasswordStoreChange(PasswordStoreChange::REMOVE, form_isc_)); |
| 576 | 566 |
| 577 result = base::Bind(method, base::Unretained(&backend), next_day, | 567 EXPECT_TRUE(base::Bind(method, base::Unretained(&backend), next_day, |
| 578 base::Time(), &changes).Run(); | 568 base::Time(), &changes).Run()); |
| 579 CheckPasswordChangesWithResult(&expected_changes, &changes, result); | 569 CheckPasswordChanges(expected_changes, changes); |
| 580 | 570 |
| 581 EXPECT_EQ(0u, global_mock_libsecret_items.size()); | 571 EXPECT_TRUE(global_mock_libsecret_items->empty()); |
| 582 } | 572 } |
| 583 | 573 |
| 584 base::MessageLoopForUI message_loop_; | 574 base::MessageLoopForUI message_loop_; |
| 585 | 575 |
| 586 // Provide some test forms to avoid having to set them up in each test. | 576 // Provide some test forms to avoid having to set them up in each test. |
| 587 PasswordForm form_google_; | 577 PasswordForm form_google_; |
| 588 PasswordForm form_facebook_; | 578 PasswordForm form_facebook_; |
| 589 PasswordForm form_isc_; | 579 PasswordForm form_isc_; |
| 590 PasswordForm other_auth_; | 580 PasswordForm other_auth_; |
| 581 |
| 582 ScopedVector<MockSecretItem> mock_libsecret_items_; |
| 591 }; | 583 }; |
| 592 | 584 |
| 593 TEST_F(NativeBackendLibsecretTest, BasicAddLogin) { | 585 TEST_F(NativeBackendLibsecretTest, BasicAddLogin) { |
| 594 NativeBackendLibsecret backend(42); | 586 NativeBackendLibsecret backend(42); |
| 595 | 587 |
| 596 backend.AddLogin(form_google_); | 588 backend.AddLogin(form_google_); |
| 597 | 589 |
| 598 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 590 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 599 if (global_mock_libsecret_items.size() > 0) | 591 if (!global_mock_libsecret_items->empty()) |
| 600 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 592 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 601 "chrome-42"); | 593 "chrome-42"); |
| 602 } | 594 } |
| 603 | 595 |
| 604 TEST_F(NativeBackendLibsecretTest, BasicListLogins) { | 596 TEST_F(NativeBackendLibsecretTest, BasicListLogins) { |
| 605 NativeBackendLibsecret backend(42); | 597 NativeBackendLibsecret backend(42); |
| 606 | 598 |
| 607 backend.AddLogin(form_google_); | 599 backend.AddLogin(form_google_); |
| 608 | 600 |
| 609 ScopedVector<autofill::PasswordForm> form_list; | 601 ScopedVector<autofill::PasswordForm> form_list; |
| 610 backend.GetAutofillableLogins(&form_list); | 602 backend.GetAutofillableLogins(&form_list); |
| 611 | 603 |
| 612 // Quick check that we got something back. | 604 // Quick check that we got something back. |
| 613 EXPECT_EQ(1u, form_list.size()); | 605 EXPECT_EQ(1u, form_list.size()); |
| 614 form_list.clear(); | 606 form_list.clear(); |
| 615 | 607 |
| 616 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 608 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 617 if (global_mock_libsecret_items.size() > 0) | 609 if (!global_mock_libsecret_items->empty()) |
| 618 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 610 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 619 "chrome-42"); | 611 "chrome-42"); |
| 620 } | 612 } |
| 621 | 613 |
| 622 // Save a password for www.facebook.com and see it suggested for m.facebook.com. | 614 // Save a password for www.facebook.com and see it suggested for m.facebook.com. |
| 623 TEST_F(NativeBackendLibsecretTest, PSLMatchingPositive) { | 615 TEST_F(NativeBackendLibsecretTest, PSLMatchingPositive) { |
| 624 PasswordForm result; | 616 PasswordForm result; |
| 625 const GURL kMobileURL("http://m.facebook.com/"); | 617 const GURL kMobileURL("http://m.facebook.com/"); |
| 626 EXPECT_TRUE(CheckCredentialAvailability(form_facebook_, kMobileURL, | 618 EXPECT_TRUE(CheckCredentialAvailability(form_facebook_, kMobileURL, |
| 627 PasswordForm::SCHEME_HTML, &result)); | 619 PasswordForm::SCHEME_HTML, &result)); |
| 628 EXPECT_EQ(kMobileURL, result.origin); | 620 EXPECT_EQ(kMobileURL, result.origin); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 | 655 |
| 664 TEST_F(NativeBackendLibsecretTest, BasicUpdateLogin) { | 656 TEST_F(NativeBackendLibsecretTest, BasicUpdateLogin) { |
| 665 NativeBackendLibsecret backend(42); | 657 NativeBackendLibsecret backend(42); |
| 666 | 658 |
| 667 backend.AddLogin(form_google_); | 659 backend.AddLogin(form_google_); |
| 668 | 660 |
| 669 PasswordForm new_form_google(form_google_); | 661 PasswordForm new_form_google(form_google_); |
| 670 new_form_google.times_used = 1; | 662 new_form_google.times_used = 1; |
| 671 new_form_google.action = GURL("http://www.google.com/different/login"); | 663 new_form_google.action = GURL("http://www.google.com/different/login"); |
| 672 | 664 |
| 673 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 665 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 674 if (global_mock_libsecret_items.size() > 0) | 666 if (!global_mock_libsecret_items->empty()) |
| 675 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 667 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 676 "chrome-42"); | 668 "chrome-42"); |
| 677 | 669 |
| 678 // Update login | 670 // Update login |
| 679 PasswordStoreChangeList changes; | 671 PasswordStoreChangeList changes; |
| 680 backend.UpdateLogin(new_form_google, &changes); | 672 backend.UpdateLogin(new_form_google, &changes); |
| 681 | 673 |
| 682 ASSERT_EQ(1u, changes.size()); | 674 ASSERT_EQ(1u, changes.size()); |
| 683 EXPECT_EQ(PasswordStoreChange::UPDATE, changes.front().type()); | 675 EXPECT_EQ(PasswordStoreChange::UPDATE, changes.front().type()); |
| 684 EXPECT_EQ(new_form_google, changes.front().form()); | 676 EXPECT_EQ(new_form_google, changes.front().form()); |
| 685 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 677 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 686 if (global_mock_libsecret_items.size() > 0) | 678 if (!global_mock_libsecret_items->empty()) |
| 687 CheckMockSecretItem(global_mock_libsecret_items[0], new_form_google, | 679 CheckMockSecretItem((*global_mock_libsecret_items)[0], new_form_google, |
| 688 "chrome-42"); | 680 "chrome-42"); |
| 689 } | 681 } |
| 690 | 682 |
| 691 TEST_F(NativeBackendLibsecretTest, BasicRemoveLogin) { | 683 TEST_F(NativeBackendLibsecretTest, BasicRemoveLogin) { |
| 692 NativeBackendLibsecret backend(42); | 684 NativeBackendLibsecret backend(42); |
| 693 | 685 |
| 694 backend.AddLogin(form_google_); | 686 backend.AddLogin(form_google_); |
| 695 | 687 |
| 696 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 688 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 697 if (global_mock_libsecret_items.size() > 0) | 689 if (!global_mock_libsecret_items->empty()) |
| 698 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 690 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 699 "chrome-42"); | 691 "chrome-42"); |
| 700 | 692 |
| 701 backend.RemoveLogin(form_google_); | 693 backend.RemoveLogin(form_google_); |
| 702 | 694 |
| 703 EXPECT_EQ(0u, global_mock_libsecret_items.size()); | 695 EXPECT_TRUE(global_mock_libsecret_items->empty()); |
| 704 } | 696 } |
| 705 | 697 |
| 706 // Verify fix for http://crbug.com/408783. | 698 // Verify fix for http://crbug.com/408783. |
| 707 TEST_F(NativeBackendLibsecretTest, RemoveLoginActionMismatch) { | 699 TEST_F(NativeBackendLibsecretTest, RemoveLoginActionMismatch) { |
| 708 NativeBackendLibsecret backend(42); | 700 NativeBackendLibsecret backend(42); |
| 709 | 701 |
| 710 backend.AddLogin(form_google_); | 702 backend.AddLogin(form_google_); |
| 711 | 703 |
| 712 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 704 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 713 if (global_mock_libsecret_items.size() > 0) | 705 if (!global_mock_libsecret_items->empty()) |
| 714 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 706 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 715 "chrome-42"); | 707 "chrome-42"); |
| 716 | 708 |
| 717 // Action url match not required for removal. | 709 // Action url match not required for removal. |
| 718 form_google_.action = GURL("https://some.other.url.com/path"); | 710 form_google_.action = GURL("https://some.other.url.com/path"); |
| 719 | 711 |
| 720 backend.RemoveLogin(form_google_); | 712 backend.RemoveLogin(form_google_); |
| 721 | 713 |
| 722 EXPECT_EQ(0u, global_mock_libsecret_items.size()); | 714 EXPECT_TRUE(global_mock_libsecret_items->empty()); |
| 723 } | 715 } |
| 724 | 716 |
| 725 TEST_F(NativeBackendLibsecretTest, RemoveNonexistentLogin) { | 717 TEST_F(NativeBackendLibsecretTest, RemoveNonexistentLogin) { |
| 726 NativeBackendLibsecret backend(42); | 718 NativeBackendLibsecret backend(42); |
| 727 | 719 |
| 728 // First add an unrelated login. | 720 // First add an unrelated login. |
| 729 backend.AddLogin(form_google_); | 721 backend.AddLogin(form_google_); |
| 730 | 722 |
| 731 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 723 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 732 if (global_mock_libsecret_items.size() > 0) | 724 if (!global_mock_libsecret_items->empty()) |
| 733 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 725 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 734 "chrome-42"); | 726 "chrome-42"); |
| 735 | 727 |
| 736 // Attempt to remove a login that doesn't exist. | 728 // Attempt to remove a login that doesn't exist. |
| 737 backend.RemoveLogin(form_isc_); | 729 backend.RemoveLogin(form_isc_); |
| 738 | 730 |
| 739 // Make sure we can still get the first form back. | 731 // Make sure we can still get the first form back. |
| 740 ScopedVector<autofill::PasswordForm> form_list; | 732 ScopedVector<autofill::PasswordForm> form_list; |
| 741 backend.GetAutofillableLogins(&form_list); | 733 backend.GetAutofillableLogins(&form_list); |
| 742 | 734 |
| 743 // Quick check that we got something back. | 735 // Quick check that we got something back. |
| 744 EXPECT_EQ(1u, form_list.size()); | 736 EXPECT_EQ(1u, form_list.size()); |
| 745 form_list.clear(); | 737 form_list.clear(); |
| 746 | 738 |
| 747 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 739 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 748 if (global_mock_libsecret_items.size() > 0) | 740 if (!global_mock_libsecret_items->empty()) |
| 749 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 741 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 750 "chrome-42"); | 742 "chrome-42"); |
| 751 } | 743 } |
| 752 | 744 |
| 753 TEST_F(NativeBackendLibsecretTest, UpdateNonexistentLogin) { | 745 TEST_F(NativeBackendLibsecretTest, UpdateNonexistentLogin) { |
| 754 NativeBackendLibsecret backend(42); | 746 NativeBackendLibsecret backend(42); |
| 755 | 747 |
| 756 // First add an unrelated login. | 748 // First add an unrelated login. |
| 757 backend.AddLogin(form_google_); | 749 backend.AddLogin(form_google_); |
| 758 | 750 |
| 759 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 751 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 760 if (global_mock_libsecret_items.size() > 0) | 752 if (!global_mock_libsecret_items->empty()) |
| 761 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 753 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 762 "chrome-42"); | 754 "chrome-42"); |
| 763 | 755 |
| 764 // Attempt to update a login that doesn't exist. | 756 // Attempt to update a login that doesn't exist. |
| 765 PasswordStoreChangeList changes; | 757 PasswordStoreChangeList changes; |
| 766 backend.UpdateLogin(form_isc_, &changes); | 758 backend.UpdateLogin(form_isc_, &changes); |
| 767 | 759 |
| 768 EXPECT_EQ(PasswordStoreChangeList(), changes); | 760 EXPECT_EQ(PasswordStoreChangeList(), changes); |
| 769 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 761 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 770 if (global_mock_libsecret_items.size() > 0) | 762 if (!global_mock_libsecret_items->empty()) |
| 771 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 763 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 772 "chrome-42"); | 764 "chrome-42"); |
| 773 } | 765 } |
| 774 | 766 |
| 775 TEST_F(NativeBackendLibsecretTest, AddDuplicateLogin) { | 767 TEST_F(NativeBackendLibsecretTest, AddDuplicateLogin) { |
| 776 NativeBackendLibsecret backend(42); | 768 NativeBackendLibsecret backend(42); |
| 777 | 769 |
| 778 PasswordStoreChangeList expected_changes, actual_changes; | 770 PasswordStoreChangeList expected_changes, actual_changes; |
| 779 expected_changes.push_back( | 771 expected_changes.push_back( |
| 780 PasswordStoreChange(PasswordStoreChange::ADD, form_google_)); | 772 PasswordStoreChange(PasswordStoreChange::ADD, form_google_)); |
| 781 actual_changes = backend.AddLogin(form_google_); | 773 actual_changes = backend.AddLogin(form_google_); |
| 782 CheckPasswordChanges(expected_changes, actual_changes); | 774 CheckPasswordChanges(expected_changes, actual_changes); |
| 783 | 775 |
| 784 expected_changes.clear(); | 776 expected_changes.clear(); |
| 785 expected_changes.push_back( | 777 expected_changes.push_back( |
| 786 PasswordStoreChange(PasswordStoreChange::REMOVE, form_google_)); | 778 PasswordStoreChange(PasswordStoreChange::REMOVE, form_google_)); |
| 787 form_google_.times_used++; | 779 form_google_.times_used++; |
| 788 expected_changes.push_back( | 780 expected_changes.push_back( |
| 789 PasswordStoreChange(PasswordStoreChange::ADD, form_google_)); | 781 PasswordStoreChange(PasswordStoreChange::ADD, form_google_)); |
| 790 | 782 |
| 791 actual_changes = backend.AddLogin(form_google_); | 783 actual_changes = backend.AddLogin(form_google_); |
| 792 CheckPasswordChanges(expected_changes, actual_changes); | 784 CheckPasswordChanges(expected_changes, actual_changes); |
| 793 | 785 |
| 794 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 786 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 795 if (global_mock_libsecret_items.size() > 0) | 787 if (!global_mock_libsecret_items->empty()) |
| 796 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 788 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 797 "chrome-42"); | 789 "chrome-42"); |
| 798 } | 790 } |
| 799 | 791 |
| 800 TEST_F(NativeBackendLibsecretTest, ListLoginsAppends) { | 792 TEST_F(NativeBackendLibsecretTest, ListLoginsAppends) { |
| 801 NativeBackendLibsecret backend(42); | 793 NativeBackendLibsecret backend(42); |
| 802 | 794 |
| 803 backend.AddLogin(form_google_); | 795 backend.AddLogin(form_google_); |
| 804 | 796 |
| 805 // Send the same request twice with the same list both times. | 797 // Send the same request twice with the same list both times. |
| 806 ScopedVector<autofill::PasswordForm> form_list; | 798 ScopedVector<autofill::PasswordForm> form_list; |
| 807 backend.GetAutofillableLogins(&form_list); | 799 backend.GetAutofillableLogins(&form_list); |
| 808 backend.GetAutofillableLogins(&form_list); | 800 backend.GetAutofillableLogins(&form_list); |
| 809 | 801 |
| 810 // Quick check that we got two results back. | 802 // Quick check that we got two results back. |
| 811 EXPECT_EQ(2u, form_list.size()); | 803 EXPECT_EQ(2u, form_list.size()); |
| 812 form_list.clear(); | 804 form_list.clear(); |
| 813 | 805 |
| 814 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 806 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 815 if (global_mock_libsecret_items.size() > 0) | 807 if (!global_mock_libsecret_items->empty()) |
| 816 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 808 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
| 817 "chrome-42"); | 809 "chrome-42"); |
| 818 } | 810 } |
| 819 | 811 |
| 820 TEST_F(NativeBackendLibsecretTest, AndroidCredentials) { | 812 TEST_F(NativeBackendLibsecretTest, AndroidCredentials) { |
| 821 NativeBackendLibsecret backend(42); | 813 NativeBackendLibsecret backend(42); |
| 822 backend.Init(); | 814 backend.Init(); |
| 823 | 815 |
| 824 PasswordForm observed_android_form; | 816 PasswordForm observed_android_form; |
| 825 observed_android_form.scheme = PasswordForm::SCHEME_HTML; | 817 observed_android_form.scheme = PasswordForm::SCHEME_HTML; |
| 826 observed_android_form.signon_realm = | 818 observed_android_form.signon_realm = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 847 TEST_F(NativeBackendLibsecretTest, RemoveLoginsSyncedBetween) { | 839 TEST_F(NativeBackendLibsecretTest, RemoveLoginsSyncedBetween) { |
| 848 CheckRemoveLoginsBetween(SYNCED); | 840 CheckRemoveLoginsBetween(SYNCED); |
| 849 } | 841 } |
| 850 | 842 |
| 851 TEST_F(NativeBackendLibsecretTest, SomeKeyringAttributesAreMissing) { | 843 TEST_F(NativeBackendLibsecretTest, SomeKeyringAttributesAreMissing) { |
| 852 // Absent attributes should be filled with default values. | 844 // Absent attributes should be filled with default values. |
| 853 NativeBackendLibsecret backend(42); | 845 NativeBackendLibsecret backend(42); |
| 854 | 846 |
| 855 backend.AddLogin(form_google_); | 847 backend.AddLogin(form_google_); |
| 856 | 848 |
| 857 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 849 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
| 858 // Remove a string attribute. | 850 // Remove a string attribute. |
| 859 global_mock_libsecret_items[0]->RemoveAttribute("avatar_url"); | 851 (*global_mock_libsecret_items)[0]->RemoveAttribute("avatar_url"); |
| 860 // Remove an integer attribute. | 852 // Remove an integer attribute. |
| 861 global_mock_libsecret_items[0]->RemoveAttribute("ssl_valid"); | 853 (*global_mock_libsecret_items)[0]->RemoveAttribute("ssl_valid"); |
| 862 | 854 |
| 863 ScopedVector<autofill::PasswordForm> form_list; | 855 ScopedVector<autofill::PasswordForm> form_list; |
| 864 backend.GetAutofillableLogins(&form_list); | 856 backend.GetAutofillableLogins(&form_list); |
| 865 | 857 |
| 866 EXPECT_EQ(1u, form_list.size()); | 858 EXPECT_EQ(1u, form_list.size()); |
| 867 EXPECT_EQ(GURL(""), form_list[0]->avatar_url); | 859 EXPECT_EQ(GURL(""), form_list[0]->avatar_url); |
| 868 EXPECT_FALSE(form_list[0]->ssl_valid); | 860 EXPECT_FALSE(form_list[0]->ssl_valid); |
| 869 } | 861 } |
| 870 | 862 |
| 871 // TODO(mdm): add more basic tests here at some point. | 863 // TODO(mdm): add more basic tests here at some point. |
| OLD | NEW |