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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/hash.h" | 10 #include "base/hash.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 using passwords_helper::AllProfilesContainSamePasswordFormsAsVerifier; | 24 using passwords_helper::AllProfilesContainSamePasswordFormsAsVerifier; |
25 using passwords_helper::AwaitAllProfilesContainSamePasswordForms; | 25 using passwords_helper::AwaitAllProfilesContainSamePasswordForms; |
26 using passwords_helper::AwaitProfileContainsSamePasswordFormsAsVerifier; | 26 using passwords_helper::AwaitProfileContainsSamePasswordFormsAsVerifier; |
27 using passwords_helper::CreateTestPasswordForm; | 27 using passwords_helper::CreateTestPasswordForm; |
28 using passwords_helper::GetPasswordCount; | 28 using passwords_helper::GetPasswordCount; |
29 using passwords_helper::GetPasswordStore; | 29 using passwords_helper::GetPasswordStore; |
30 using passwords_helper::GetVerifierPasswordCount; | 30 using passwords_helper::GetVerifierPasswordCount; |
31 using passwords_helper::GetVerifierPasswordStore; | 31 using passwords_helper::GetVerifierPasswordStore; |
32 using passwords_helper::RemoveLogin; | 32 using passwords_helper::RemoveLogin; |
33 using passwords_helper::RemoveLogins; | 33 using passwords_helper::RemoveLogins; |
34 using passwords_helper::SetDecryptionPassphrase; | |
35 using passwords_helper::SetEncryptionPassphrase; | |
36 using passwords_helper::UpdateLogin; | 34 using passwords_helper::UpdateLogin; |
37 using sync_integration_test_util::AwaitPassphraseAccepted; | 35 using sync_integration_test_util::AwaitPassphraseAccepted; |
38 using sync_integration_test_util::AwaitPassphraseRequired; | 36 using sync_integration_test_util::AwaitPassphraseRequired; |
39 | 37 |
40 using autofill::PasswordForm; | 38 using autofill::PasswordForm; |
41 | 39 |
42 static const char* kValidPassphrase = "passphrase!"; | 40 static const char* kValidPassphrase = "passphrase!"; |
43 | 41 |
44 class TwoClientPasswordsSyncTest : public SyncTest { | 42 class TwoClientPasswordsSyncTest : public SyncTest { |
45 public: | 43 public: |
(...skipping 30 matching lines...) Expand all Loading... |
76 form1.password_value = base::ASCIIToUTF16("new_password"); | 74 form1.password_value = base::ASCIIToUTF16("new_password"); |
77 AddLogin(GetPasswordStore(1), form1); | 75 AddLogin(GetPasswordStore(1), form1); |
78 | 76 |
79 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); | 77 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); |
80 } | 78 } |
81 | 79 |
82 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, | 80 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, |
83 E2E_ENABLED(SetPassphraseAndAddPassword)) { | 81 E2E_ENABLED(SetPassphraseAndAddPassword)) { |
84 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
85 | 83 |
86 SetEncryptionPassphrase(0, kValidPassphrase, | 84 GetSyncService(0)->SetEncryptionPassphrase( |
87 browser_sync::ProfileSyncService::EXPLICIT); | 85 kValidPassphrase, browser_sync::ProfileSyncService::EXPLICIT); |
88 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((0)))); | 86 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(0))); |
89 | 87 |
90 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1)))); | 88 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService(1))); |
91 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); | 89 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kValidPassphrase)); |
92 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1)))); | 90 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(1))); |
93 | 91 |
94 PasswordForm form = CreateTestPasswordForm(0); | 92 PasswordForm form = CreateTestPasswordForm(0); |
95 AddLogin(GetPasswordStore(0), form); | 93 AddLogin(GetPasswordStore(0), form); |
96 ASSERT_EQ(1, GetPasswordCount(0)); | 94 ASSERT_EQ(1, GetPasswordCount(0)); |
97 | 95 |
98 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); | 96 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); |
99 } | 97 } |
100 | 98 |
101 // TCM ID - 4603879 | 99 // TCM ID - 4603879 |
102 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Update) { | 100 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Update) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Wait for deletion from client 1 to propagate. | 140 // Wait for deletion from client 1 to propagate. |
143 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0)); | 141 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0)); |
144 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); | 142 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); |
145 } | 143 } |
146 | 144 |
147 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, | 145 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, |
148 SetPassphraseAndThenSetupSync) { | 146 SetPassphraseAndThenSetupSync) { |
149 ASSERT_TRUE(SetupClients()); | 147 ASSERT_TRUE(SetupClients()); |
150 | 148 |
151 ASSERT_TRUE(GetClient(0)->SetupSync()); | 149 ASSERT_TRUE(GetClient(0)->SetupSync()); |
152 SetEncryptionPassphrase(0, kValidPassphrase, | 150 GetSyncService(0)->SetEncryptionPassphrase( |
153 browser_sync::ProfileSyncService::EXPLICIT); | 151 kValidPassphrase, browser_sync::ProfileSyncService::EXPLICIT); |
154 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(0))); | 152 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(0))); |
155 | 153 |
156 // When client 1 hits a passphrase required state, we can infer that | 154 // When client 1 hits a passphrase required state, we can infer that |
157 // client 0's passphrase has been committed. to the server. | 155 // client 0's passphrase has been committed. to the server. |
158 ASSERT_FALSE(GetClient(1)->SetupSync()); | 156 ASSERT_FALSE(GetClient(1)->SetupSync()); |
159 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService(1))); | 157 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService(1))); |
160 | 158 |
161 // Get client 1 out of the passphrase required state. | 159 // Get client 1 out of the passphrase required state. |
162 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); | 160 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kValidPassphrase)); |
163 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(1))); | 161 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(1))); |
164 | 162 |
165 // We must mark the setup complete now, since we just entered the passphrase | 163 // We must mark the setup complete now, since we just entered the passphrase |
166 // and the previous SetupSync() call failed. | 164 // and the previous SetupSync() call failed. |
167 GetClient(1)->FinishSyncSetup(); | 165 GetClient(1)->FinishSyncSetup(); |
168 | 166 |
169 // Move around some passwords to make sure it's all working. | 167 // Move around some passwords to make sure it's all working. |
170 PasswordForm form0 = CreateTestPasswordForm(0); | 168 PasswordForm form0 = CreateTestPasswordForm(0); |
171 AddLogin(GetPasswordStore(0), form0); | 169 AddLogin(GetPasswordStore(0), form0); |
172 | 170 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 258 |
261 // Blocks and waits for password forms in all profiles to match. | 259 // Blocks and waits for password forms in all profiles to match. |
262 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); | 260 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); |
263 | 261 |
264 // Check that total number of passwords is as expected. | 262 // Check that total number of passwords is as expected. |
265 for (int i = 0; i < num_clients(); ++i) { | 263 for (int i = 0; i < num_clients(); ++i) { |
266 ASSERT_EQ(GetPasswordCount(i), init_password_count + num_clients()) << | 264 ASSERT_EQ(GetPasswordCount(i), init_password_count + num_clients()) << |
267 "Total password count is wrong."; | 265 "Total password count is wrong."; |
268 } | 266 } |
269 } | 267 } |
OLD | NEW |