From 660857771139fd7a62ba64607f9a1d2563eb994c Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Thu, 5 Mar 2015 16:12:51 +1100 Subject: [PATCH] Bug 1081158 - ensure we report all login related errors. r=rnewman --- services/sync/modules/policies.js | 6 ++++++ services/sync/tests/unit/test_errorhandler.js | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/services/sync/modules/policies.js b/services/sync/modules/policies.js index 167dd10dce5..d799cb2356f 100644 --- a/services/sync/modules/policies.js +++ b/services/sync/modules/policies.js @@ -737,6 +737,12 @@ ErrorHandler.prototype = { return true; } + if (Status.login == LOGIN_FAILED_LOGIN_REJECTED) { + // An explicit LOGIN_REJECTED state is always reported (bug 1081158) + this._log.trace("shouldReportError: true (login was rejected)"); + return true; + } + let lastSync = Svc.Prefs.get("lastSync"); if (lastSync && ((Date.now() - Date.parse(lastSync)) > Svc.Prefs.get("errorhandler.networkFailureReportTimeout") * 1000)) { diff --git a/services/sync/tests/unit/test_errorhandler.js b/services/sync/tests/unit/test_errorhandler.js index 4e94fb342bc..c087acc9ff4 100644 --- a/services/sync/tests/unit/test_errorhandler.js +++ b/services/sync/tests/unit/test_errorhandler.js @@ -468,6 +468,24 @@ add_identity_test(this, function test_shouldReportError_master_password() { yield deferred.promise; }); +// Test that even if we don't have a cluster URL, a login failure due to +// authentication errors is always reported. +add_identity_test(this, function test_shouldReportLoginFailureWithNoCluster() { + // Ensure no clusterURL - any error not specific to login should not be reported. + Service.serverURL = ""; + Service.clusterURL = ""; + + // Test explicit "login rejected" state. + Status.resetSync(); + // If we have a LOGIN_REJECTED state, we always report the error. + Status.login = LOGIN_FAILED_LOGIN_REJECTED; + do_check_true(errorHandler.shouldReportError()); + // But any other status with a missing clusterURL is treated as a mid-sync + // 401 (ie, should be treated as a node reassignment) + Status.login = LOGIN_SUCCEEDED; + do_check_false(errorHandler.shouldReportError()); +}); + // XXX - how to arrange for 'Service.identity.basicPassword = null;' in // an fxaccounts environment? add_task(function test_login_syncAndReportErrors_non_network_error() {