Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 847032 - add unit test for HELO bypass; expose console.log to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
asutherland committed Sep 13, 2013
1 parent 8459b88 commit 3dc7eb7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion node-deps/simplesmtp
Submodule simplesmtp updated 1 files
+34 −15 lib/client.js
48 changes: 48 additions & 0 deletions test/unit/test_smtp_prober.js
Expand Up @@ -52,6 +52,7 @@ function makeCredsAndConnInfo() {
} }


TD.commonCase('timeout failure', function(T, RT) { TD.commonCase('timeout failure', function(T, RT) {
$th_imap.thunkConsoleForNonTestUniverse();
var eCheck = T.lazyLogger('check'), var eCheck = T.lazyLogger('check'),
prober = null; prober = null;


Expand All @@ -74,6 +75,7 @@ TD.commonCase('timeout failure', function(T, RT) {
}); });


TD.commonCase('SSL failure', function(T, RT) { TD.commonCase('SSL failure', function(T, RT) {
$th_imap.thunkConsoleForNonTestUniverse();
var eCheck = T.lazyLogger('check'), var eCheck = T.lazyLogger('check'),
prober = null; prober = null;


Expand All @@ -96,6 +98,7 @@ var SMTP_GREETING = '220 localhost ESMTP Fake\r\n';
var SMTP_EHLO_RESPONSE = '250 AUTH PLAIN\r\n'; var SMTP_EHLO_RESPONSE = '250 AUTH PLAIN\r\n';


TD.commonCase('STARTTLS unsupported', function(T, RT) { TD.commonCase('STARTTLS unsupported', function(T, RT) {
$th_imap.thunkConsoleForNonTestUniverse();
var eCheck = T.lazyLogger('check'), var eCheck = T.lazyLogger('check'),
prober = null; prober = null;


Expand Down Expand Up @@ -142,7 +145,52 @@ TD.commonCase('STARTTLS unsupported', function(T, RT) {
}); });
}); });


/**
* Make sure that we fail if a server only supports HELO in a context where we
* want to perform a startTLS upgrade.
*/
TD.commonCase('EHLO unsupported does not bypass startTLS', function(T, RT) {
$th_imap.thunkConsoleForNonTestUniverse();
var eCheck = T.lazyLogger('check'),
prober = null;

var fireTimeout = thunkSmtpTimeouts(eCheck);
var cci = makeCredsAndConnInfo();

cci.connInfo.port = 25;
cci.connInfo.crypto = 'starttls';

T.action(eCheck, 'create prober, see STARTTLS error', function() {
FawltySocketFactory.precommand(
HOST, cci.connInfo.port,
{
cmd: 'fake',
data: SMTP_GREETING,
},
[
{
match: true,
actions: [
{
cmd: 'fake-receive',
data: '500 I hate EHLO\r\n',
},
],
},
]);
eCheck.expect_namedValue('smtp:setTimeout', $smtpprobe.CONNECT_TIMEOUT_MS);
prober = new $smtpprobe.SmtpProber(cci.credentials, cci.connInfo);
prober.onresult = function(err) {
eCheck.namedValue('probe result', err);
};
eCheck.expect_event('smtp:clearTimeout');
eCheck.expect_namedValue('probe result', 'bad-security');
});
});


function cannedLoginTest(T, RT, opts) { function cannedLoginTest(T, RT, opts) {
$th_imap.thunkConsoleForNonTestUniverse();
var eCheck = T.lazyLogger('check'); var eCheck = T.lazyLogger('check');


var fireTimeout = thunkSmtpTimeouts(eCheck), var fireTimeout = thunkSmtpTimeouts(eCheck),
Expand Down

0 comments on commit 3dc7eb7

Please sign in to comment.