1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/sync/test/integration/passwords_helper.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "sync/internal_api/public/engine/model_safe_worker.h"
#include "sync/internal_api/public/sessions/sync_session_snapshot.h"
using passwords_helper::AddLogin;
using passwords_helper::AllProfilesContainSamePasswordForms;
using passwords_helper::AllProfilesContainSamePasswordFormsAsVerifier;
using passwords_helper::AwaitAllProfilesContainSamePasswordForms;
using passwords_helper::AwaitProfileContainsSamePasswordFormsAsVerifier;
using passwords_helper::CreateTestPasswordForm;
using passwords_helper::GetPasswordCount;
using passwords_helper::GetPasswordStore;
using passwords_helper::GetVerifierPasswordCount;
using passwords_helper::GetVerifierPasswordStore;
using passwords_helper::RemoveLogin;
using passwords_helper::RemoveLogins;
using passwords_helper::SetDecryptionPassphrase;
using passwords_helper::SetEncryptionPassphrase;
using passwords_helper::UpdateLogin;
using sync_integration_test_util::AwaitPassphraseAccepted;
using sync_integration_test_util::AwaitPassphraseRequired;
using autofill::PasswordForm;
static const char* kValidPassphrase = "passphrase!";
class TwoClientPasswordsSyncTest : public SyncTest {
public:
TwoClientPasswordsSyncTest() : SyncTest(TWO_CLIENT) {}
~TwoClientPasswordsSyncTest() override {}
bool TestUsesSelfNotifications() override { return false; }
private:
DISALLOW_COPY_AND_ASSIGN(TwoClientPasswordsSyncTest);
};
// TCM ID - 3732277
IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Add) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
PasswordForm form = CreateTestPasswordForm(0);
AddLogin(GetVerifierPasswordStore(), form);
ASSERT_EQ(1, GetVerifierPasswordCount());
AddLogin(GetPasswordStore(0), form);
ASSERT_EQ(1, GetPasswordCount(0));
ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms());
}
IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Race) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllProfilesContainSamePasswordForms());
PasswordForm form0 = CreateTestPasswordForm(0);
AddLogin(GetPasswordStore(0), form0);
PasswordForm form1 = form0;
form1.password_value = base::ASCIIToUTF16("new_password");
AddLogin(GetPasswordStore(1), form1);
ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms());
}
IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest,
SetPassphraseAndAddPassword) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
SetEncryptionPassphrase(0, kValidPassphrase, ProfileSyncService::EXPLICIT);
ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((0))));
ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1))));
ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase));
ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1))));
PasswordForm form = CreateTestPasswordForm(0);
AddLogin(GetPasswordStore(0), form);
ASSERT_EQ(1, GetPasswordCount(0));
ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms());
}
// TCM ID - 4603879
IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Update) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
PasswordForm form = CreateTestPasswordForm(0);
AddLogin(GetVerifierPasswordStore(), form);
AddLogin(GetPasswordStore(0), form);
// Wait for client 0 to commit and client 1 to receive the update.
ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(1));
form.password_value = base::ASCIIToUTF16("new_password");
UpdateLogin(GetVerifierPasswordStore(), form);
UpdateLogin(GetPasswordStore(1), form);
ASSERT_EQ(1, GetVerifierPasswordCount());
// Wait for client 1 to commit and client 0 to receive the update.
ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0));
ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
}
// TCM ID - 3719309
IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Delete) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
PasswordForm form0 = CreateTestPasswordForm(0);
AddLogin(GetVerifierPasswordStore(), form0);
AddLogin(GetPasswordStore(0), form0);
PasswordForm form1 = CreateTestPasswordForm(1);
AddLogin(GetVerifierPasswordStore(), form1);
AddLogin(GetPasswordStore(0), form1);
// Wait for client 0 to commit and client 1 to receive the update.
ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(1));
RemoveLogin(GetPasswordStore(1), form0);
RemoveLogin(GetVerifierPasswordStore(), form0);
ASSERT_EQ(1, GetVerifierPasswordCount());
// Wait for deletion from client 1 to propagate.
ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0));
ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
}
// TCM ID - 7573511
// Flaky on Mac and Windows: http://crbug.com/111399
#if defined(OS_WIN) || defined(OS_MACOSX)
#define MAYBE_DeleteAll DISABLED_DeleteAll
#else
#define MAYBE_DeleteAll DeleteAll
#endif
IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, MAYBE_DeleteAll) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
PasswordForm form0 = CreateTestPasswordForm(0);
AddLogin(GetVerifierPasswordStore(), form0);
AddLogin(GetPasswordStore(0), form0);
PasswordForm form1 = CreateTestPasswordForm(1);
AddLogin(GetVerifierPasswordStore(), form1);
AddLogin(GetPasswordStore(0), form1);
ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(1));
ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
RemoveLogins(GetPasswordStore(1));
RemoveLogins(GetVerifierPasswordStore());
ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0));
ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
ASSERT_EQ(0, GetVerifierPasswordCount());
}
// TCM ID - 3694311
IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Merge) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllProfilesContainSamePasswordForms());
PasswordForm form0 = CreateTestPasswordForm(0);
AddLogin(GetPasswordStore(0), form0);
PasswordForm form1 = CreateTestPasswordForm(1);
AddLogin(GetPasswordStore(1), form1);
PasswordForm form2 = CreateTestPasswordForm(2);
AddLogin(GetPasswordStore(1), form2);
ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms());
ASSERT_EQ(3, GetPasswordCount(0));
}
|