#include "chrome/browser/sync/test/integration/passwords_helper.h"
#include <sstream>
#include <utility>
#include "base/base64.h"
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/run_loop.h"
#include "base/strings/escape.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
#include "chrome/browser/password_manager/account_password_store_factory.h"
#include "chrome/browser/password_manager/profile_password_store_factory.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_manager_test_utils.h"
#include "components/password_manager/core/browser/password_store/password_store_consumer.h"
#include "components/password_manager/core/browser/password_store/password_store_interface.h"
#include "components/password_manager/core/browser/sync/password_proto_utils.h"
#include "components/sync/engine/loopback_server/persistent_unique_client_entity.h"
#include "components/sync/engine/nigori/key_derivation_params.h"
#include "components/sync/nigori/cryptographer_impl.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/password_specifics.pb.h"
#include "components/sync/service/sync_service_impl.h"
#include "content/public/test/test_utils.h"
#include "url/gurl.h"
PasswordForm;
PasswordStoreInterface;
test;
namespace {
const char kFakeSignonRealm[] = …;
const char kIndexedFakeOrigin[] = …;
class PasswordStoreConsumerHelper
: public password_manager::PasswordStoreConsumer { … };
sync_pb::EntitySpecifics EncryptPasswordSpecifics(
const sync_pb::PasswordSpecificsData& password_data,
const std::string& passphrase,
const syncer::KeyDerivationParams& key_derivation_params) { … }
std::string GetClientTag(const sync_pb::PasswordSpecificsData& password_data) { … }
}
namespace passwords_helper {
std::vector<std::unique_ptr<PasswordForm>> GetLogins(
PasswordStoreInterface* store) { … }
std::vector<std::unique_ptr<PasswordForm>> GetAllLogins(
PasswordStoreInterface* store) { … }
void RemoveLogins(PasswordStoreInterface* store) { … }
PasswordStoreInterface* GetProfilePasswordStoreInterface(int index) { … }
PasswordStoreInterface* GetVerifierProfilePasswordStoreInterface() { … }
PasswordStoreInterface* GetAccountPasswordStoreInterface(int index) { … }
password_manager::PasswordStoreInterface* GetPasswordStoreInterface(
int index,
PasswordForm::Store store) { … }
bool ProfileContainsSamePasswordFormsAsVerifier(int index) { … }
bool ProfilesContainSamePasswordForms(int index_a,
int index_b,
PasswordForm::Store store) { … }
bool AllProfilesContainSamePasswordFormsAsVerifier() { … }
bool AllProfilesContainSamePasswordForms(PasswordForm::Store store) { … }
int GetPasswordCount(int index, PasswordForm::Store store) { … }
int GetVerifierPasswordCount() { … }
PasswordForm CreateTestPasswordForm(int index) { … }
void InjectEncryptedServerPassword(
const password_manager::PasswordForm& form,
const std::string& encryption_passphrase,
const syncer::KeyDerivationParams& key_derivation_params,
fake_server::FakeServer* fake_server) { … }
void InjectEncryptedServerPassword(
const sync_pb::PasswordSpecificsData& password_data,
const std::string& encryption_passphrase,
const syncer::KeyDerivationParams& key_derivation_params,
fake_server::FakeServer* fake_server) { … }
void InjectKeystoreEncryptedServerPassword(
const password_manager::PasswordForm& form,
fake_server::FakeServer* fake_server) { … }
void InjectKeystoreEncryptedServerPassword(
const sync_pb::PasswordSpecificsData& password_data,
fake_server::FakeServer* fake_server) { … }
}
PasswordSyncActiveChecker::PasswordSyncActiveChecker(
syncer::SyncServiceImpl* service)
: … { … }
PasswordSyncActiveChecker::~PasswordSyncActiveChecker() = default;
bool PasswordSyncActiveChecker::IsExitConditionSatisfied(std::ostream* os) { … }
PasswordSyncInactiveChecker::PasswordSyncInactiveChecker(
syncer::SyncServiceImpl* service)
: … { … }
PasswordSyncInactiveChecker::~PasswordSyncInactiveChecker() = default;
bool PasswordSyncInactiveChecker::IsExitConditionSatisfied(std::ostream* os) { … }
SamePasswordFormsChecker::SamePasswordFormsChecker(PasswordForm::Store store)
: … { … }
SamePasswordFormsChecker::~SamePasswordFormsChecker() = default;
bool SamePasswordFormsChecker::IsExitConditionSatisfied(std::ostream* os) { … }
SamePasswordFormsAsVerifierChecker::SamePasswordFormsAsVerifierChecker(int i)
: … { … }
bool SamePasswordFormsAsVerifierChecker::IsExitConditionSatisfied(
std::ostream* os) { … }
PasswordFormsChecker::PasswordFormsChecker(
int index,
const std::vector<password_manager::PasswordForm>& expected_forms)
: … { … }
PasswordFormsChecker::~PasswordFormsChecker() = default;
bool PasswordFormsChecker::IsExitConditionSatisfied(std::ostream* os) { … }
bool PasswordFormsChecker::IsExitConditionSatisfiedImpl(std::ostream* os) { … }
ServerPasswordsEqualityChecker::ServerPasswordsEqualityChecker(
const std::vector<password_manager::PasswordForm>& expected_forms,
const std::string& encryption_passphrase,
const syncer::KeyDerivationParams& key_derivation_params)
: … { … }
ServerPasswordsEqualityChecker::~ServerPasswordsEqualityChecker() = default;
bool ServerPasswordsEqualityChecker::IsExitConditionSatisfied(
std::ostream* os) { … }
PasswordFormsAddedChecker::PasswordFormsAddedChecker(
password_manager::PasswordStoreInterface* password_store,
size_t expected_new_password_forms)
: … { … }
PasswordFormsAddedChecker::~PasswordFormsAddedChecker() { … }
bool PasswordFormsAddedChecker::IsExitConditionSatisfied(std::ostream* os) { … }
void PasswordFormsAddedChecker::OnLoginsChanged(
password_manager::PasswordStoreInterface* store,
const password_manager::PasswordStoreChangeList& changes) { … }
void PasswordFormsAddedChecker::OnLoginsRetained(
password_manager::PasswordStoreInterface* store,
const std::vector<password_manager::PasswordForm>& retained_passwords) { … }