Commit 347c098c authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Sync UI: Don't allow setting a passphrase if !EncryptEverythingAllowed

If EncryptEverythingAllowed() was false, then PeopleHandler already
skipped the call to EnableEncryptEverything(), but it did still call
SetEncryptionPassphrase(). That could get users into a weird state
where Sync stopped working.
This CL fixes the issue by also skipping the SetEncryptionPassphrase()
call in case EncryptEverythingAllowed() is false.

Bug: 924847
Change-Id: I3b606e3ea9d0a8f86b865b41eda233dd472cc1eb
Reviewed-on: https://chromium-review.googlesource.com/c/1439299Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#627004}
parent d03db88c
...@@ -546,8 +546,10 @@ void PeopleHandler::HandleSetEncryption(const base::ListValue* args) { ...@@ -546,8 +546,10 @@ void PeopleHandler::HandleSetEncryption(const base::ListValue* args) {
// Don't allow "encrypt all" if the SyncService doesn't allow it. // Don't allow "encrypt all" if the SyncService doesn't allow it.
// The UI is hidden, but the user may have enabled it e.g. by fiddling with // The UI is hidden, but the user may have enabled it e.g. by fiddling with
// the web inspector. // the web inspector.
if (!service->GetUserSettings()->IsEncryptEverythingAllowed()) if (!service->GetUserSettings()->IsEncryptEverythingAllowed()) {
configuration.encrypt_all = false; configuration.encrypt_all = false;
configuration.set_new_passphrase = false;
}
// Note: Data encryption will not occur until configuration is complete // Note: Data encryption will not occur until configuration is complete
// (when the PSS receives its CONFIGURE_DONE notification from the sync // (when the PSS receives its CONFIGURE_DONE notification from the sync
......
...@@ -731,6 +731,8 @@ TEST_F(PeopleHandlerTest, SetNewCustomPassphrase) { ...@@ -731,6 +731,8 @@ TEST_F(PeopleHandlerTest, SetNewCustomPassphrase) {
base::ListValue list_args; base::ListValue list_args;
list_args.AppendString(kTestCallbackId); list_args.AppendString(kTestCallbackId);
list_args.AppendString(args); list_args.AppendString(args);
ON_CALL(*mock_pss_->GetUserSettingsMock(), IsEncryptEverythingAllowed())
.WillByDefault(Return(true));
ON_CALL(*mock_pss_->GetUserSettingsMock(), ON_CALL(*mock_pss_->GetUserSettingsMock(),
IsPassphraseRequiredForDecryption()) IsPassphraseRequiredForDecryption())
.WillByDefault(Return(false)); .WillByDefault(Return(false));
...@@ -1067,11 +1069,6 @@ TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) { ...@@ -1067,11 +1069,6 @@ TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) {
} }
TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) { TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) {
std::string args = GetConfiguration(
NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA);
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
ON_CALL(*mock_pss_->GetUserSettingsMock(), ON_CALL(*mock_pss_->GetUserSettingsMock(),
IsPassphraseRequiredForDecryption()) IsPassphraseRequiredForDecryption())
.WillByDefault(Return(false)); .WillByDefault(Return(false));
...@@ -1080,8 +1077,20 @@ TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) { ...@@ -1080,8 +1077,20 @@ TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) {
SetupInitializedProfileSyncService(); SetupInitializedProfileSyncService();
ON_CALL(*mock_pss_->GetUserSettingsMock(), IsEncryptEverythingAllowed()) ON_CALL(*mock_pss_->GetUserSettingsMock(), IsEncryptEverythingAllowed())
.WillByDefault(Return(false)); .WillByDefault(Return(false));
base::DictionaryValue dict;
dict.SetBoolean("setNewPassphrase", true);
std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(),
"password", ENCRYPT_ALL_DATA);
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), EnableEncryptEverything()) EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), EnableEncryptEverything())
.Times(0); .Times(0);
EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetEncryptionPassphrase(_))
.Times(0);
handler_->HandleSetEncryption(&list_args); handler_->HandleSetEncryption(&list_args);
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
......
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