Skip to content
Snippets Groups Projects
Commit 16fe1ff2 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

tests for issue #878

parent d16d54e5
No related branches found
No related tags found
No related merge requests found
......@@ -22,61 +22,68 @@ suite.options.error = false;
start_stop.addStartupBatches(suite);
// test posting more than 10kb
suite.addBatch({
"posting more than 10kb": {
topic: function(assertion) {
var cb = this.callback;
var req = http.request({
host: '127.0.0.1',
port: 10002,
path: '/wsapi/authenticate_user',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
method: "POST"
}, function (res) {
cb(null, res);
}).on('error', function (e) {
cb(e);
});
req.write(secrets.weakGenerate(1024 * 10 + 1));
req.end();
},
"fails": function (err, r) {
assert.ok(/socket hang up/.test(err.toString()));
function addTests(port, path) {
// test posting more than 10kb
suite.addBatch({
"posting more than 10kb": {
topic: function(assertion) {
var cb = this.callback;
var req = http.request({
host: '127.0.0.1',
port: port,
path: path,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
method: "POST"
}, function (res) {
cb(null, res);
}).on('error', function (e) {
cb(e);
});
req.write(secrets.weakGenerate(1024 * 10 + 1));
req.end();
},
"fails": function (err, r) {
assert.ok(/socket hang up/.test(err.toString()));
}
}
}
});
});
// test posting more than 10kb with content-length header
suite.addBatch({
"posting more than 10kb with content-length": {
topic: function(assertion) {
var cb = this.callback;
var req = http.request({
host: '127.0.0.1',
port: 10002,
path: '/wsapi/authenticate_user',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 1024 * 10 + 1
},
method: "POST"
}, function (res) {
cb(null, res);
}).on('error', function (e) {
cb(e);
});
req.write(secrets.weakGenerate(1024 * 10 + 1));
req.end();
},
"fails": function (err, r) {
assert.strictEqual(413, r.statusCode);
// test posting more than 10kb with content-length header
suite.addBatch({
"posting more than 10kb with content-length": {
topic: function(assertion) {
var cb = this.callback;
var req = http.request({
host: '127.0.0.1',
port: port,
path: path,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 1024 * 10 + 1
},
method: "POST"
}, function (res) {
cb(null, res);
}).on('error', function (e) {
cb(e);
});
req.write(secrets.weakGenerate(1024 * 10 + 1));
req.end();
},
"fails": function (err, r) {
assert.strictEqual(413, r.statusCode);
}
}
}
});
});
};
// test the browserid process
addTests(10002, '/wsapi/authenticate_user');
// test the verifier
addTests(10000, '/verify');
start_stop.addShutdownBatches(suite);
......
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