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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "chrome/browser/sessions/session_service.h" | 6 #include "chrome/browser/sessions/session_service.h" |
7 #include "chrome/browser/sync/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/profile_sync_service_harness.h" |
8 #include "chrome/browser/sync/sessions/session_state.h" | 8 #include "chrome/browser/sync/sessions/session_state.h" |
9 #include "chrome/browser/sync/test/integration/sync_test.h" | 9 #include "chrome/browser/sync/test/integration/sync_test.h" |
10 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 10 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 162 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
163 GetClient(0)->service()->SetPassphrase( | 163 GetClient(0)->service()->SetPassphrase( |
164 kValidPassphrase, | 164 kValidPassphrase, |
165 ProfileSyncService::EXPLICIT, | 165 ProfileSyncService::EXPLICIT, |
166 ProfileSyncService::USER_PROVIDED); | 166 ProfileSyncService::USER_PROVIDED); |
167 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 167 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
168 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 168 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
169 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 169 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
170 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 170 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
171 num_blocking_conflicting_updates); | 171 num_simple_conflicting_updates); |
172 // We have two meta nodes (one for each client), the one tab node, plus the | 172 // We have two meta nodes (one for each client), the one tab node, plus the |
173 // basic preference/themes/search engines items. | 173 // basic preference/themes/search engines items. |
174 ASSERT_EQ(NumberOfDefaultSyncItems() + 3, | 174 ASSERT_EQ(NumberOfDefaultSyncItems() + 3, |
175 GetClient(1)->GetLastSessionSnapshot()-> | 175 GetClient(1)->GetLastSessionSnapshot()-> |
176 num_conflicting_updates); // The encrypted nodes. | 176 num_conflicting_updates); // The encrypted nodes. |
177 | 177 |
178 GetClient(1)->service()->SetPassphrase( | 178 GetClient(1)->service()->SetPassphrase( |
179 kValidPassphrase, | 179 kValidPassphrase, |
180 ProfileSyncService::EXPLICIT, | 180 ProfileSyncService::EXPLICIT, |
181 ProfileSyncService::USER_PROVIDED); | 181 ProfileSyncService::USER_PROVIDED); |
(...skipping 29 matching lines...) Expand all Loading... |
211 | 211 |
212 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 212 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
213 GetClient(0)->service()->SetPassphrase( | 213 GetClient(0)->service()->SetPassphrase( |
214 kValidPassphrase, | 214 kValidPassphrase, |
215 ProfileSyncService::EXPLICIT, | 215 ProfileSyncService::EXPLICIT, |
216 ProfileSyncService::USER_PROVIDED); | 216 ProfileSyncService::USER_PROVIDED); |
217 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 217 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
218 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 218 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
219 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 219 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
220 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 220 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
221 num_blocking_conflicting_updates); | 221 num_simple_conflicting_updates); |
222 // We have nine non-blocking conflicts due to the two meta nodes (one for | 222 // We have nine encryption conflicts due to the two meta nodes (one for each |
223 // each client), plus the basic preference/themes/search engines nodes. | 223 // client), plus the basic preference/themes/search engines nodes. |
224 ASSERT_EQ(NumberOfDefaultSyncItems() + 2, | 224 ASSERT_EQ(NumberOfDefaultSyncItems() + 2, |
225 GetClient(1)->GetLastSessionSnapshot()-> | 225 GetClient(1)->GetLastSessionSnapshot()-> |
226 num_conflicting_updates); // The encrypted nodes. | 226 num_conflicting_updates); // The encrypted nodes. |
227 | 227 |
228 ScopedWindowMap client0_windows; | 228 ScopedWindowMap client0_windows; |
229 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 229 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
230 client0_windows.GetMutable())); | 230 client0_windows.GetMutable())); |
231 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 231 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
232 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 232 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
233 num_blocking_conflicting_updates); | 233 num_simple_conflicting_updates); |
234 ASSERT_EQ(NumberOfDefaultSyncItems() + 3, | 234 ASSERT_EQ(NumberOfDefaultSyncItems() + 3, |
235 GetClient(1)->GetLastSessionSnapshot()-> | 235 GetClient(1)->GetLastSessionSnapshot()-> |
236 num_conflicting_updates); // The encrypted nodes. | 236 num_conflicting_updates); // The encrypted nodes. |
237 | 237 |
238 GetClient(1)->service()->SetPassphrase( | 238 GetClient(1)->service()->SetPassphrase( |
239 kValidPassphrase, | 239 kValidPassphrase, |
240 ProfileSyncService::EXPLICIT, | 240 ProfileSyncService::EXPLICIT, |
241 ProfileSyncService::USER_PROVIDED); | 241 ProfileSyncService::USER_PROVIDED); |
242 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 242 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
243 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 243 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
(...skipping 19 matching lines...) Expand all Loading... |
263 | 263 |
264 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 264 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
265 GetClient(0)->service()->SetPassphrase( | 265 GetClient(0)->service()->SetPassphrase( |
266 kValidPassphrase, | 266 kValidPassphrase, |
267 ProfileSyncService::EXPLICIT, | 267 ProfileSyncService::EXPLICIT, |
268 ProfileSyncService::USER_PROVIDED); | 268 ProfileSyncService::USER_PROVIDED); |
269 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 269 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
270 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 270 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
271 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 271 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
272 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 272 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
273 num_blocking_conflicting_updates); | 273 num_simple_conflicting_updates); |
274 // We have two non-blocking conflicts due to the two meta nodes (one for each | 274 // We have two encryption conflicts due to the two meta nodes (one for each |
275 // client), plus the basic preference/themes/search engines nodes. | 275 // client), plus the basic preference/themes/search engines nodes. |
276 ASSERT_EQ(NumberOfDefaultSyncItems() + 2, | 276 ASSERT_EQ(NumberOfDefaultSyncItems() + 2, |
277 GetClient(1)->GetLastSessionSnapshot()-> | 277 GetClient(1)->GetLastSessionSnapshot()-> |
278 num_conflicting_updates); // The encrypted nodes. | 278 num_conflicting_updates); // The encrypted nodes. |
279 | 279 |
280 // These changes are either made with the old passphrase or not encrypted at | 280 // These changes are either made with the old passphrase or not encrypted at |
281 // all depending on when client 0's changes are propagated. | 281 // all depending on when client 0's changes are propagated. |
282 ScopedWindowMap client1_windows; | 282 ScopedWindowMap client1_windows; |
283 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), | 283 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), |
284 client1_windows.GetMutable())); | 284 client1_windows.GetMutable())); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // new passphrase and synced back. It will be unable to decrypt it yet. | 328 // new passphrase and synced back. It will be unable to decrypt it yet. |
329 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 329 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
330 GetClient(0)->service()->SetPassphrase( | 330 GetClient(0)->service()->SetPassphrase( |
331 kValidPassphrase, | 331 kValidPassphrase, |
332 ProfileSyncService::EXPLICIT, | 332 ProfileSyncService::EXPLICIT, |
333 ProfileSyncService::USER_PROVIDED); | 333 ProfileSyncService::USER_PROVIDED); |
334 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 334 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
335 ASSERT_TRUE(AwaitQuiescence()); | 335 ASSERT_TRUE(AwaitQuiescence()); |
336 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 336 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
337 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 337 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
338 num_blocking_conflicting_updates); | 338 num_simple_conflicting_updates); |
339 // We have three non-blocking conflicts due to the two meta nodes (one for | 339 // We have three encryption conflicts due to the two meta nodes (one for |
340 // each client), the one tab node, plus the basic preference/themes/search | 340 // each client), the one tab node, plus the basic preference/themes/search |
341 // engines nodes. | 341 // engines nodes. |
342 ASSERT_GE(NumberOfDefaultSyncItems() + 3, | 342 ASSERT_GE(NumberOfDefaultSyncItems() + 3, |
343 GetClient(1)->GetLastSessionSnapshot()-> | 343 GetClient(1)->GetLastSessionSnapshot()-> |
344 num_conflicting_updates); // The encrypted nodes. | 344 num_conflicting_updates); // The encrypted nodes. |
345 | 345 |
346 // At this point we enter the passphrase, triggering a resync. | 346 // At this point we enter the passphrase, triggering a resync. |
347 GetClient(1)->service()->SetPassphrase( | 347 GetClient(1)->service()->SetPassphrase( |
348 kValidPassphrase, | 348 kValidPassphrase, |
349 ProfileSyncService::EXPLICIT, | 349 ProfileSyncService::EXPLICIT, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 387 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
388 | 388 |
389 // These changes will sync over to client 1, who will be unable to decrypt | 389 // These changes will sync over to client 1, who will be unable to decrypt |
390 // them due to the missing passphrase. | 390 // them due to the missing passphrase. |
391 ScopedWindowMap client0_windows; | 391 ScopedWindowMap client0_windows; |
392 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 392 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
393 client0_windows.GetMutable())); | 393 client0_windows.GetMutable())); |
394 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 394 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
395 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 395 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
396 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 396 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
397 num_blocking_conflicting_updates); | 397 num_simple_conflicting_updates); |
398 // We have three non-blocking conflicts due to the two meta nodes (one for | 398 // We have three encryption conflicts due to the two meta nodes (one for |
399 // each client), the one tab node, plus the basic preference/themes/search | 399 // each client), the one tab node, plus the basic preference/themes/search |
400 // engines nodes. | 400 // engines nodes. |
401 ASSERT_EQ(NumberOfDefaultSyncItems() + 3, | 401 ASSERT_EQ(NumberOfDefaultSyncItems() + 3, |
402 GetClient(1)->GetLastSessionSnapshot()-> | 402 GetClient(1)->GetLastSessionSnapshot()-> |
403 num_conflicting_updates); // The encrypted nodes. | 403 num_conflicting_updates); // The encrypted nodes. |
404 | 404 |
405 GetClient(1)->service()->SetPassphrase( | 405 GetClient(1)->service()->SetPassphrase( |
406 kValidPassphrase, | 406 kValidPassphrase, |
407 ProfileSyncService::EXPLICIT, | 407 ProfileSyncService::EXPLICIT, |
408 ProfileSyncService::USER_PROVIDED); | 408 ProfileSyncService::USER_PROVIDED); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 482 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
483 | 483 |
484 // Client 0 becomes active again with a new tab. | 484 // Client 0 becomes active again with a new tab. |
485 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), | 485 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), |
486 client0_windows.GetMutable())); | 486 client0_windows.GetMutable())); |
487 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 487 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
488 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 488 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
489 ASSERT_EQ(1U, sessions1.size()); | 489 ASSERT_EQ(1U, sessions1.size()); |
490 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 490 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
491 } | 491 } |
OLD | NEW |