Bug 996027 - Ensure that TPS always fakes login into Weave. r=rnewman, a=bkerensa DONTBUILD
authorHenrik Skupin <mail@hskupin.info>
Mon, 14 Apr 2014 18:22:23 +0200
changeset 193059 945e92a1d40941d5ba43f3c4b5ca0da3d5eab7fc
parent 193058 2d1b4d36eef948088f39d03b9bf2ba9377af3e9b
child 193060 4d6c9cf84cd218baa2f366d4b8782f01878fd864
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, bkerensa
bugs996027
milestone30.0a2
Bug 996027 - Ensure that TPS always fakes login into Weave. r=rnewman, a=bkerensa DONTBUILD
services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm
services/sync/tps/extensions/tps/resource/auth/sync.jsm
services/sync/tps/extensions/tps/resource/tps.jsm
--- a/services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm
+++ b/services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm
@@ -74,14 +74,23 @@ var Authentication = {
       return fxAccounts.setSignedInUser(credentials);
     }).then(() => {
       cb(null, true);
     }, error => {
       cb(error, false);
     });
 
     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);
     }
   }
 };
--- a/services/sync/tps/extensions/tps/resource/auth/sync.jsm
+++ b/services/sync/tps/extensions/tps/resource/auth/sync.jsm
@@ -63,15 +63,22 @@ var Authentication = {
     Logger.AssertTrue(account["passphrase"], "Passphrase has been found");
 
     Logger.logInfo("Logging in user: " + account["username"]);
 
     Weave.Service.identity.account = account["username"];
     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;
   }
 };
--- a/services/sync/tps/extensions/tps/resource/tps.jsm
+++ b/services/sync/tps/extensions/tps/resource/tps.jsm
@@ -832,17 +832,16 @@ let TPS = {
     if (Authentication.isLoggedIn && !force) {
       return;
     }
 
     Logger.logInfo("Setting client credentials and login.");
     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();
   },
 
   /**
    * Triggers a sync operation
    *