Commit 3b5c790b authored by Rushan Suleymanov's avatar Rushan Suleymanov Committed by Commit Bot

[Sync] Fix bookmarks reupload integration tests

Some tests related to bookmarks reupload are flaky because there is used
UpdatedProgressMarkerChecker. It doesn't guarantee that all current
changes are committed.

The better option is to wait for the actual expected data on the server
rather than for the next commit message.

For bookmarks reupload there are two possible titles in specifics:
legacy canonicalized title and full title. This CL extends the
ServerBookmarksEqualityChecker to wait until both of them are equal to
the expected title.

Bug: 1135271
Change-Id: I0a80949e30b085d94e00a82ddd8d79db39309891
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462268Reviewed-by: default avatarJan Krcal <jkrcal@chromium.org>
Commit-Queue: Rushan Suleymanov <rushans@google.com>
Cr-Commit-Position: refs/heads/master@{#816154}
parent 82a56949
...@@ -1248,12 +1248,12 @@ bool BookmarkFaviconLoadedChecker::IsExitConditionSatisfied(std::ostream* os) { ...@@ -1248,12 +1248,12 @@ bool BookmarkFaviconLoadedChecker::IsExitConditionSatisfied(std::ostream* os) {
ServerBookmarksEqualityChecker::ServerBookmarksEqualityChecker( ServerBookmarksEqualityChecker::ServerBookmarksEqualityChecker(
syncer::ProfileSyncService* service, syncer::ProfileSyncService* service,
fake_server::FakeServer* fake_server, fake_server::FakeServer* fake_server,
const std::vector<ExpectedBookmark>& expected_bookmarks, std::vector<ExpectedBookmark> expected_bookmarks,
syncer::Cryptographer* cryptographer) syncer::Cryptographer* cryptographer)
: SingleClientStatusChangeChecker(service), : SingleClientStatusChangeChecker(service),
fake_server_(fake_server), fake_server_(fake_server),
cryptographer_(cryptographer), cryptographer_(cryptographer),
expected_bookmarks_(expected_bookmarks) {} expected_bookmarks_(std::move(expected_bookmarks)) {}
bool ServerBookmarksEqualityChecker::IsExitConditionSatisfied( bool ServerBookmarksEqualityChecker::IsExitConditionSatisfied(
std::ostream* os) { std::ostream* os) {
...@@ -1293,6 +1293,7 @@ bool ServerBookmarksEqualityChecker::IsExitConditionSatisfied( ...@@ -1293,6 +1293,7 @@ bool ServerBookmarksEqualityChecker::IsExitConditionSatisfied(
[actual_specifics](const ExpectedBookmark& bookmark) { [actual_specifics](const ExpectedBookmark& bookmark) {
return actual_specifics.legacy_canonicalized_title() == return actual_specifics.legacy_canonicalized_title() ==
bookmark.title && bookmark.title &&
actual_specifics.full_title() == bookmark.title &&
actual_specifics.url() == bookmark.url; actual_specifics.url() == bookmark.url;
}); });
if (it != expected.end()) { if (it != expected.end()) {
......
...@@ -443,10 +443,11 @@ class BookmarkFaviconLoadedChecker ...@@ -443,10 +443,11 @@ class BookmarkFaviconLoadedChecker
}; };
// Checker used to block until the bookmarks on the server match a given set of // Checker used to block until the bookmarks on the server match a given set of
// expected bookmarks. // expected bookmarks. The |title| is comapred to both legacy and full titles.
class ServerBookmarksEqualityChecker : public SingleClientStatusChangeChecker { class ServerBookmarksEqualityChecker : public SingleClientStatusChangeChecker {
public: public:
struct ExpectedBookmark { struct ExpectedBookmark {
// Used to check both legacy and full titles in specifics.
std::string title; std::string title;
GURL url; GURL url;
}; };
...@@ -454,10 +455,11 @@ class ServerBookmarksEqualityChecker : public SingleClientStatusChangeChecker { ...@@ -454,10 +455,11 @@ class ServerBookmarksEqualityChecker : public SingleClientStatusChangeChecker {
// If a |cryptographer| is provided (i.e. is not nullptr), it is assumed that // If a |cryptographer| is provided (i.e. is not nullptr), it is assumed that
// the server-side data should be encrypted, and the provided cryptographer // the server-side data should be encrypted, and the provided cryptographer
// will be used to decrypt the data prior to checking for equality. // will be used to decrypt the data prior to checking for equality.
// |fake_server| must not be nullptr and must outlive this object.
ServerBookmarksEqualityChecker( ServerBookmarksEqualityChecker(
syncer::ProfileSyncService* service, syncer::ProfileSyncService* service,
fake_server::FakeServer* fake_server, fake_server::FakeServer* fake_server,
const std::vector<ExpectedBookmark>& expected_bookmarks, std::vector<ExpectedBookmark> expected_bookmarks,
syncer::Cryptographer* cryptographer); syncer::Cryptographer* cryptographer);
bool IsExitConditionSatisfied(std::ostream* os) override; bool IsExitConditionSatisfied(std::ostream* os) override;
......
...@@ -71,6 +71,10 @@ const int kSingleProfileIndex = 0; ...@@ -71,6 +71,10 @@ const int kSingleProfileIndex = 0;
// fake server across PRE_MyTest and MyTest. // fake server across PRE_MyTest and MyTest.
const char kBookmarkGuid[] = "e397ed62-9532-4dbf-ae55-200236eba15c"; const char kBookmarkGuid[] = "e397ed62-9532-4dbf-ae55-200236eba15c";
// A title and a URL which are used across PRE_MyTest and MyTest.
const char kBookmarkTitle[] = "Title";
const char kBookmarkPageUrl[] = "http://www.foo.com/";
class SingleClientBookmarksSyncTest : public SyncTest { class SingleClientBookmarksSyncTest : public SyncTest {
public: public:
SingleClientBookmarksSyncTest() : SyncTest(SINGLE_CLIENT) {} SingleClientBookmarksSyncTest() : SyncTest(SINGLE_CLIENT) {}
...@@ -1238,7 +1242,6 @@ IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, ...@@ -1238,7 +1242,6 @@ IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest,
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
SingleClientBookmarksSyncTestWithDisabledReuploadBookmarks, SingleClientBookmarksSyncTestWithDisabledReuploadBookmarks,
PRE_ShouldNotReploadUponFaviconLoad) { PRE_ShouldNotReploadUponFaviconLoad) {
const GURL url = GURL("http://www.foo.com");
fake_server::EntityBuilderFactory entity_builder_factory; fake_server::EntityBuilderFactory entity_builder_factory;
fake_server::BookmarkEntityBuilder bookmark_builder = fake_server::BookmarkEntityBuilder bookmark_builder =
entity_builder_factory.NewBookmarkEntityBuilder("Foo Title"); entity_builder_factory.NewBookmarkEntityBuilder("Foo Title");
...@@ -1247,14 +1250,17 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1247,14 +1250,17 @@ IN_PROC_BROWSER_TEST_F(
// that it's a legacy bookmark means any locally-produced specifics would be // that it's a legacy bookmark means any locally-produced specifics would be
// different for this bookmark (new fields like GUID would be populated). // different for this bookmark (new fields like GUID would be populated).
std::unique_ptr<syncer::LoopbackServerEntity> bookmark = std::unique_ptr<syncer::LoopbackServerEntity> bookmark =
bookmark_builder.BuildBookmark(url, /*is_legacy=*/true); bookmark_builder.BuildBookmark(GURL(kBookmarkPageUrl),
/*is_legacy=*/true);
ASSERT_TRUE(bookmark.get()->GetSpecifics().bookmark().guid().empty()); ASSERT_TRUE(bookmark.get()->GetSpecifics().bookmark().guid().empty());
fake_server_->InjectEntity(std::move(bookmark)); fake_server_->InjectEntity(std::move(bookmark));
// Start syncing. // Start syncing.
DisableVerifier(); DisableVerifier();
ASSERT_TRUE(SetupSync()); ASSERT_TRUE(SetupSync());
ASSERT_TRUE(BookmarksUrlChecker(kSingleProfileIndex, url, 1).Wait()); ASSERT_TRUE(
BookmarksUrlChecker(kSingleProfileIndex, GURL(kBookmarkPageUrl), 1)
.Wait());
} }
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
...@@ -1264,10 +1270,10 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1264,10 +1270,10 @@ IN_PROC_BROWSER_TEST_F(
const std::string title = "Title"; const std::string title = "Title";
const std::string new_title = "New Title"; const std::string new_title = "New Title";
const GURL page_url = GURL("http://www.foo.com");
const GURL icon_url("http://www.google.com/favicon.ico"); const GURL icon_url("http://www.google.com/favicon.ico");
const BookmarkNode* bookmark = AddURL(kSingleProfileIndex, title, page_url); const BookmarkNode* bookmark =
AddURL(kSingleProfileIndex, title, GURL(kBookmarkPageUrl));
SetFavicon(0, bookmark, icon_url, CreateFavicon(SK_ColorWHITE), SetFavicon(0, bookmark, icon_url, CreateFavicon(SK_ColorWHITE),
bookmarks_helper::FROM_UI); bookmarks_helper::FROM_UI);
...@@ -1275,7 +1281,8 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1275,7 +1281,8 @@ IN_PROC_BROWSER_TEST_F(
UpdatedProgressMarkerChecker(GetSyncService(kSingleProfileIndex)).Wait()); UpdatedProgressMarkerChecker(GetSyncService(kSingleProfileIndex)).Wait());
ASSERT_TRUE(bookmarks_helper::ServerBookmarksEqualityChecker( ASSERT_TRUE(bookmarks_helper::ServerBookmarksEqualityChecker(
GetSyncService(kSingleProfileIndex), GetFakeServer(), GetSyncService(kSingleProfileIndex), GetFakeServer(),
{{title, page_url}}, /*cryptographer=*/nullptr) {{title, GURL(kBookmarkPageUrl)}},
/*cryptographer=*/nullptr)
.Wait()); .Wait());
// Stop Sync and update local entity to enter in unsynced state. // Stop Sync and update local entity to enter in unsynced state.
...@@ -1324,7 +1331,8 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1324,7 +1331,8 @@ IN_PROC_BROWSER_TEST_F(
ASSERT_TRUE(GetClient(kSingleProfileIndex)->AwaitEngineInitialization()); ASSERT_TRUE(GetClient(kSingleProfileIndex)->AwaitEngineInitialization());
ASSERT_TRUE(bookmarks_helper::ServerBookmarksEqualityChecker( ASSERT_TRUE(bookmarks_helper::ServerBookmarksEqualityChecker(
GetSyncService(kSingleProfileIndex), GetFakeServer(), GetSyncService(kSingleProfileIndex), GetFakeServer(),
{{new_title, url}}, /*cryptographer=*/nullptr) {{new_title, url}},
/*cryptographer=*/nullptr)
.Wait()); .Wait());
// Last commit should initiate favicon loading. // Last commit should initiate favicon loading.
...@@ -1392,15 +1400,11 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1392,15 +1400,11 @@ IN_PROC_BROWSER_TEST_F(
fake_server_->InjectEntity(std::move(remote_folder)); fake_server_->InjectEntity(std::move(remote_folder));
ASSERT_TRUE(SetupSync()); ASSERT_TRUE(SetupSync());
ASSERT_TRUE( ASSERT_TRUE(bookmarks_helper::ServerBookmarksEqualityChecker(
UpdatedProgressMarkerChecker(GetSyncService(kSingleProfileIndex)).Wait()); GetSyncService(kSingleProfileIndex), GetFakeServer(),
{{title, /*url=*/GURL()}},
const std::vector<sync_pb::SyncEntity> server_bookmarks = /*cryptographer=*/nullptr)
GetFakeServer()->GetSyncEntitiesByModelType(syncer::BOOKMARKS); .Wait());
ASSERT_EQ(1u, CountFoldersWithTitlesMatching(kSingleProfileIndex, title));
ASSERT_EQ(1u, server_bookmarks.size());
EXPECT_TRUE(server_bookmarks.front().specifics().bookmark().has_full_title());
} }
// This test looks similar to // This test looks similar to
...@@ -1414,22 +1418,16 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1414,22 +1418,16 @@ IN_PROC_BROWSER_TEST_F(
// locally. // locally.
ASSERT_TRUE(SetupSync()); ASSERT_TRUE(SetupSync());
const std::string title = "Title";
const GURL url = GURL("http://www.foo.com");
// Make an incremental remote creation of bookmark without full_title. // Make an incremental remote creation of bookmark without full_title.
fake_server::EntityBuilderFactory entity_builder_factory; fake_server::EntityBuilderFactory entity_builder_factory;
fake_server::BookmarkEntityBuilder bookmark_builder = fake_server::BookmarkEntityBuilder bookmark_builder =
entity_builder_factory.NewBookmarkEntityBuilder(title); entity_builder_factory.NewBookmarkEntityBuilder(kBookmarkTitle);
std::unique_ptr<syncer::LoopbackServerEntity> remote_folder = std::unique_ptr<syncer::LoopbackServerEntity> remote_folder =
bookmark_builder.BuildBookmark(url, /*is_legacy=*/false); bookmark_builder.BuildBookmarkWithoutFullTitle(GURL(kBookmarkPageUrl));
const std::string new_guid = remote_folder->GetSpecifics().bookmark().guid();
// Makr sure that server-side specifics doesn't have full title.
remote_folder->GetSpecifics().mutable_bookmark()->clear_full_title();
fake_server_->InjectEntity(std::move(remote_folder)); fake_server_->InjectEntity(std::move(remote_folder));
ASSERT_TRUE(BookmarksTitleChecker(kSingleProfileIndex, title, ASSERT_TRUE(BookmarksTitleChecker(kSingleProfileIndex, kBookmarkTitle,
/*expected_count=*/1) /*expected_count=*/1)
.Wait()); .Wait());
} }
...@@ -1439,16 +1437,15 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1439,16 +1437,15 @@ IN_PROC_BROWSER_TEST_F(
ShouldReuploadFullTitleForOldClients) { ShouldReuploadFullTitleForOldClients) {
// This test checks that the legacy bookmark which was stored locally will // This test checks that the legacy bookmark which was stored locally will
// imply reupload to the server when reupload feature is enabled. // imply reupload to the server when reupload feature is enabled.
const GURL url = GURL("http://www.foo.com");
ASSERT_EQ( ASSERT_EQ(
1u, 1u,
GetFakeServer()->GetSyncEntitiesByModelType(syncer::BOOKMARKS).size()); GetFakeServer()->GetSyncEntitiesByModelType(syncer::BOOKMARKS).size());
const int64_t old_server_version = ASSERT_FALSE(GetFakeServer()
GetFakeServer()
->GetSyncEntitiesByModelType(syncer::BOOKMARKS) ->GetSyncEntitiesByModelType(syncer::BOOKMARKS)
.front() .front()
.version(); .specifics()
.bookmark()
.has_full_title());
ASSERT_TRUE(SetupClients()); ASSERT_TRUE(SetupClients());
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// signin::SetRefreshTokenForPrimaryAccount() is needed on ChromeOS in order // signin::SetRefreshTokenForPrimaryAccount() is needed on ChromeOS in order
...@@ -1456,20 +1453,14 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1456,20 +1453,14 @@ IN_PROC_BROWSER_TEST_F(
GetClient(0)->SignInPrimaryAccount(); GetClient(0)->SignInPrimaryAccount();
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
ASSERT_TRUE(GetClient(kSingleProfileIndex)->AwaitEngineInitialization()); ASSERT_TRUE(GetClient(kSingleProfileIndex)->AwaitEngineInitialization());
ASSERT_TRUE(BookmarkFaviconLoadedChecker(kSingleProfileIndex, url).Wait());
ASSERT_TRUE( ASSERT_TRUE(
UpdatedProgressMarkerChecker(GetSyncService(kSingleProfileIndex)).Wait()); BookmarkFaviconLoadedChecker(kSingleProfileIndex, GURL(kBookmarkPageUrl))
ASSERT_GT(GetFakeServer() .Wait());
->GetSyncEntitiesByModelType(syncer::BOOKMARKS) ASSERT_TRUE(bookmarks_helper::ServerBookmarksEqualityChecker(
.front() GetSyncService(kSingleProfileIndex), GetFakeServer(),
.version(), {{kBookmarkTitle, GURL(kBookmarkPageUrl)}},
old_server_version); /*cryptographer=*/nullptr)
.Wait());
const std::string title = "Title";
const std::vector<sync_pb::SyncEntity> server_bookmarks =
GetFakeServer()->GetSyncEntitiesByModelType(syncer::BOOKMARKS);
ASSERT_EQ(1u, server_bookmarks.size());
EXPECT_TRUE(server_bookmarks.front().specifics().bookmark().has_full_title());
} }
// TODO(rushans): add the same test as before with favicons. // TODO(rushans): add the same test as before with favicons.
...@@ -1479,28 +1470,18 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1479,28 +1470,18 @@ IN_PROC_BROWSER_TEST_F(
PRE_ShouldReuploadFullTitleAfterRestartOnIncrementalChange) { PRE_ShouldReuploadFullTitleAfterRestartOnIncrementalChange) {
ASSERT_TRUE(SetupSync()); ASSERT_TRUE(SetupSync());
const std::string title = "Title";
const GURL url = GURL("http://www.foo.com");
// Make an incremental remote creation of bookmark. // Make an incremental remote creation of bookmark.
fake_server::EntityBuilderFactory entity_builder_factory; fake_server::EntityBuilderFactory entity_builder_factory;
fake_server::BookmarkEntityBuilder bookmark_builder = fake_server::BookmarkEntityBuilder bookmark_builder =
entity_builder_factory.NewBookmarkEntityBuilder(title); entity_builder_factory.NewBookmarkEntityBuilder(kBookmarkTitle);
std::unique_ptr<syncer::LoopbackServerEntity> remote_folder = std::unique_ptr<syncer::LoopbackServerEntity> remote_folder =
bookmark_builder.BuildBookmarkWithoutFullTitle(url); bookmark_builder.BuildBookmarkWithoutFullTitle(GURL(kBookmarkPageUrl));
ASSERT_FALSE(remote_folder->GetSpecifics().bookmark().has_full_title()); ASSERT_FALSE(remote_folder->GetSpecifics().bookmark().has_full_title());
fake_server_->InjectEntity(std::move(remote_folder)); fake_server_->InjectEntity(std::move(remote_folder));
ASSERT_TRUE(BookmarksTitleChecker(kSingleProfileIndex, title, ASSERT_TRUE(BookmarksTitleChecker(kSingleProfileIndex, kBookmarkTitle,
/*expected_count=*/1) /*expected_count=*/1)
.Wait()); .Wait());
// Check that the full title was not uploaded to the server yet.
const std::vector<sync_pb::SyncEntity> server_bookmarks =
GetFakeServer()->GetSyncEntitiesByModelType(syncer::BOOKMARKS);
ASSERT_EQ(1u, server_bookmarks.size());
EXPECT_FALSE(
server_bookmarks.front().specifics().bookmark().has_full_title());
} }
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
...@@ -1508,7 +1489,16 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1508,7 +1489,16 @@ IN_PROC_BROWSER_TEST_F(
ShouldReuploadFullTitleAfterRestartOnIncrementalChange) { ShouldReuploadFullTitleAfterRestartOnIncrementalChange) {
ASSERT_TRUE(SetupClients()); ASSERT_TRUE(SetupClients());
const GURL url = GURL("http://www.foo.com"); // Check that the full title was not uploaded to the server yet.
ASSERT_EQ(
1u,
GetFakeServer()->GetSyncEntitiesByModelType(syncer::BOOKMARKS).size());
ASSERT_FALSE(GetFakeServer()
->GetSyncEntitiesByModelType(syncer::BOOKMARKS)
.front()
.specifics()
.bookmark()
.has_full_title());
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// signin::SetRefreshTokenForPrimaryAccount() is needed on ChromeOS in order // signin::SetRefreshTokenForPrimaryAccount() is needed on ChromeOS in order
...@@ -1516,15 +1506,14 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1516,15 +1506,14 @@ IN_PROC_BROWSER_TEST_F(
GetClient(0)->SignInPrimaryAccount(); GetClient(0)->SignInPrimaryAccount();
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
ASSERT_TRUE(GetClient(kSingleProfileIndex)->AwaitEngineInitialization()); ASSERT_TRUE(GetClient(kSingleProfileIndex)->AwaitEngineInitialization());
ASSERT_TRUE(BookmarkFaviconLoadedChecker(kSingleProfileIndex, url).Wait());
ASSERT_TRUE( ASSERT_TRUE(
UpdatedProgressMarkerChecker(GetSyncService(kSingleProfileIndex)).Wait()); BookmarkFaviconLoadedChecker(kSingleProfileIndex, GURL(kBookmarkPageUrl))
.Wait());
const std::string title = "Title"; ASSERT_TRUE(bookmarks_helper::ServerBookmarksEqualityChecker(
const std::vector<sync_pb::SyncEntity> server_bookmarks = GetSyncService(kSingleProfileIndex), GetFakeServer(),
GetFakeServer()->GetSyncEntitiesByModelType(syncer::BOOKMARKS); {{kBookmarkTitle, GURL(kBookmarkPageUrl)}},
ASSERT_EQ(1u, server_bookmarks.size()); /*cryptographer=*/nullptr)
EXPECT_TRUE(server_bookmarks.front().specifics().bookmark().has_full_title()); .Wait());
} }
} // namespace } // namespace
...@@ -201,18 +201,20 @@ class SingleClientCustomPassphraseUseScryptSyncTest ...@@ -201,18 +201,20 @@ class SingleClientCustomPassphraseUseScryptSyncTest
IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseSyncTest, IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseSyncTest,
CommitsEncryptedData) { CommitsEncryptedData) {
const std::string title1 = "Hello world";
const std::string title2 = "Bookmark #2";
const GURL page_url1("https://google.com/");
const GURL page_url2("https://example.com/");
SetEncryptionPassphraseForClient(/*index=*/0, "hunter2"); SetEncryptionPassphraseForClient(/*index=*/0, "hunter2");
ASSERT_TRUE(SetupSync()); ASSERT_TRUE(SetupSync());
ASSERT_TRUE( ASSERT_TRUE(AddURL(/*profile=*/0, title1, page_url1));
AddURL(/*profile=*/0, "Hello world", GURL("https://google.com/"))); ASSERT_TRUE(AddURL(/*profile=*/0, title2, page_url2));
ASSERT_TRUE(
AddURL(/*profile=*/0, "Bookmark #2", GURL("https://example.com/")));
ASSERT_TRUE(WaitForNigori(PassphraseType::kCustomPassphrase)); ASSERT_TRUE(WaitForNigori(PassphraseType::kCustomPassphrase));
EXPECT_TRUE(WaitForEncryptedServerBookmarks( EXPECT_TRUE(WaitForEncryptedServerBookmarks(
{{"Hello world", GURL("https://google.com/")}, {{title1, page_url1}, {title2, page_url2}},
{"Bookmark #2", GURL("https://example.com/")}},
/*passphrase=*/"hunter2")); /*passphrase=*/"hunter2"));
} }
...@@ -261,36 +263,38 @@ IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseSyncTest, ...@@ -261,36 +263,38 @@ IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseSyncTest,
IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest, IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest,
CommitsEncryptedDataUsingPbkdf2WhenScryptDisabled) { CommitsEncryptedDataUsingPbkdf2WhenScryptDisabled) {
const std::string title = "PBKDF2 encrypted";
const GURL page_url("https://google.com/pbkdf2-encrypted");
SetEncryptionPassphraseForClient(/*index=*/0, "hunter2"); SetEncryptionPassphraseForClient(/*index=*/0, "hunter2");
ASSERT_TRUE(SetupSync()); ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AddURL(/*profile=*/0, "PBKDF2 encrypted", ASSERT_TRUE(AddURL(/*profile=*/0, title, page_url));
GURL("https://google.com/pbkdf2-encrypted")));
ASSERT_TRUE(WaitForNigori(PassphraseType::kCustomPassphrase)); ASSERT_TRUE(WaitForNigori(PassphraseType::kCustomPassphrase));
NigoriSpecifics nigori; NigoriSpecifics nigori;
EXPECT_TRUE(GetServerNigori(GetFakeServer(), &nigori)); EXPECT_TRUE(GetServerNigori(GetFakeServer(), &nigori));
EXPECT_EQ(nigori.custom_passphrase_key_derivation_method(), EXPECT_EQ(nigori.custom_passphrase_key_derivation_method(),
sync_pb::NigoriSpecifics::PBKDF2_HMAC_SHA1_1003); sync_pb::NigoriSpecifics::PBKDF2_HMAC_SHA1_1003);
EXPECT_TRUE(WaitForEncryptedServerBookmarks( EXPECT_TRUE(WaitForEncryptedServerBookmarks({{title, page_url}},
{{"PBKDF2 encrypted", GURL("https://google.com/pbkdf2-encrypted")}},
/*passphrase=*/"hunter2")); /*passphrase=*/"hunter2"));
} }
IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseUseScryptSyncTest, IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseUseScryptSyncTest,
CommitsEncryptedDataUsingScryptWhenScryptEnabled) { CommitsEncryptedDataUsingScryptWhenScryptEnabled) {
const std::string title = "scrypt encrypted";
const GURL page_url("https://google.com/scrypt-encrypted");
SetEncryptionPassphraseForClient(/*index=*/0, "hunter2"); SetEncryptionPassphraseForClient(/*index=*/0, "hunter2");
ASSERT_TRUE(SetupSync()); ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AddURL(/*profile=*/0, "scrypt encrypted", ASSERT_TRUE(AddURL(/*profile=*/0, title, page_url));
GURL("https://google.com/scrypt-encrypted")));
ASSERT_TRUE(WaitForNigori(PassphraseType::kCustomPassphrase)); ASSERT_TRUE(WaitForNigori(PassphraseType::kCustomPassphrase));
NigoriSpecifics nigori; NigoriSpecifics nigori;
EXPECT_TRUE(GetServerNigori(GetFakeServer(), &nigori)); EXPECT_TRUE(GetServerNigori(GetFakeServer(), &nigori));
EXPECT_EQ(nigori.custom_passphrase_key_derivation_method(), EXPECT_EQ(nigori.custom_passphrase_key_derivation_method(),
sync_pb::NigoriSpecifics::SCRYPT_8192_8_11); sync_pb::NigoriSpecifics::SCRYPT_8192_8_11);
EXPECT_TRUE(WaitForEncryptedServerBookmarks( EXPECT_TRUE(WaitForEncryptedServerBookmarks({{title, page_url}},
{{"scrypt encrypted", GURL("https://google.com/scrypt-encrypted")}},
/*passphrase=*/"hunter2")); /*passphrase=*/"hunter2"));
} }
...@@ -313,12 +317,13 @@ IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest, ...@@ -313,12 +317,13 @@ IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest,
IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest, IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest,
DoesNotLeakUnencryptedData) { DoesNotLeakUnencryptedData) {
const std::string title = "Should be encrypted";
const GURL page_url("https://google.com/encrypted");
SetEncryptionPassphraseForClient(/*index=*/0, "hunter2"); SetEncryptionPassphraseForClient(/*index=*/0, "hunter2");
ASSERT_TRUE(SetupClients()); ASSERT_TRUE(SetupClients());
// Create local bookmarks before sync is enabled. // Create local bookmarks before sync is enabled.
ASSERT_TRUE(AddURL(/*profile=*/0, "Should be encrypted", ASSERT_TRUE(AddURL(/*profile=*/0, title, page_url));
GURL("https://google.com/encrypted")));
CommittedBookmarkEntityNameObserver observer(GetFakeServer()); CommittedBookmarkEntityNameObserver observer(GetFakeServer());
ASSERT_TRUE(SetupSync()); ASSERT_TRUE(SetupSync());
...@@ -332,19 +337,20 @@ IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest, ...@@ -332,19 +337,20 @@ IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest,
// once, we are certain that no bookmarks other than those we've verified to // once, we are certain that no bookmarks other than those we've verified to
// be encrypted have been committed. // be encrypted have been committed.
EXPECT_TRUE(WaitForEncryptedServerBookmarks( EXPECT_TRUE(WaitForEncryptedServerBookmarks(
{{"Should be encrypted", GURL("https://google.com/encrypted")}}, {{title, page_url}},
{KeyDerivationParams::CreateForPbkdf2(), "hunter2"})); {KeyDerivationParams::CreateForPbkdf2(), "hunter2"}));
EXPECT_THAT(observer.GetCommittedEntityNames(), ElementsAre("encrypted")); EXPECT_THAT(observer.GetCommittedEntityNames(), ElementsAre("encrypted"));
} }
IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest, IN_PROC_BROWSER_TEST_F(SingleClientCustomPassphraseDoNotUseScryptSyncTest,
ReencryptsDataWhenPassphraseIsSet) { ReencryptsDataWhenPassphraseIsSet) {
const std::string title = "Re-encryption is great";
const GURL page_url("https://google.com/re-encrypted");
ASSERT_TRUE(SetupSync()); ASSERT_TRUE(SetupSync());
ASSERT_TRUE(WaitForNigori(PassphraseType::kKeystorePassphrase)); ASSERT_TRUE(WaitForNigori(PassphraseType::kKeystorePassphrase));
ASSERT_TRUE(AddURL(/*profile=*/0, "Re-encryption is great", ASSERT_TRUE(AddURL(/*profile=*/0, title, page_url));
GURL("https://google.com/re-encrypted"))); const std::vector<ServerBookmarksEqualityChecker::ExpectedBookmark> expected =
std::vector<ServerBookmarksEqualityChecker::ExpectedBookmark> expected = { {{title, page_url}};
{"Re-encryption is great", GURL("https://google.com/re-encrypted")}};
ASSERT_TRUE(WaitForUnencryptedServerBookmarks(expected)); ASSERT_TRUE(WaitForUnencryptedServerBookmarks(expected));
GetSyncService()->GetUserSettings()->SetEncryptionPassphrase("hunter2"); GetSyncService()->GetUserSettings()->SetEncryptionPassphrase("hunter2");
......
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