Skip to content

Commit

Permalink
emit secure instead of secureConnection to avoid node 0.6 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Feb 3, 2012
1 parent 3020ce8 commit 70361f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ will be emitted as an `'error'` event on the stream object but you can provide
your own authorization logic by doing:

``` js
stream.on('secureConnect', function (ack) {
stream.on('secure', function (ack) {
if (...) ack.accept()
else ack.reject()
})
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports.connect = function () {
}
else if (tlsOpts) {
stream = tls.connect(port, host, tlsOpts, function () {
var pending = stream.listeners('secureConnect').length;
var pending = stream.listeners('secure').length;
var allOk = pending === 0 ? stream.authorized : true;
if (pending === 0) done()
else {
Expand All @@ -51,7 +51,7 @@ exports.connect = function () {
if (--pending === 0) done();
}
};
stream.emit('secureConnect', ack);
stream.emit('secure', ack);
}

function done () {
Expand Down
10 changes: 5 additions & 5 deletions test/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function makeServer () {
return server;
}

test('TLS - unauthorized', {timeout: 1000}, function(t) {
test('TLS - unauthorized', function (t) {
t.plan(2);
var options = { tls: true };
var server = makeServer();
Expand All @@ -41,7 +41,7 @@ test('TLS - unauthorized', {timeout: 1000}, function(t) {
});
});

test('TLS - unauthorized with callback', {timeout: 1000}, function(t) {
test('TLS - unauthorized with callback', function (t) {
t.plan(3);

var server = makeServer();
Expand All @@ -56,14 +56,14 @@ test('TLS - unauthorized with callback', {timeout: 1000}, function(t) {
})
});

c.on('secureConnect', function (ack) {
c.on('secure', function (ack) {
t.ok(!c.authorized);
ack.accept();
});
});
});

test('TLS - authorized', {timeout: 1000}, function(t) {
test('TLS - authorized', function (t) {
t.plan(3);

var server = makeServer();
Expand All @@ -81,7 +81,7 @@ test('TLS - authorized', {timeout: 1000}, function(t) {
})
});

c.on('secureConnect', function (ack) {
c.on('secure', function (ack) {
t.ok(c.authorized, "should be authorized");
if (c.authorized) ack.accept()
else ack.reject()
Expand Down

0 comments on commit 70361f0

Please sign in to comment.