mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Bug 584486 - Changing password via web leads to unknown error [r=mconnor]
This commit is contained in:
parent
e97c6b419f
commit
3960a68871
@ -1317,8 +1317,6 @@ WeaveSvc.prototype = {
|
|||||||
// we'll handle that later
|
// we'll handle that later
|
||||||
Status.resetBackoff();
|
Status.resetBackoff();
|
||||||
|
|
||||||
this.globalScore = 0;
|
|
||||||
|
|
||||||
// Ping the server with a special info request once a day
|
// Ping the server with a special info request once a day
|
||||||
let infoURL = this.infoURL;
|
let infoURL = this.infoURL;
|
||||||
let now = Math.floor(Date.now() / 1000);
|
let now = Math.floor(Date.now() / 1000);
|
||||||
@ -1330,8 +1328,15 @@ WeaveSvc.prototype = {
|
|||||||
|
|
||||||
// Figure out what the last modified time is for each collection
|
// Figure out what the last modified time is for each collection
|
||||||
let info = new Resource(infoURL).get();
|
let info = new Resource(infoURL).get();
|
||||||
if (!info.success)
|
if (!info.success) {
|
||||||
|
if (info.status == 401) {
|
||||||
|
this.logout();
|
||||||
|
Status.login = LOGIN_FAILED_LOGIN_REJECTED;
|
||||||
|
}
|
||||||
throw "aborting sync, failed to get collections";
|
throw "aborting sync, failed to get collections";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.globalScore = 0;
|
||||||
|
|
||||||
// Convert the response to an object and read out the modified times
|
// Convert the response to an object and read out the modified times
|
||||||
for each (let engine in [Clients].concat(Engines.getAll()))
|
for each (let engine in [Clients].concat(Engines.getAll()))
|
||||||
|
71
services/sync/tests/unit/test_service_sync_401.js
Normal file
71
services/sync/tests/unit/test_service_sync_401.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
Cu.import("resource://services-sync/service.js");
|
||||||
|
|
||||||
|
function login_handler(request, response) {
|
||||||
|
// btoa('johndoe:ilovejane') == am9obmRvZTppbG92ZWphbmU=
|
||||||
|
let body;
|
||||||
|
if (request.hasHeader("Authorization") &&
|
||||||
|
request.getHeader("Authorization") == "Basic am9obmRvZTppbG92ZWphbmU=") {
|
||||||
|
body = "{}";
|
||||||
|
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||||
|
} else {
|
||||||
|
body = "Unauthorized";
|
||||||
|
response.setStatusLine(request.httpVersion, 401, "Unauthorized");
|
||||||
|
}
|
||||||
|
response.bodyOutputStream.write(body, body.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
let logger = Log4Moz.repository.rootLogger;
|
||||||
|
Log4Moz.repository.rootLogger.addAppender(new Log4Moz.DumpAppender());
|
||||||
|
|
||||||
|
do_test_pending();
|
||||||
|
let server = httpd_setup({
|
||||||
|
"/1.0/johndoe/info/collections": login_handler
|
||||||
|
});
|
||||||
|
|
||||||
|
const GLOBAL_SCORE = 42;
|
||||||
|
|
||||||
|
try {
|
||||||
|
_("Set up test fixtures.");
|
||||||
|
Weave.Service.serverURL = "http://localhost:8080/";
|
||||||
|
Weave.Service.clusterURL = "http://localhost:8080/";
|
||||||
|
Weave.Service.username = "johndoe";
|
||||||
|
Weave.Service.password = "ilovejane";
|
||||||
|
Weave.Service.passphrase = "foo";
|
||||||
|
Weave.Service.globalScore = GLOBAL_SCORE;
|
||||||
|
// Avoid daily ping
|
||||||
|
Weave.Svc.Prefs.set("lastPing", Math.floor(Date.now() / 1000));
|
||||||
|
|
||||||
|
let threw = false;
|
||||||
|
Weave.Svc.Obs.add("weave:service:sync:error", function (subject, data) {
|
||||||
|
threw = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
_("Initial state: We're successfully logged in.");
|
||||||
|
Weave.Service.login();
|
||||||
|
do_check_true(Weave.Service.isLoggedIn);
|
||||||
|
do_check_eq(Weave.Status.login, Weave.LOGIN_SUCCEEDED);
|
||||||
|
|
||||||
|
_("Simulate having changed the password somehwere else.");
|
||||||
|
Weave.Service.password = "ilovejosephine";
|
||||||
|
|
||||||
|
_("Let's try to sync.");
|
||||||
|
Weave.Service.sync();
|
||||||
|
|
||||||
|
_("Verify that sync() threw an exception.");
|
||||||
|
do_check_true(threw);
|
||||||
|
|
||||||
|
_("We're no longer logged in.");
|
||||||
|
do_check_false(Weave.Service.isLoggedIn);
|
||||||
|
|
||||||
|
_("Sync status.");
|
||||||
|
do_check_eq(Weave.Status.login, Weave.LOGIN_FAILED_LOGIN_REJECTED);
|
||||||
|
|
||||||
|
_("globalScore is unchanged.");
|
||||||
|
do_check_eq(Weave.Service.globalScore, GLOBAL_SCORE);
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
Weave.Svc.Prefs.resetBranch("");
|
||||||
|
server.stop(do_test_finished);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user