Commit 115bc01b authored by Maksim Moskvitin's avatar Maksim Moskvitin Committed by Commit Bot

Prepare sync_integration_tests for USS Nigori

Bunch of tests not passing with USS implementation of Nigori and this
is expected due to the implementation of these tests.

SingleClientCustomPassphraseForceDisableScryptSyncTest.* covers
behavior specific for Directory implementation: disable kSyncUSSNigori.

SingleClientDirectorySyncTest.DeleteDirectoryWhenCorrupted is likely
not working due to having no Directory datatypes. Since Directory is
subject for removal it's not worth to further invest into this test.

TwoClientBookmarksSyncTest.* encryption related tests use
EnableEncryption() and has no direct mapping to custom passphrase test.
They also exercises EnableEncryption() logic instead of bookmarks
logic. They are removed (we have / planning to add analogues whenever
possible into custom passphrase tests).
FirstClientEnablesEncryptionWithPassSecondChanges is an exception,
because it already works with custom passphrase and actively manipulate
bookmarks, so it's worth to keep as is (minor changes, to not rely on
IsEncryptionComplete()).

TwoClientPreferencesTest.* and TwoClientSessionsSyncTest.* encryption
related tests are removed (same motivation as for bookmarks tests).

Bug: 922900
Change-Id: Ib95db74830b1d5d43b20d7dfacf3045694f80014
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890050
Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712513}
parent 30b86781
......@@ -210,11 +210,14 @@ class SingleClientCustomPassphraseSyncTestWithUssTests
DISALLOW_COPY_AND_ASSIGN(SingleClientCustomPassphraseSyncTestWithUssTests);
};
class SingleClientCustomPassphraseForceDisableScryptSyncTest
class SingleClientCustomPassphraseForceDisableScryptDirectoryOnlySyncTest
: public SingleClientCustomPassphraseSyncTest {
public:
SingleClientCustomPassphraseForceDisableScryptSyncTest()
: features_(/*force_disabled=*/true, /*use_for_new_passphrases=*/false) {
SingleClientCustomPassphraseForceDisableScryptDirectoryOnlySyncTest()
: scrypt_features_(/*force_disabled=*/true,
/*use_for_new_passphrases=*/false) {
override_features_.InitAndDisableFeature(switches::kSyncUSSNigori);
// Creation of NigoriSpecifics with scrypt derivation method requires
// |force_disabled| temporary set to false.
ScopedScryptFeatureToggler toggler(/*force_disabled=*/false,
......@@ -227,7 +230,8 @@ class SingleClientCustomPassphraseForceDisableScryptSyncTest
const sync_pb::NigoriSpecifics& scrypt_nigori() { return scrypt_nigori_; }
private:
ScopedScryptFeatureToggler features_;
ScopedScryptFeatureToggler scrypt_features_;
base::test::ScopedFeatureList override_features_;
sync_pb::NigoriSpecifics scrypt_nigori_;
};
......@@ -386,8 +390,9 @@ IN_PROC_BROWSER_TEST_P(SingleClientCustomPassphraseDoNotUseScryptSyncTest,
EXPECT_TRUE(WaitForClientBookmarkWithTitle("scypt-encrypted bookmark"));
}
IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseForceDisableScryptSyncTest,
CannotDecryptScryptKeyEncryptedDataWhenScryptDisabled) {
IN_PROC_BROWSER_TEST_F(
SingleClientCustomPassphraseForceDisableScryptDirectoryOnlySyncTest,
CannotDecryptScryptKeyEncryptedDataWhenScryptDisabled) {
SetNigoriInFakeServer(GetFakeServer(), scrypt_nigori());
SetDecryptionPassphraseForClient(/*index=*/0, "hunter2");
......
......@@ -77,56 +77,4 @@ IN_PROC_BROWSER_TEST_F(SingleClientDirectorySyncTest,
EXPECT_FALSE(FolderContainsFiles(directory_path));
}
// Verify that when the sync directory's backing store becomes corrupted, we
// trigger an unrecoverable error and delete the database.
IN_PROC_BROWSER_TEST_F(SingleClientDirectorySyncTest,
DeleteDirectoryWhenCorrupted) {
ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
// Sync and wait for syncing to complete.
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
ASSERT_TRUE(bookmarks_helper::ModelMatchesVerifier(0));
// Flush the directory to the backing store and wait until the flush
// completes.
syncer::ProfileSyncService* sync_service = GetSyncService(0);
sync_service->FlushDirectory();
sync_service->FlushBackendTaskRunnerForTest();
// Now corrupt the database.
FilePath directory_path = sync_service->GetSyncClientForTest()
->GetSyncDataPath();
const FilePath sync_db(directory_path.Append(
syncer::syncable::Directory::kSyncDatabaseFilename));
ASSERT_TRUE(sql::test::CorruptSizeInHeaderWithLock(sync_db));
// Write some bookmarks and flush the directory to force sync to
// notice the corruption.
const GURL url("https://www.example.com");
const bookmarks::BookmarkNode* top = bookmarks_helper::AddFolder(
0, bookmarks_helper::GetOtherNode(0), 0, "top");
for (int i = 0; i < 100; ++i) {
ASSERT_TRUE(
bookmarks_helper::AddURL(0, top, 0, base::NumberToString(i), url));
}
sync_service->FlushDirectory();
// Wait for an unrecoverable error to occur.
ASSERT_TRUE(SyncUnrecoverableErrorChecker(sync_service).Wait());
ASSERT_TRUE(sync_service->HasUnrecoverableError());
// An unrecoverable error causes ProfileSyncService to post a shutdown task to
// its task runner. Make sure that task gets run before we wait for the sync
// thread.
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
run_loop.QuitClosure());
run_loop.Run();
// Wait until the sync loop has processed any existing tasks and see that the
// directory no longer exists.
sync_service->FlushBackendTaskRunnerForTest();
ASSERT_FALSE(FolderContainsFiles(directory_path));
}
} // namespace
......@@ -1779,78 +1779,6 @@ IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
ASSERT_FALSE(ContainsDuplicateBookmarks(0));
}
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SingleClientEnabledEncryption) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllModelsMatchVerifier());
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
ASSERT_TRUE(AllModelsMatchVerifier());
}
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SingleClientEnabledEncryptionAndChanged) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllModelsMatchVerifier());
ASSERT_TRUE(EnableEncryption(0));
ASSERT_NE(nullptr, AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))));
ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
ASSERT_TRUE(AllModelsMatchVerifier());
}
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
BothClientsEnabledEncryption) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllModelsMatchVerifier());
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(EnableEncryption(1));
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
ASSERT_TRUE(AllModelsMatchVerifier());
}
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SingleClientEnabledEncryptionBothChanged) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllModelsMatchVerifier());
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
ASSERT_NE(nullptr, AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))));
ASSERT_NE(nullptr, AddURL(0, IndexedURLTitle(1), GURL(IndexedURL(1))));
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(AllModelsMatchVerifier());
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
}
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
SingleClientEnabledEncryptionAndChangedMultipleTimes) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllModelsMatchVerifier());
ASSERT_NE(nullptr, AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))));
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
ASSERT_TRUE(AllModelsMatchVerifier());
ASSERT_NE(nullptr, AddURL(0, IndexedURLTitle(1), GURL(IndexedURL(1))));
ASSERT_NE(nullptr, AddFolder(0, IndexedFolderName(0)));
ASSERT_TRUE(BookmarksMatchVerifierChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
FirstClientEnablesEncryptionWithPassSecondChanges) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
......@@ -1867,10 +1795,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
GetSyncService(0)->GetUserSettings()->SetEncryptionPassphrase(
kValidPassphrase);
ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(0)).Wait());
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
ASSERT_TRUE(GetSyncService(1)->GetUserSettings()->IsPassphraseRequired());
// Client 0 adds bookmarks between the first two and between the second two.
......@@ -1978,38 +1903,6 @@ IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, CreateSyncedBookmarks) {
ASSERT_TRUE(BookmarksMatchChecker().Wait());
}
// Enable enccryption and then trigger the server side creation of Synced
// Bookmarks. Ensure both clients remain syncing afterwards. Add bookmarks to
// the synced bookmarks folder and ensure both clients receive the bookmark.
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
CreateSyncedBookmarksWithSingleClientEnableEncryption) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AllModelsMatchVerifier());
// Enable the encryption on Client 0.
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
ASSERT_TRUE(BookmarksMatchChecker().Wait());
fake_server_->InjectEntity(syncer::PersistentPermanentEntity::CreateNew(
syncer::BOOKMARKS, "synced_bookmarks", "Synced Bookmarks",
"google_chrome_bookmarks"));
ASSERT_TRUE(BookmarksMatchChecker().Wait());
// Add a bookmark on Client 0 and ensure it syncs over. This will also trigger
// both clients downloading the new Synced Bookmarks folder.
ASSERT_NE(nullptr, AddURL(0, "Google", GURL("http://www.google.com")));
ASSERT_TRUE(BookmarksMatchChecker().Wait());
// Now add a bookmark within the Synced Bookmarks folder and ensure it syncs
// over.
const BookmarkNode* synced_bookmarks = GetSyncedBookmarksNode(0);
ASSERT_TRUE(synced_bookmarks);
ASSERT_NE(nullptr, AddURL(0, synced_bookmarks, 0, "Google2",
GURL("http://www.google2.com")));
ASSERT_TRUE(BookmarksMatchChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
BookmarkAllNodesRemovedEvent) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
......
......@@ -167,39 +167,6 @@ IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
ASSERT_TRUE(ListPrefMatchChecker(prefs::kURLsToRestoreOnStartup).Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
E2E_ENABLED(SingleClientEnabledEncryptionBothChanged)) {
ResetSyncForPrimaryAccount();
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(BooleanPrefMatchChecker(prefs::kHomePageIsNewTabPage).Wait());
ASSERT_TRUE(StringPrefMatchChecker(prefs::kHomePage).Wait());
ASSERT_TRUE(EnableEncryption(0));
ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
ChangeStringPref(1, prefs::kHomePage, "http://www.google.com/1");
ASSERT_TRUE(AwaitEncryptionComplete(0));
ASSERT_TRUE(AwaitEncryptionComplete(1));
ASSERT_TRUE(StringPrefMatchChecker(prefs::kHomePage).Wait());
ASSERT_TRUE(BooleanPrefMatchChecker(prefs::kHomePageIsNewTabPage).Wait());
}
IN_PROC_BROWSER_TEST_F(
TwoClientPreferencesSyncTest,
E2E_ENABLED(BothClientsEnabledEncryptionAndChangedMultipleTimes)) {
ResetSyncForPrimaryAccount();
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(BooleanPrefMatchChecker(prefs::kHomePageIsNewTabPage).Wait());
ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(EnableEncryption(1));
ASSERT_TRUE(BooleanPrefMatchChecker(prefs::kHomePageIsNewTabPage).Wait());
ASSERT_TRUE(BooleanPrefMatchChecker(prefs::kShowHomeButton).Wait());
ChangeBooleanPref(0, prefs::kShowHomeButton);
ASSERT_TRUE(BooleanPrefMatchChecker(prefs::kShowHomeButton).Wait());
}
// The following tests use lower-level mechanisms to wait for sync cycle
// completions. Those only work reliably with self notifications turned on.
class TwoClientPreferencesSyncTestWithSelfNotifications : public SyncTest {
......
......@@ -122,45 +122,6 @@ IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, E2E_ENABLED(AllChanged)) {
}
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
SingleClientEnabledEncryption) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(CheckInitialState(0));
ASSERT_TRUE(CheckInitialState(1));
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
SingleClientEnabledEncryptionAndChanged) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(CheckInitialState(0));
ASSERT_TRUE(CheckInitialState(1));
ASSERT_TRUE(OpenTab(0, GURL(kURL1)));
ASSERT_TRUE(EnableEncryption(0));
WaitForForeignSessionsToSync(0, 1);
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
BothClientsEnabledEncryption) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(CheckInitialState(0));
ASSERT_TRUE(CheckInitialState(1));
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(EnableEncryption(1));
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, BothChanged) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
......
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