| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/sync/test/integration/passwords_helper.h" | 6 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
| 7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| 8 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 8 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
| 9 #include "chrome/browser/sync/test/integration/sync_test.h" | 9 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 10 #include "sync/internal_api/public/engine/model_safe_worker.h" | 10 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 11 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 11 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 12 | 12 |
| 13 using passwords_helper::AddLogin; | 13 using passwords_helper::AddLogin; |
| 14 using passwords_helper::AllProfilesContainSamePasswordForms; | 14 using passwords_helper::AllProfilesContainSamePasswordForms; |
| 15 using passwords_helper::AllProfilesContainSamePasswordFormsAsVerifier; | 15 using passwords_helper::AllProfilesContainSamePasswordFormsAsVerifier; |
| 16 using passwords_helper::AwaitAllProfilesContainSamePasswordForms; |
| 17 using passwords_helper::AwaitProfileContainsSamePasswordFormsAsVerifier; |
| 16 using passwords_helper::CreateTestPasswordForm; | 18 using passwords_helper::CreateTestPasswordForm; |
| 17 using passwords_helper::GetPasswordCount; | 19 using passwords_helper::GetPasswordCount; |
| 18 using passwords_helper::GetPasswordStore; | 20 using passwords_helper::GetPasswordStore; |
| 19 using passwords_helper::GetVerifierPasswordCount; | 21 using passwords_helper::GetVerifierPasswordCount; |
| 20 using passwords_helper::GetVerifierPasswordStore; | 22 using passwords_helper::GetVerifierPasswordStore; |
| 21 using passwords_helper::ProfileContainsSamePasswordFormsAsVerifier; | |
| 22 using passwords_helper::RemoveLogin; | 23 using passwords_helper::RemoveLogin; |
| 23 using passwords_helper::RemoveLogins; | 24 using passwords_helper::RemoveLogins; |
| 24 using passwords_helper::SetDecryptionPassphrase; | 25 using passwords_helper::SetDecryptionPassphrase; |
| 25 using passwords_helper::SetEncryptionPassphrase; | 26 using passwords_helper::SetEncryptionPassphrase; |
| 26 using passwords_helper::UpdateLogin; | 27 using passwords_helper::UpdateLogin; |
| 27 using sync_integration_test_util::AwaitCommitActivityCompletion; | |
| 28 using sync_integration_test_util::AwaitPassphraseAccepted; | 28 using sync_integration_test_util::AwaitPassphraseAccepted; |
| 29 using sync_integration_test_util::AwaitPassphraseRequired; | 29 using sync_integration_test_util::AwaitPassphraseRequired; |
| 30 | 30 |
| 31 using autofill::PasswordForm; | 31 using autofill::PasswordForm; |
| 32 | 32 |
| 33 static const char* kValidPassphrase = "passphrase!"; | 33 static const char* kValidPassphrase = "passphrase!"; |
| 34 static const char* kAnotherValidPassphrase = "another passphrase!"; | |
| 35 | 34 |
| 36 class TwoClientPasswordsSyncTest : public SyncTest { | 35 class TwoClientPasswordsSyncTest : public SyncTest { |
| 37 public: | 36 public: |
| 38 TwoClientPasswordsSyncTest() : SyncTest(TWO_CLIENT) {} | 37 TwoClientPasswordsSyncTest() : SyncTest(TWO_CLIENT) {} |
| 39 virtual ~TwoClientPasswordsSyncTest() {} | 38 virtual ~TwoClientPasswordsSyncTest() {} |
| 40 | 39 |
| 40 virtual bool TestUsesSelfNotifications() OVERRIDE { return false; } |
| 41 |
| 41 private: | 42 private: |
| 42 DISALLOW_COPY_AND_ASSIGN(TwoClientPasswordsSyncTest); | 43 DISALLOW_COPY_AND_ASSIGN(TwoClientPasswordsSyncTest); |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 class LegacyTwoClientPasswordsSyncTest : public SyncTest { | 46 class LegacyTwoClientPasswordsSyncTest : public SyncTest { |
| 46 public: | 47 public: |
| 47 LegacyTwoClientPasswordsSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {} | 48 LegacyTwoClientPasswordsSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {} |
| 48 virtual ~LegacyTwoClientPasswordsSyncTest() {} | 49 virtual ~LegacyTwoClientPasswordsSyncTest() {} |
| 49 | 50 |
| 50 private: | 51 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(LegacyTwoClientPasswordsSyncTest); | 52 DISALLOW_COPY_AND_ASSIGN(LegacyTwoClientPasswordsSyncTest); |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 // TCM ID - 3732277 | 55 // TCM ID - 3732277 |
| 55 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Add) { | 56 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Add) { |
| 56 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 57 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 57 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | 58 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); |
| 58 | 59 |
| 59 PasswordForm form = CreateTestPasswordForm(0); | 60 PasswordForm form = CreateTestPasswordForm(0); |
| 60 AddLogin(GetVerifierPasswordStore(), form); | 61 AddLogin(GetVerifierPasswordStore(), form); |
| 61 ASSERT_EQ(1, GetVerifierPasswordCount()); | 62 ASSERT_EQ(1, GetVerifierPasswordCount()); |
| 62 AddLogin(GetPasswordStore(0), form); | 63 AddLogin(GetPasswordStore(0), form); |
| 63 ASSERT_EQ(1, GetPasswordCount(0)); | 64 ASSERT_EQ(1, GetPasswordCount(0)); |
| 64 | 65 |
| 65 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 66 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); |
| 66 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | |
| 67 } | 67 } |
| 68 | 68 |
| 69 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Race) { | 69 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Race) { |
| 70 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 70 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 71 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | 71 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); |
| 72 | 72 |
| 73 PasswordForm form0 = CreateTestPasswordForm(0); | 73 PasswordForm form0 = CreateTestPasswordForm(0); |
| 74 AddLogin(GetPasswordStore(0), form0); | 74 AddLogin(GetPasswordStore(0), form0); |
| 75 | 75 |
| 76 PasswordForm form1 = form0; | 76 PasswordForm form1 = form0; |
| 77 form1.password_value = base::ASCIIToUTF16("new_password"); | 77 form1.password_value = base::ASCIIToUTF16("new_password"); |
| 78 AddLogin(GetPasswordStore(1), form1); | 78 AddLogin(GetPasswordStore(1), form1); |
| 79 | 79 |
| 80 ASSERT_TRUE(AwaitQuiescence()); | 80 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); |
| 81 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | |
| 82 } | |
| 83 | |
| 84 // TCM ID - 4577932. | |
| 85 IN_PROC_BROWSER_TEST_F(LegacyTwoClientPasswordsSyncTest, DisablePasswords) { | |
| 86 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 87 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | |
| 88 | |
| 89 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::PASSWORDS)); | |
| 90 PasswordForm form = CreateTestPasswordForm(0); | |
| 91 AddLogin(GetVerifierPasswordStore(), form); | |
| 92 ASSERT_EQ(1, GetVerifierPasswordCount()); | |
| 93 AddLogin(GetPasswordStore(0), form); | |
| 94 ASSERT_EQ(1, GetPasswordCount(0)); | |
| 95 | |
| 96 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | |
| 97 ASSERT_TRUE(ProfileContainsSamePasswordFormsAsVerifier(0)); | |
| 98 ASSERT_FALSE(ProfileContainsSamePasswordFormsAsVerifier(1)); | |
| 99 | |
| 100 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::PASSWORDS)); | |
| 101 ASSERT_TRUE(AwaitQuiescence()); | |
| 102 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | |
| 103 ASSERT_EQ(1, GetPasswordCount(1)); | |
| 104 } | |
| 105 | |
| 106 // TCM ID - 4649281. | |
| 107 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, DisableSync) { | |
| 108 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 109 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | |
| 110 | |
| 111 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); | |
| 112 PasswordForm form = CreateTestPasswordForm(0); | |
| 113 AddLogin(GetVerifierPasswordStore(), form); | |
| 114 ASSERT_EQ(1, GetVerifierPasswordCount()); | |
| 115 AddLogin(GetPasswordStore(0), form); | |
| 116 ASSERT_EQ(1, GetPasswordCount(0)); | |
| 117 | |
| 118 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | |
| 119 ASSERT_TRUE(ProfileContainsSamePasswordFormsAsVerifier(0)); | |
| 120 ASSERT_FALSE(ProfileContainsSamePasswordFormsAsVerifier(1)); | |
| 121 | |
| 122 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); | |
| 123 ASSERT_TRUE(AwaitQuiescence()); | |
| 124 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | |
| 125 ASSERT_EQ(1, GetPasswordCount(1)); | |
| 126 } | |
| 127 | |
| 128 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, SetPassphrase) { | |
| 129 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 130 | |
| 131 SetEncryptionPassphrase(0, kValidPassphrase, ProfileSyncService::EXPLICIT); | |
| 132 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((0)))); | |
| 133 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
| 134 | |
| 135 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); | |
| 136 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); | |
| 137 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1)))); | |
| 138 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((1)))); | |
| 139 } | 81 } |
| 140 | 82 |
| 141 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, | 83 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, |
| 142 SetPassphraseAndAddPassword) { | 84 SetPassphraseAndAddPassword) { |
| 143 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 85 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 144 | 86 |
| 145 SetEncryptionPassphrase(0, kValidPassphrase, ProfileSyncService::EXPLICIT); | 87 SetEncryptionPassphrase(0, kValidPassphrase, ProfileSyncService::EXPLICIT); |
| 146 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((0)))); | 88 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((0)))); |
| 147 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
| 148 | 89 |
| 149 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); | 90 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); |
| 150 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); | 91 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); |
| 151 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1)))); | 92 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1)))); |
| 152 | 93 |
| 153 PasswordForm form = CreateTestPasswordForm(0); | 94 PasswordForm form = CreateTestPasswordForm(0); |
| 154 AddLogin(GetPasswordStore(0), form); | 95 AddLogin(GetPasswordStore(0), form); |
| 155 ASSERT_EQ(1, GetPasswordCount(0)); | 96 ASSERT_EQ(1, GetPasswordCount(0)); |
| 156 | 97 |
| 157 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 98 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); |
| 158 ASSERT_EQ(1, GetPasswordCount(1)); | |
| 159 } | 99 } |
| 160 | 100 |
| 161 // TCM ID - 4603879 | 101 // TCM ID - 4603879 |
| 162 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Update) { | 102 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Update) { |
| 163 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 103 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 164 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | 104 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); |
| 165 | 105 |
| 166 PasswordForm form = CreateTestPasswordForm(0); | 106 PasswordForm form = CreateTestPasswordForm(0); |
| 167 AddLogin(GetVerifierPasswordStore(), form); | 107 AddLogin(GetVerifierPasswordStore(), form); |
| 168 AddLogin(GetPasswordStore(0), form); | 108 AddLogin(GetPasswordStore(0), form); |
| 169 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 109 |
| 110 // Wait for client 0 to commit and client 1 to receive the update. |
| 111 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(1)); |
| 170 | 112 |
| 171 form.password_value = base::ASCIIToUTF16("new_password"); | 113 form.password_value = base::ASCIIToUTF16("new_password"); |
| 172 UpdateLogin(GetVerifierPasswordStore(), form); | 114 UpdateLogin(GetVerifierPasswordStore(), form); |
| 173 UpdateLogin(GetPasswordStore(1), form); | 115 UpdateLogin(GetPasswordStore(1), form); |
| 174 ASSERT_TRUE(AwaitQuiescence()); | 116 ASSERT_EQ(1, GetVerifierPasswordCount()); |
| 175 | 117 |
| 176 ASSERT_EQ(1, GetVerifierPasswordCount()); | 118 // Wait for client 1 to commit and client 0 to receive the update. |
| 119 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0)); |
| 177 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | 120 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); |
| 178 } | 121 } |
| 179 | 122 |
| 180 // TCM ID - 3719309 | 123 // TCM ID - 3719309 |
| 181 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Delete) { | 124 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Delete) { |
| 182 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 125 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 183 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | 126 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); |
| 184 | 127 |
| 185 PasswordForm form0 = CreateTestPasswordForm(0); | 128 PasswordForm form0 = CreateTestPasswordForm(0); |
| 186 AddLogin(GetVerifierPasswordStore(), form0); | 129 AddLogin(GetVerifierPasswordStore(), form0); |
| 187 AddLogin(GetPasswordStore(0), form0); | 130 AddLogin(GetPasswordStore(0), form0); |
| 188 PasswordForm form1 = CreateTestPasswordForm(1); | 131 PasswordForm form1 = CreateTestPasswordForm(1); |
| 189 AddLogin(GetVerifierPasswordStore(), form1); | 132 AddLogin(GetVerifierPasswordStore(), form1); |
| 190 AddLogin(GetPasswordStore(0), form1); | 133 AddLogin(GetPasswordStore(0), form1); |
| 191 ASSERT_TRUE(AwaitQuiescence()); | 134 |
| 135 // Wait for client 0 to commit and client 1 to receive the update. |
| 136 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(1)); |
| 192 | 137 |
| 193 RemoveLogin(GetPasswordStore(1), form0); | 138 RemoveLogin(GetPasswordStore(1), form0); |
| 194 RemoveLogin(GetVerifierPasswordStore(), form0); | 139 RemoveLogin(GetVerifierPasswordStore(), form0); |
| 195 ASSERT_TRUE(AwaitQuiescence()); | 140 ASSERT_EQ(1, GetVerifierPasswordCount()); |
| 196 | 141 |
| 197 ASSERT_EQ(1, GetVerifierPasswordCount()); | 142 // Wait for deletion from client 1 to propagate. |
| 143 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0)); |
| 198 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | 144 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); |
| 199 } | 145 } |
| 200 | 146 |
| 201 // TCM ID - 7573511 | 147 // TCM ID - 7573511 |
| 202 // Flaky on Mac and Windows: http://crbug.com/111399 | 148 // Flaky on Mac and Windows: http://crbug.com/111399 |
| 203 #if defined(OS_WIN) || defined(OS_MACOSX) | 149 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 204 #define MAYBE_DeleteAll DISABLED_DeleteAll | 150 #define MAYBE_DeleteAll DISABLED_DeleteAll |
| 205 #else | 151 #else |
| 206 #define MAYBE_DeleteAll DeleteAll | 152 #define MAYBE_DeleteAll DeleteAll |
| 207 #endif | 153 #endif |
| 208 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, MAYBE_DeleteAll) { | 154 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, MAYBE_DeleteAll) { |
| 209 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 155 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 210 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | 156 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); |
| 211 | 157 |
| 212 PasswordForm form0 = CreateTestPasswordForm(0); | 158 PasswordForm form0 = CreateTestPasswordForm(0); |
| 213 AddLogin(GetVerifierPasswordStore(), form0); | 159 AddLogin(GetVerifierPasswordStore(), form0); |
| 214 AddLogin(GetPasswordStore(0), form0); | 160 AddLogin(GetPasswordStore(0), form0); |
| 215 PasswordForm form1 = CreateTestPasswordForm(1); | 161 PasswordForm form1 = CreateTestPasswordForm(1); |
| 216 AddLogin(GetVerifierPasswordStore(), form1); | 162 AddLogin(GetVerifierPasswordStore(), form1); |
| 217 AddLogin(GetPasswordStore(0), form1); | 163 AddLogin(GetPasswordStore(0), form1); |
| 218 ASSERT_TRUE(AwaitQuiescence()); | 164 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(1)); |
| 165 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); |
| 219 | 166 |
| 220 RemoveLogins(GetPasswordStore(1)); | 167 RemoveLogins(GetPasswordStore(1)); |
| 221 RemoveLogins(GetVerifierPasswordStore()); | 168 RemoveLogins(GetVerifierPasswordStore()); |
| 222 ASSERT_TRUE(AwaitQuiescence()); | 169 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0)); |
| 223 | 170 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); |
| 224 ASSERT_EQ(0, GetVerifierPasswordCount()); | 171 ASSERT_EQ(0, GetVerifierPasswordCount()); |
| 225 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | |
| 226 } | 172 } |
| 227 | 173 |
| 228 // TCM ID - 3694311 | 174 // TCM ID - 3694311 |
| 229 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Merge) { | 175 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Merge) { |
| 230 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 176 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 231 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | 177 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); |
| 232 | 178 |
| 233 PasswordForm form0 = CreateTestPasswordForm(0); | 179 PasswordForm form0 = CreateTestPasswordForm(0); |
| 234 AddLogin(GetPasswordStore(0), form0); | 180 AddLogin(GetPasswordStore(0), form0); |
| 235 PasswordForm form1 = CreateTestPasswordForm(1); | 181 PasswordForm form1 = CreateTestPasswordForm(1); |
| 236 AddLogin(GetPasswordStore(1), form1); | 182 AddLogin(GetPasswordStore(1), form1); |
| 237 PasswordForm form2 = CreateTestPasswordForm(2); | 183 PasswordForm form2 = CreateTestPasswordForm(2); |
| 238 AddLogin(GetPasswordStore(1), form2); | 184 AddLogin(GetPasswordStore(1), form2); |
| 239 ASSERT_TRUE(AwaitQuiescence()); | |
| 240 | 185 |
| 186 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); |
| 241 ASSERT_EQ(3, GetPasswordCount(0)); | 187 ASSERT_EQ(3, GetPasswordCount(0)); |
| 242 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | |
| 243 } | 188 } |
| 244 | |
| 245 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, | |
| 246 SetPassphraseAndThenSetupSync) { | |
| 247 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
| 248 | |
| 249 ASSERT_TRUE(GetClient(0)->SetupSync()); | |
| 250 SetEncryptionPassphrase(0, kValidPassphrase, ProfileSyncService::EXPLICIT); | |
| 251 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((0)))); | |
| 252 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | |
| 253 | |
| 254 ASSERT_FALSE(GetClient(1)->SetupSync()); | |
| 255 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); | |
| 256 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); | |
| 257 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1)))); | |
| 258 | |
| 259 // For some reason, the tests won't pass unless these flags are set. | |
| 260 GetSyncService((1))->SetSetupInProgress(false); | |
| 261 GetSyncService((1))->SetSyncSetupCompleted(); | |
| 262 | |
| 263 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((1)))); | |
| 264 | |
| 265 // Following ensures types are enabled and active (see bug 87572). | |
| 266 syncer::ModelSafeRoutingInfo routes; | |
| 267 GetSyncService((0))->GetModelSafeRoutingInfo(&routes); | |
| 268 ASSERT_EQ(syncer::GROUP_PASSWORD, routes[syncer::PASSWORDS]); | |
| 269 routes.clear(); | |
| 270 GetSyncService((1))->GetModelSafeRoutingInfo(&routes); | |
| 271 ASSERT_EQ(syncer::GROUP_PASSWORD, routes[syncer::PASSWORDS]); | |
| 272 } | |
| 273 | |
| 274 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, | |
| 275 SetDifferentPassphraseAndThenSetupSync) { | |
| 276 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
| 277 | |
| 278 ASSERT_TRUE(GetClient(0)->SetupSync()); | |
| 279 SetEncryptionPassphrase(0, kValidPassphrase, ProfileSyncService::EXPLICIT); | |
| 280 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((0)))); | |
| 281 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | |
| 282 | |
| 283 // Setup 1 with a different passphrase, so that it fails to sync. | |
| 284 ASSERT_FALSE(GetClient(1)->SetupSync()); | |
| 285 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); | |
| 286 ASSERT_FALSE(SetDecryptionPassphrase(1, kAnotherValidPassphrase)); | |
| 287 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); | |
| 288 | |
| 289 // Add a password on 0 while clients have different passphrases. | |
| 290 PasswordForm form0 = CreateTestPasswordForm(0); | |
| 291 AddLogin(GetVerifierPasswordStore(), form0); | |
| 292 AddLogin(GetPasswordStore(0), form0); | |
| 293 | |
| 294 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | |
| 295 | |
| 296 // Password hasn't been synced to 1 yet. | |
| 297 ASSERT_FALSE(AllProfilesContainSamePasswordFormsAsVerifier()); | |
| 298 | |
| 299 // Update 1 with the correct passphrase, the password should now sync over. | |
| 300 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); | |
| 301 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); | |
| 302 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1)))); | |
| 303 | |
| 304 // For some reason, the tests won't pass unless these flags are set. | |
| 305 GetSyncService((1))->SetSetupInProgress(false); | |
| 306 GetSyncService((1))->SetSyncSetupCompleted(); | |
| 307 | |
| 308 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
| 309 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | |
| 310 } | |
| OLD | NEW |