Skip to content
Snippets Groups Projects
Commit 866d3e11 authored by Brian Warner's avatar Brian Warner Committed by Lloyd Hilaiel
Browse files

update stalled-mysql tests to match new behavior

All wsapi operations now require the database (to update+check the
superSessionToken), so some tests that previously expected operations to
succeed without a database now expect them to fail (generally 503).

wsapi_client.js was changed to pass HTTP errors during
/wsapi/session_context back to the caller, so their response code can be
checked, rather than throwing an error (and preventing any other
assertions from being made).
parent 1b0444d8
No related branches found
No related tags found
No related merge requests found
......@@ -95,7 +95,8 @@ function withCSRF(cfg, context, cb) {
exports.get(cfg, '/wsapi/session_context', context, undefined, function(err, r) {
if (err) return cb(err);
try {
if (r.code !== 200) throw 'http error';
if (r.code !== 200)
return cb({what: "http error", resp: r}); // report first error
context.session = JSON.parse(r.body);
context.sessionStartedAt = new Date().getTime();
cb(null, context.session.csrf_token);
......@@ -109,7 +110,14 @@ function withCSRF(cfg, context, cb) {
exports.post = function(cfg, path, context, postArgs, cb) {
withCSRF(cfg, context, function(err, csrf) {
if (err) return cb(err);
if (err) {
if (err.what == "http error") {
// let the session_context HTTP return code speak for the overall
// POST
return cb(null, err.resp);
}
return cb(err);
}
// parse the server URL (cfg.browserid)
var uObj;
......
......@@ -79,9 +79,8 @@ suite.addBatch({
suite.addBatch({
"ping": {
topic: wsapi.get('/wsapi/ping', {}),
"fails with 500 when db is stalled": function(err, r) {
// address info with a primary address doesn't need db access.
assert.strictEqual(r.code, 500);
"fails with 503 when db is stalled": function(err, r) {
assert.strictEqual(r.code, 503);
}
},
"address_info": {
......@@ -216,7 +215,7 @@ suite.addBatch({
"ping": {
topic: wsapi.get('/wsapi/ping', { }),
"fails": function(err, r) {
assert.strictEqual(r.code, 500);
assert.strictEqual(r.code, 503);
}
},
......@@ -391,15 +390,11 @@ suite.addBatch({
"fails with 404": function(err, r) {
assert.strictEqual(r.code, 404);
}
}
});
// logout doesn't need database, it should still succeed
suite.addBatch({
"logout": {
},
"logout": { // logout needs the database too
topic: wsapi.post('/wsapi/logout', { }),
"succeeds": function(err, r) {
assert.strictEqual(r.code, 200);
"fails with 503": function(err, r) {
assert.strictEqual(r.code, 503);
}
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment