From b8f85e3a20a69ecd7b1c1c00fa9245411205d2b8 Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Mon, 14 Apr 2014 18:22:23 +0200 Subject: [PATCH] Bug 996027 - Ensure that TPS always fakes login into Weave. r=rnewman DONTBUILD --- .../tps/extensions/tps/resource/auth/fxaccounts.jsm | 13 +++++++++++-- .../sync/tps/extensions/tps/resource/auth/sync.jsm | 13 ++++++++++--- services/sync/tps/extensions/tps/resource/tps.jsm | 1 - 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm b/services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm index 043ac040e300..f5daa14be7bc 100644 --- a/services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm +++ b/services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm @@ -79,9 +79,18 @@ var Authentication = { }); try { - return cb.wait(); + cb.wait(); + + if (Weave.Status.login !== Weave.LOGIN_SUCCEEDED) { + Logger.logInfo("Logging into Weave."); + Weave.Service.login(); + Logger.AssertEqual(Weave.Status.login, Weave.LOGIN_SUCCEEDED, + "Weave logged in"); + } + + return true; } catch (error) { - throw new Error("signIn() failed with: " + JSON.stringify(error)); + throw new Error("signIn() failed with: " + error.message); } } }; diff --git a/services/sync/tps/extensions/tps/resource/auth/sync.jsm b/services/sync/tps/extensions/tps/resource/auth/sync.jsm index 34736893ed84..676b17a9189f 100644 --- a/services/sync/tps/extensions/tps/resource/auth/sync.jsm +++ b/services/sync/tps/extensions/tps/resource/auth/sync.jsm @@ -68,9 +68,16 @@ var Authentication = { Weave.Service.identity.basicPassword = account["password"]; Weave.Service.identity.syncKey = account["passphrase"]; - // Fake the login - Weave.Service.login(); - Weave.Svc.Obs.notify("weave:service:setup-complete"); + if (Weave.Status.login !== Weave.LOGIN_SUCCEEDED) { + Logger.logInfo("Logging into Weave."); + Weave.Service.login(); + Logger.AssertEqual(Weave.Status.login, Weave.LOGIN_SUCCEEDED, + "Weave logged in"); + + // Bug 997279: Temporary workaround until we can ensure that Sync itself + // sends this notification for the first login attempt by TPS + Weave.Svc.Obs.notify("weave:service:setup-complete"); + } return true; } diff --git a/services/sync/tps/extensions/tps/resource/tps.jsm b/services/sync/tps/extensions/tps/resource/tps.jsm index 7ff600a4c625..8b8c03ceef7b 100644 --- a/services/sync/tps/extensions/tps/resource/tps.jsm +++ b/services/sync/tps/extensions/tps/resource/tps.jsm @@ -837,7 +837,6 @@ let TPS = { let account = this.fxaccounts_enabled ? this.config.fx_account : this.config.sync_account; Authentication.signIn(account); - this.waitForSetupComplete(); Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status OK"); this.waitForTracking();