Skip to content

Commit

Permalink
Merge pull request #311 from martynsmith/apeiron/fix-secure-opts
Browse files Browse the repository at this point in the history
Fix option handling when passing a secure object
  • Loading branch information
Chris Nehren committed Jan 21, 2015
2 parents 4ce22d6 + b0cc7c5 commit 8e34f3c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
3 changes: 1 addition & 2 deletions lib/irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ Client.prototype.connect = function(retryCount, callback) {
if (typeof self.opt.secure == 'object') {
// copy "secure" opts to options passed to connect()
for (var f in self.opt.secure) {
if (creds.hasOwnProperty(f))
connectionOpts[f] = self.opt.secure[f];
connectionOpts[f] = self.opt.secure[f];
}
}

Expand Down
38 changes: 28 additions & 10 deletions test/test-irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,41 @@ var expected = testHelpers.getFixtures('basic');
var greeting = ':localhost 001 testbot :Welcome to the Internet Relay Chat Network testbot\r\n';

test('connect, register and quit', function(t) {
runTests(t, false);
runTests(t, false, false);
});

test('connect, register and quit, securely', function(t) {
runTests(t, true);
runTests(t, true, false);
});

function runTests(t, isSecure) {
test('connect, register and quit, securely, with secure object', function(t) {
runTests(t, true, true);
});

function runTests(t, isSecure, useSecureObject) {
var port = isSecure ? 6697 : 6667;
var mock = testHelpers.MockIrcd(port, 'utf-8', isSecure);
var client = new irc.Client('localhost', 'testbot', {
secure: isSecure,
selfSigned: true,
port: port,
retryCount: 0,
debug: true
});
var client;
if (isSecure && useSecureObject) {
client = new irc.Client('notlocalhost', 'testbot', {
secure: {
host: 'localhost',
port: port,
rejectUnauthorized: false
},
selfSigned: true,
retryCount: 0,
debug: true
});
} else {
var client = new irc.Client('localhost', 'testbot', {
secure: isSecure,
selfSigned: true,
port: port,
retryCount: 0,
debug: true
});
}

t.plan(expected.sent.length + expected.received.length);

Expand Down

0 comments on commit 8e34f3c

Please sign in to comment.