diff --git a/data/lib/node-crypto.js b/data/lib/node-crypto.js index dc7cc6c1..0c1c8bc0 100644 --- a/data/lib/node-crypto.js +++ b/data/lib/node-crypto.js @@ -8,6 +8,7 @@ exports.createHash = function(algorithm) { return { update: function(addData) { data += addData; + return this; }, digest: function(encoding) { switch (encoding) { diff --git a/test/unit/test_incoming_prober.js b/test/unit/test_incoming_prober.js index 1a23304e..404c5ebc 100644 --- a/test/unit/test_incoming_prober.js +++ b/test/unit/test_incoming_prober.js @@ -380,6 +380,68 @@ TD.commonCase('POP3 selects preferredAuthMethod', function(T, RT) { }); +/** + * Ensure that APOP authentication works properly. + */ +TD.commonCase('POP3 APOP', function(T, RT) { + if (RT.envOptions.type !== 'pop3') { return; } + + $th_main.thunkConsoleForNonTestUniverse(); + var eCheck = T.lazyLogger('check'), + prober = null; + + var fireTimeout = thunkTimeouts(eCheck); + var cci = makeCredsAndConnInfo(); + + cci.connInfo.port = PORT; + + T.action(eCheck, 'works with APOP', function() { + var precommands = []; + precommands.push({ + match: /APOP/, + actions: [ + { + cmd: 'fake-receive', + data: '+OK\r\n', + }, + ], + }); + precommands.push({ + match: /UIDL 1/, + actions: [ + { + cmd: 'fake-receive', + data: '+OK\r\n', + }, + ], + }); + precommands.push({ + match: /TOP 1/, + actions: [ + { + cmd: 'fake-receive', + data: '+OK\r\n.\r\n', + }, + ], + }); + FawltySocketFactory.precommand( + HOST, PORT, + { + cmd: 'fake', + data: '+OK POP3 Ready \r\n', + }, + precommands); + eCheck.expect_namedValue('incoming:setTimeout', proberTimeout(RT)); + prober = new (proberClass(RT))(cci.credentials, cci.connInfo, eCheck._logger); + prober.onresult = function(err, conn) { + eCheck.namedValue('authMethod', conn.authMethod); + }; + eCheck.expect_event('incoming:clearTimeout'); + eCheck.expect_namedValue('authMethod', 'apop'); + }); +}); + + /** * Some servers (ex: aol.com) will hang-up on us on an auth error with a bad * password.