Skip to content

Commit

Permalink
Additional SSL tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Kovanen committed Nov 24, 2014
1 parent 86e1e6f commit 0a100b0
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -25,7 +25,7 @@
"mocha": "1.12.0",
"expect.js": "0.2.0",
"superagent": "0.15.4",
"engine.io-client": "rase-/engine.io-client#9e7212",
"engine.io-client": "rase-/engine.io-client#3337a5",
"s": "0.1.1"
},
"scripts": { "test" : "make test" },
Expand Down
Binary file added test/fixtures/client.pfx
Binary file not shown.
117 changes: 116 additions & 1 deletion test/server.js
Expand Up @@ -1265,11 +1265,49 @@ describe('server', function () {
cert: fs.readFileSync('test/fixtures/server.crt'),
ca: fs.readFileSync('test/fixtures/ca.crt'),
requestCert: true,
rejectUnauthorized: true
};

var opts = {
key: fs.readFileSync('test/fixtures/client.key'),
cert: fs.readFileSync('test/fixtures/client.crt'),
ca: fs.readFileSync('test/fixtures/ca.crt'),
transports: ['polling'],
};

var srv = https.createServer(srvOpts, function(req, res){
res.writeHead(200);
res.end('hello world\n');
});

var engine = eio({ transports: ['polling'], allowUpgrades: false });
engine.attach(srv);
srv.listen(null, function() {
var port = srv.address().port;
var socket = new eioc.Socket('https://localhost:%d'.s(port), opts);

engine.on('connection', function (conn) {
conn.on('message', function(msg) {
expect(msg).to.be('hello');
done();
});
});

socket.on('open', function() {
socket.send('hello');
});
});
});

it('should send and receive data with ca when not requiring auth (polling)', function(done){
var srvOpts = {
key: fs.readFileSync('test/fixtures/server.key'),
cert: fs.readFileSync('test/fixtures/server.crt'),
ca: fs.readFileSync('test/fixtures/ca.crt'),
requestCert: true
};

var opts = {
ca: fs.readFileSync('test/fixtures/ca.crt'),
transports: ['polling']
};
Expand Down Expand Up @@ -1304,6 +1342,7 @@ describe('server', function () {
cert: fs.readFileSync('test/fixtures/server.crt'),
ca: fs.readFileSync('test/fixtures/ca.crt'),
requestCert: true,
rejectUnauthorized: true
};

var opts = {
Expand Down Expand Up @@ -1337,8 +1376,84 @@ describe('server', function () {
});
});

});
it('should send and receive data with pfx (polling)', function(done){
var srvOpts = {
key: fs.readFileSync('test/fixtures/server.key'),
cert: fs.readFileSync('test/fixtures/server.crt'),
ca: fs.readFileSync('test/fixtures/ca.crt'),
requestCert: true,
rejectUnauthorized: true
};

var opts = {
pfx: fs.readFileSync('test/fixtures/client.pfx'),
ca: fs.readFileSync('test/fixtures/ca.crt'),
transports: ['polling']
};

var srv = https.createServer(srvOpts, function(req, res){
res.writeHead(200);
res.end('hello world\n');
});

var engine = eio({ transports: ['polling'], allowUpgrades: false });
engine.attach(srv);
srv.listen(null, function() {
var port = srv.address().port;
var socket = new eioc.Socket('https://localhost:%d'.s(port), opts);

engine.on('connection', function (conn) {
conn.on('message', function(msg) {
expect(msg).to.be('hello');
done();
});
});

socket.on('open', function() {
socket.send('hello');
});
});
});

it('should send and receive data with pfx (ws)', function(done){
var srvOpts = {
key: fs.readFileSync('test/fixtures/server.key'),
cert: fs.readFileSync('test/fixtures/server.crt'),
ca: fs.readFileSync('test/fixtures/ca.crt'),
requestCert: true,
rejectUnauthorized: true
};

var opts = {
pfx: fs.readFileSync('test/fixtures/client.pfx'),
ca: fs.readFileSync('test/fixtures/ca.crt'),
transports: ['websocket']
};

var srv = https.createServer(srvOpts, function(req, res){
res.writeHead(200);
res.end('hello world\n');
});

var engine = eio({ transports: ['websocket'], allowUpgrades: false });
engine.attach(srv);
srv.listen(null, function() {
var port = srv.address().port;
var socket = new eioc.Socket('https://localhost:%d'.s(port), opts);

engine.on('connection', function (conn) {
conn.on('message', function(msg) {
expect(msg).to.be('hello');
done();
});
});

socket.on('open', function() {
socket.send('hello');
});
});
});
});

describe('send', function() {
describe('writeBuffer', function() {
Expand Down

0 comments on commit 0a100b0

Please sign in to comment.