#include "components/sync/service/sync_service_crypto.h"
#include <utility>
#include "base/base64.h"
#include "base/functional/callback.h"
#include "base/test/metrics/histogram_tester.h"
#include "components/os_crypt/sync/os_crypt.h"
#include "components/os_crypt/sync/os_crypt_mocker.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/sync/base/time.h"
#include "components/sync/engine/nigori/key_derivation_params.h"
#include "components/sync/engine/nigori/nigori.h"
#include "components/sync/engine/sync_status.h"
#include "components/sync/test/mock_sync_engine.h"
#include "components/trusted_vault/test/fake_trusted_vault_client.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
namespace {
_;
Eq;
IsEmpty;
IsNull;
Ne;
Not;
NotNull;
Return;
ReturnPointee;
ReturnRef;
SaveArg;
sync_pb::EncryptedData MakeEncryptedData(
const std::string& passphrase,
const KeyDerivationParams& derivation_params) { … }
CoreAccountInfo MakeAccountInfoWithGaia(const std::string& gaia) { … }
std::string CreateBootstrapToken(const std::string& passphrase,
const KeyDerivationParams& derivation_params) { … }
MATCHER(IsScryptKeyDerivationParams, "") { … }
MATCHER_P2(BootstrapTokenDerivedFrom,
expected_passphrase,
expected_derivation_params,
"") { … }
class MockDelegate : public SyncServiceCrypto::Delegate { … };
class SyncServiceCryptoTest : public testing::Test { … };
TEST_F(SyncServiceCryptoTest, ShouldRequireNoUserAction) { … }
TEST_F(SyncServiceCryptoTest, ShouldSetUpNewCustomPassphrase) { … }
TEST_F(SyncServiceCryptoTest, ShouldExposePassphraseRequired) { … }
TEST_F(SyncServiceCryptoTest,
ShouldStoreBootstrapTokenBeforeReconfiguringDataTypes) { … }
TEST_F(SyncServiceCryptoTest, ShouldSetupDecryptionWithBootstrapToken) { … }
TEST_F(SyncServiceCryptoTest,
ShouldSetupDecryptionWithBootstrapTokenUponEngineInitialization) { … }
TEST_F(SyncServiceCryptoTest, ShouldIgnoreNotMatchingBootstrapToken) { … }
TEST_F(SyncServiceCryptoTest, ShouldIgnoreCorruptedBootstrapToken) { … }
TEST_F(SyncServiceCryptoTest, ShouldDecryptWithNigoriKey) { … }
TEST_F(SyncServiceCryptoTest,
ShouldIgnoreDecryptionWithNigoriKeyWhenPassphraseNotRequired) { … }
TEST_F(SyncServiceCryptoTest,
ShouldDeferDecryptionWithNigoriKeyUntilEngineInitialization) { … }
TEST_F(SyncServiceCryptoTest, ShouldGetDecryptionKeyFromBootstrapToken) { … }
TEST_F(SyncServiceCryptoTest,
ShouldGetNullDecryptionKeyFromEmptyBootstrapToken) { … }
TEST_F(SyncServiceCryptoTest,
ShouldGetNullDecryptionKeyFromCorruptedBootstrapToken) { … }
TEST_F(SyncServiceCryptoTest,
ShouldReadValidTrustedVaultKeysFromClientBeforeInitialization) { … }
TEST_F(SyncServiceCryptoTest,
ShouldReadValidTrustedVaultKeysFromClientAfterInitialization) { … }
TEST_F(SyncServiceCryptoTest,
ShouldReadNoTrustedVaultKeysFromClientAfterInitialization) { … }
TEST_F(SyncServiceCryptoTest, ShouldReadInvalidTrustedVaultKeysFromClient) { … }
TEST_F(SyncServiceCryptoTest, ShouldFollowKeyRotationDueToSecondFetch) { … }
TEST_F(SyncServiceCryptoTest, ShouldRefetchTrustedVaultKeysWhenChangeObserved) { … }
TEST_F(SyncServiceCryptoTest,
ShouldDeferTrustedVaultKeyFetchingWhenChangeObservedWhileOngoingFetch) { … }
TEST_F(
SyncServiceCryptoTest,
ShouldDeferTrustedVaultKeyFetchingWhenChangeObservedWhileOngoingRefetch) { … }
TEST_F(SyncServiceCryptoTest,
ShouldNotGetRecoverabilityIfKeystorePassphraseUsed) { … }
TEST_F(SyncServiceCryptoTest,
ShouldNotReportDegradedRecoverabilityUponInitialization) { … }
TEST_F(SyncServiceCryptoTest,
ShouldReportDegradedRecoverabilityUponInitialization) { … }
TEST_F(SyncServiceCryptoTest, ShouldReportDegradedRecoverabilityUponChange) { … }
TEST_F(SyncServiceCryptoTest,
ShouldStopReportingDegradedRecoverabilityUponChange) { … }
TEST_F(SyncServiceCryptoTest, ShouldReportDegradedRecoverabilityUponRetrieval) { … }
TEST_F(SyncServiceCryptoTest,
ShouldClearDegradedRecoverabilityIfCustomPassphraseIsSet) { … }
TEST_F(SyncServiceCryptoTest,
ShouldIgnoreDegradedRecoverabilityRequestCompletionAfterReset) { … }
}
}