2012-09-24 13:45:49 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
2010-06-17 08:47:13 -07:00
|
|
|
Cu.import("resource://services-sync/service.js");
|
2010-08-25 15:49:45 -07:00
|
|
|
Cu.import("resource://services-sync/util.js");
|
2012-09-24 13:45:49 -07:00
|
|
|
Cu.import("resource://testing-common/services/sync/utils.js");
|
2010-06-17 08:47:13 -07:00
|
|
|
|
|
|
|
function run_test() {
|
2010-08-02 22:37:13 -07:00
|
|
|
do_test_pending();
|
2010-06-17 08:47:13 -07:00
|
|
|
let server = httpd_setup({
|
2011-01-14 13:22:20 -08:00
|
|
|
"/user/1.0/johndoe": httpd_handler(200, "OK", "1"),
|
|
|
|
"/user/1.0/janedoe": httpd_handler(200, "OK", "0"),
|
2010-09-13 08:17:37 -07:00
|
|
|
// john@doe.com
|
2011-01-14 13:22:20 -08:00
|
|
|
"/user/1.0/7wohs32cngzuqt466q3ge7indszva4of": httpd_handler(200, "OK", "0"),
|
2010-09-15 03:54:33 -07:00
|
|
|
// jane@doe.com
|
2011-01-14 13:22:20 -08:00
|
|
|
"/user/1.0/vuuf3eqgloxpxmzph27f5a6ve7gzlrms": httpd_handler(200, "OK", "1")
|
2010-06-17 08:47:13 -07:00
|
|
|
});
|
|
|
|
try {
|
2012-02-06 09:50:11 -08:00
|
|
|
Service.serverURL = TEST_SERVER_URL;
|
2010-06-17 08:47:13 -07:00
|
|
|
|
|
|
|
_("A 404 will be recorded as 'generic-server-error'");
|
2011-03-25 00:57:23 -07:00
|
|
|
do_check_eq(Service.checkAccount("jimdoe"), "generic-server-error");
|
2010-09-15 03:54:33 -07:00
|
|
|
|
|
|
|
_("Account that's available.");
|
|
|
|
do_check_eq(Service.checkAccount("john@doe.com"), "available");
|
2010-06-17 08:47:13 -07:00
|
|
|
|
2010-09-13 08:17:37 -07:00
|
|
|
_("Account that's not available.");
|
2010-09-15 03:54:33 -07:00
|
|
|
do_check_eq(Service.checkAccount("jane@doe.com"), "notAvailable");
|
2010-06-17 08:47:13 -07:00
|
|
|
|
2011-03-25 00:57:23 -07:00
|
|
|
_("Username fallback: Account that's not available.");
|
|
|
|
do_check_eq(Service.checkAccount("johndoe"), "notAvailable");
|
2010-09-13 08:17:37 -07:00
|
|
|
|
2011-03-25 00:57:23 -07:00
|
|
|
_("Username fallback: Account that's available.");
|
|
|
|
do_check_eq(Service.checkAccount("janedoe"), "available");
|
2010-06-17 08:47:13 -07:00
|
|
|
|
|
|
|
} finally {
|
2010-08-25 15:49:45 -07:00
|
|
|
Svc.Prefs.resetBranch("");
|
2010-08-02 22:37:13 -07:00
|
|
|
server.stop(do_test_finished);
|
2010-06-17 08:47:13 -07:00
|
|
|
}
|
|
|
|
}
|