Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[test] Add test for maxHttpBufferSize option with websocket (#499)
  • Loading branch information
darrachequesne committed Apr 27, 2017
1 parent 519fb8d commit 82ed65f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -201,7 +201,7 @@ to a single process.
packet (`25000`)
- `upgradeTimeout` (`Number`): how many ms before an uncompleted transport upgrade is cancelled (`10000`)
- `maxHttpBufferSize` (`Number`): how many bytes or characters a message
can be when polling, before closing the session (to avoid DoS). Default
can be, before closing the session (to avoid DoS). Default
value is `10E7`.
- `allowRequest` (`Function`): A function that receives a given handshake
or upgrade request as its first parameter, and can decide whether to
Expand Down
24 changes: 22 additions & 2 deletions test/server.js
Expand Up @@ -1143,14 +1143,34 @@ describe('server', function () {
var socket = new eioc.Socket('ws://localhost:%d'.s(port));
engine.on('connection', function (conn) {
conn.on('message', function (msg) {
console.log(msg);
done(new Error('Test invalidation (message is longer than allowed)'));
});
});
socket.on('open', function () {
socket.send('aasdasdakjhasdkjhasdkjhasdkjhasdkjhasdkjhasdkjha');
});
socket.on('close', function () {
done();
});
});
});

it('should not be receiving data when getting a message longer than maxHttpBufferSize (websocket)', function (done) {
var opts = { maxHttpBufferSize: 5 };
var engine = listen(opts, function (port) {
var socket = new eioc.Socket('ws://localhost:%d'.s(port), { transports: ['websocket'] });
engine.on('connection', function (conn) {
conn.on('message', function (msg) {
done(new Error('Test invalidation (message is longer than allowed)'));
});
});
socket.on('open', function () {
socket.send('aasdasdakjhasdkjhasdkjhasdkjhasdkjhasdkjhasdkjha');
});
socket.on('close', function () {
done();
});
});
setTimeout(done, 1000);
});

it('should receive data when getting a message shorter than maxHttpBufferSize when polling', function (done) {
Expand Down

0 comments on commit 82ed65f

Please sign in to comment.