Bug 596620 - Remove compat code for username-based UI. r=rnewman
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Fri, 25 Mar 2011 00:57:23 -0700
changeset 67761 a8551b4ae9f0416af49ba4afce73dff421963c5d
parent 67760 5fb27adf75a90394271d0b400e3d7778da687c4a
child 67762 a04fc798eb366a354158920c910469d8bb6bae09
push id19427
push userpweitershausen@mozilla.com
push dateSun, 10 Apr 2011 18:54:44 +0000
treeherdermozilla-central@21ce62e6aebe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs596620
milestone2.0b13pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 596620 - Remove compat code for username-based UI. r=rnewman Also call Weave.Service.createAccount() with right parameters.
services/sync/locales/en-US/errors.properties
services/sync/modules/service.js
services/sync/tests/unit/test_service_checkAccount.js
services/sync/tests/unit/test_service_createAccount.js
services/sync/tests/unit/test_utils_getErrorString.js
--- a/services/sync/locales/en-US/errors.properties
+++ b/services/sync/locales/en-US/errors.properties
@@ -1,12 +1,10 @@
 error.login.reason.network    = Failed to connect to the server
 error.login.reason.synckey    = Wrong Sync Key
-# error.login.reason.password is deprecated.
-error.login.reason.password   = Incorrect username or password
 error.login.reason.account    = Incorrect account name or password
 error.login.reason.no_password= No saved password to use
 error.login.reason.no_synckey = No saved Sync Key to use
 error.login.reason.server     = Server incorrectly configured
 
 error.sync.failed_partial     = One or more data types could not be synced
 
 invalid-captcha = Incorrect words, try again
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -1179,22 +1179,16 @@ WeaveSvc.prototype = {
       return "weak-password";
     default:
       return "generic-server-error";
     }
   },
 
   checkAccount: function checkAccount(account) {
     let username = this._usernameFromAccount(account);
-    return this.checkUsername(username);
-  },
-
-  // Backwards compat with the Firefox UI. Fold into checkAccount() once
-  // bug 595066 has landed.
-  checkUsername: function checkUsername(username) {
     let url = this.userAPI + username;
     let res = new Resource(url);
     res.authenticator = new NoOpAuthenticator();
 
     let data = "";
     try {
       data = res.get();
       if (data.status == 200) {
@@ -1206,28 +1200,19 @@ WeaveSvc.prototype = {
 
     }
     catch(ex) {}
 
     // Convert to the error string, or default to generic on exception.
     return this._errorStr(data);
   },
 
-  createAccount: function createAccount() {
-    // Backwards compat with the Firefox UI. Change to signature to
-    // (email, password, captchaChallenge, captchaResponse) once
-    // bug 595066 has landed.
-    let username, email, password, captchaChallenge, captchaResponse;
-    if (arguments.length == 4) {
-      [email, password, captchaChallenge, captchaResponse] = arguments;
-      username = this._usernameFromAccount(email);
-    } else {
-      [username, password, email, captchaChallenge, captchaResponse] = arguments;
-    }
-
+  createAccount: function createAccount(email, password,
+                                        captchaChallenge, captchaResponse) {
+    let username = this._usernameFromAccount(email);
     let payload = JSON.stringify({
       "password": Utils.encodeUTF8(password),
       "email": email,
       "captcha-challenge": captchaChallenge,
       "captcha-response": captchaResponse
     });
 
     let url = this.userAPI + username;
--- a/services/sync/tests/unit/test_service_checkAccount.js
+++ b/services/sync/tests/unit/test_service_checkAccount.js
@@ -10,29 +10,27 @@ function run_test() {
     "/user/1.0/7wohs32cngzuqt466q3ge7indszva4of": httpd_handler(200, "OK", "0"),
     // jane@doe.com
     "/user/1.0/vuuf3eqgloxpxmzph27f5a6ve7gzlrms": httpd_handler(200, "OK", "1")
   });
   try {
     Service.serverURL = "http://localhost:8080/";
 
     _("A 404 will be recorded as 'generic-server-error'");
-    do_check_eq(Service.checkUsername("jimdoe"), "generic-server-error");
+    do_check_eq(Service.checkAccount("jimdoe"), "generic-server-error");
 
     _("Account that's available.");
     do_check_eq(Service.checkAccount("john@doe.com"), "available");
 
     _("Account that's not available.");
     do_check_eq(Service.checkAccount("jane@doe.com"), "notAvailable");
 
-    // Backwards compat with the Firefox UI. Remove once bug 595066 has landed.
+    _("Username fallback: Account that's not available.");
+    do_check_eq(Service.checkAccount("johndoe"), "notAvailable");
 
-    _("Account that's not available.");
-    do_check_eq(Service.checkUsername("johndoe"), "notAvailable");
-
-    _("Account that's available.");
-    do_check_eq(Service.checkUsername("janedoe"), "available");
+    _("Username fallback: Account that's available.");
+    do_check_eq(Service.checkAccount("janedoe"), "available");
 
   } finally {
     Svc.Prefs.resetBranch("");
     server.stop(do_test_finished);
   }
 }
--- a/services/sync/tests/unit/test_service_createAccount.js
+++ b/services/sync/tests/unit/test_service_createAccount.js
@@ -18,20 +18,17 @@ function run_test() {
 
   do_test_pending();
   let server = httpd_setup({
     // john@doe.com
     "/user/1.0/7wohs32cngzuqt466q3ge7indszva4of": send(200, "OK", "0"),
     // jane@doe.com
     "/user/1.0/vuuf3eqgloxpxmzph27f5a6ve7gzlrms": send(400, "Bad Request", "2"),
     // jim@doe.com
-    "/user/1.0/vz6fhecgw5t3sgx3a4cektoiokyczkqd": send(500, "Server Error", "Server Error"),
-    "/user/1.0/johndoe": send(200, "OK", "0"),
-    "/user/1.0/janedoe": send(400, "Bad Request", "2"),
-    "/user/1.0/jimdoe": send(500, "Server Error", "Server Error")
+    "/user/1.0/vz6fhecgw5t3sgx3a4cektoiokyczkqd": send(500, "Server Error", "Server Error")
   });
   try {
     Service.serverURL = "http://localhost:8080/";
 
     _("Create an account.");
     let res = Service.createAccount("john@doe.com", "mysecretpw",
                                     "challenge", "response");
     do_check_eq(res, null);
@@ -60,31 +57,13 @@ function run_test() {
     do_check_eq(res, "generic-server-error");
 
     _("Admin secret preference is passed as HTTP header token.");
     Svc.Prefs.set("admin-secret", "my-server-secret");
     res = Service.createAccount("john@doe.com", "mysecretpw",
                                 "challenge", "response");
     do_check_eq(secretHeader, "my-server-secret");
 
-
-    // Backwards compat with the Firefox UI. Remove once bug 595066 has landed.
-
-    _("Create an old-style account.");
-    res = Service.createAccount("johndoe", "mysecretpw", "john@doe.com",
-                                "challenge", "response");
-    do_check_eq(res, null);
-
-    _("Invalid captcha or other user-friendly error.");
-    res = Service.createAccount("janedoe", "anothersecretpw", "jane@doe.com",
-                                "challenge", "response");
-    do_check_eq(res, "invalid-captcha");
-
-    _("Generic server error.");
-    res = Service.createAccount("jimdoe", "preciousss", "jim@doe.com",
-                                "challenge", "response");
-    do_check_eq(res, "generic-server-error");
-
   } finally {
     Svc.Prefs.resetBranch("");
     server.stop(do_test_finished);
   }
 }
--- a/services/sync/tests/unit/test_utils_getErrorString.js
+++ b/services/sync/tests/unit/test_utils_getErrorString.js
@@ -1,14 +1,14 @@
 Cu.import("resource://services-sync/util.js");
 
 function run_test() {
   let str;
 
   // we just test whether the returned string includes the
   // string "unknown", should be good enough
  
-  str = Utils.getErrorString("error.login.reason.password");
+  str = Utils.getErrorString("error.login.reason.account");
   do_check_true(str.match(/unknown/i) == null);
 
   str = Utils.getErrorString("foobar");
   do_check_true(str.match(/unknown/i) != null);
 }