Commit 19b4eb7a authored by Maksim Moskvitin's avatar Maksim Moskvitin Committed by Commit Bot

[Sync:USS] Add ShouldLoadUSSCustomPassphraseInDirectoryMode test

New test cover compatibility of USS and Directory implementation in
term of storing keys derived from custom passphrase. We setup custom
passphrase encryption with USS implementation and then verify, that
Directory implementation can decrypt data without providing custom
passphrase again (by loading it from prefs).

Bug: 922900
Change-Id: I9c902a4f6c59b7f41f344ab60e725d7ff59ad88f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1710542
Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680052}
parent e31c850e
......@@ -9,6 +9,7 @@
#include "components/sync/base/passphrase_enums.h"
#include "components/sync/driver/profile_sync_service.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/engine/sync_engine_switches.h"
#include "components/sync/nigori/cryptographer.h"
namespace {
......@@ -399,6 +400,59 @@ IN_PROC_BROWSER_TEST_P(SingleClientCustomPassphraseDoNotUseScryptSyncTest,
expected, {KeyDerivationParams::CreateForPbkdf2(), "hunter2"}));
}
// TODO(https://crbug.com/952074): re-enable once flakiness is addressed.
#if defined(THREAD_SANITIZER)
#define MAYBE_PRE_ShouldLoadUSSCustomPassphraseInDirectoryMode \
DISABLED_PRE_ShouldLoadUSSCustomPassphraseInDirectoryMode
#else
#define MAYBE_PRE_ShouldLoadUSSCustomPassphraseInDirectoryMode \
PRE_ShouldLoadUSSCustomPassphraseInDirectoryMode
#endif
IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseSyncTest,
PRE_ShouldLoadUSSCustomPassphraseInDirectoryMode) {
base::test::ScopedFeatureList override_features;
// TODO(crbug.com/922900): Don't disable scrypt derivation and use it as key
// derivation method in ShouldLoadUSSCustomPassphraseInDirectoryMode, once
// USS implementation support it for new passphrases.
override_features.InitWithFeatures(
/*enabled_features=*/{switches::kSyncUSSBookmarks,
switches::kSyncUSSPasswords,
switches::kSyncUSSAutofillWalletMetadata,
switches::kSyncUSSNigori},
/*disabled_features=*/{switches::kSyncUseScryptForNewCustomPassphrases});
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(WaitForNigori(PassphraseType::KEYSTORE_PASSPHRASE));
GetSyncService()->GetUserSettings()->SetEncryptionPassphrase("hunter2");
ASSERT_TRUE(WaitForNigori(PassphraseType::CUSTOM_PASSPHRASE));
}
// TODO(https://crbug.com/952074): re-enable once flakiness is addressed.
#if defined(THREAD_SANITIZER)
#define MAYBE_ShouldLoadUSSCustomPassphraseInDirectoryMode \
DISABLED_ShouldLoadUSSCustomPassphraseInDirectoryMode
#else
#define MAYBE_ShouldLoadUSSCustomPassphraseInDirectoryMode \
ShouldLoadUSSCustomPassphraseInDirectoryMode
#endif
IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseSyncTest,
ShouldLoadUSSCustomPassphraseInDirectoryMode) {
// We should be able to decrypt bookmarks with passphrase, which was set when
// kSyncUSSNigori was enabled, without providing it again once kSyncUSSNigori
// is disabled.
base::test::ScopedFeatureList override_features;
override_features.InitAndDisableFeature(switches::kSyncUSSNigori);
const KeyParams key_params = {KeyDerivationParams::CreateForPbkdf2(),
"hunter2"};
InjectEncryptedServerBookmark(
"some bookmark", GURL("http://example.com/doesnt-matter"), key_params);
ASSERT_TRUE(SetupClients());
EXPECT_TRUE(WaitForPassphraseRequiredState(/*desired_state=*/false));
EXPECT_TRUE(WaitForClientBookmarkWithTitle("some bookmark"));
}
INSTANTIATE_TEST_SUITE_P(USS,
SingleClientCustomPassphraseDoNotUseScryptSyncTest,
testing::Values(false, true));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment