mirror of
https://github.com/MailHops/mailhops-node.git
synced 2025-05-16 03:40:17 -07:00
Added id check for getIPsFromMailParser
Added more tests for getIPsFromMailParser
This commit is contained in:
parent
f242c6f101
commit
d399507458
@ -140,6 +140,8 @@ module.exports = {
|
|||||||
&& !lastchar.match(/\.|\d|\-/)
|
&& !lastchar.match(/\.|\d|\-/)
|
||||||
&& ( firstchar != '?' && lastchar != '?' )
|
&& ( firstchar != '?' && lastchar != '?' )
|
||||||
&& lastchar != ';'
|
&& lastchar != ';'
|
||||||
|
&& line.toLowerCase().indexOf(' id '+ip) === -1
|
||||||
|
&& parseInt(ip.substring(0,ip.indexOf('.'))) < 240 //IANA-RESERVED
|
||||||
&& regexIp.test(ip)){
|
&& regexIp.test(ip)){
|
||||||
|
|
||||||
ips.unshift( ip );
|
ips.unshift( ip );
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mailhops",
|
"name": "mailhops",
|
||||||
"version": "2.0.5",
|
"version": "2.0.6",
|
||||||
"description": "A nodejs module for interacting with the MailHops API.",
|
"description": "A nodejs module for interacting with the MailHops API.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"x-original-to": "andrew@mailhops.com",
|
"x-original-to": "andrew@mailhops.com",
|
||||||
"delivered-to": "x12669597@homiemail-mx18.g.dreamhost.com",
|
"delivered-to": "x12669597@homiemail-mx18.g.dreamhost.com",
|
||||||
"received": ["from homiemail-a110.g.dreamhost.com (agjbgdcfdbdd.dreamhost.com [69.163.253.130]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by homiemail-mx18.g.dreamhost.com (Postfix) with ESMTPS id 5895D9004034 for <andrew@mailhops.com>; Thu, 8 Dec 2016 16:02:34 -0800 (PST)"
|
"received": ["from homiemail-a110.g.dreamhost.com (agjbgdcfdbdd.dreamhost.com [69.163.253.130]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by homiemail-mx18.g.dreamhost.com (Postfix) with ESMTPS id 5895D9004034 for <andrew@mailhops.com>; Thu, 8 Dec 2016 16:02:34 -0800 (PST)"
|
||||||
, "from homiemail-a110.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a110.g.dreamhost.com (Postfix) with ESMTP id 1BA792004763B for <andrew@mailhops.com>; Thu, 8 Dec 2016 16:02:34 -0800 (PST)"
|
, "from homiemail-a110.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a110.g.dreamhost.com (Postfix) with ESMTP id 15.1.225.42 for <andrew@mailhops.com>; Thu, 8 Dec 2016 16:02:34 -0800 (PST)"
|
||||||
, "from Andrews-MacBook-Pro-4.local (c-67-177-226-240.hsd1.co.comcast.net [67.177.226.240]) (Authenticated sender: andrew@showhops.com) by homiemail-a110.g.dreamhost.com (Postfix) with ESMTPA id F349520047638 for <andrew@mailhops.com>; Thu, 8 Dec 2016 16:02:33 -0800 (PST)"
|
, "from Andrews-MacBook-Pro-4.local (c-67-177-226-240.hsd1.co.comcast.net [67.177.226.240]) (Authenticated sender: andrew@showhops.com) by homiemail-a110.g.dreamhost.com (Postfix) with ESMTPA id F349520047638 for <andrew@mailhops.com>; Thu, 8 Dec 2016 16:02:33 -0800 (PST)"
|
||||||
],
|
],
|
||||||
"dkim-signature": "v=1; a=rsa-sha1; c=relaxed; d=showhops.com; h=message-id :date:from:mime-version:to:subject:content-type :content-transfer-encoding; s=showhops.com; bh=gXjUxcC3bG8U+A3N7 7ELq45N68U=; b=U09iG7hIF9CmUxHZSxHJekgSgfApMkJmTTMDeyXsVSJlMQish ElW8P2UfAd1k2+x+PlrV7vDIxr2NSyWI/qDSuYuQt4GStsfJnS2LVEodzPM0Mfsx yAK16/iGNu87UCnYo6v3xvilyW6D0L4P4RM/NB7ib7NinOUIaWJiMJ/hAk=",
|
"dkim-signature": "v=1; a=rsa-sha1; c=relaxed; d=showhops.com; h=message-id :date:from:mime-version:to:subject:content-type :content-transfer-encoding; s=showhops.com; bh=gXjUxcC3bG8U+A3N7 7ELq45N68U=; b=U09iG7hIF9CmUxHZSxHJekgSgfApMkJmTTMDeyXsVSJlMQish ElW8P2UfAd1k2+x+PlrV7vDIxr2NSyWI/qDSuYuQt4GStsfJnS2LVEodzPM0Mfsx yAK16/iGNu87UCnYo6v3xvilyW6D0L4P4RM/NB7ib7NinOUIaWJiMJ/hAk=",
|
||||||
|
25
test/main.js
25
test/main.js
@ -108,7 +108,6 @@ describe("main", function(){
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a 200 response and route of 10 hops', function(done){
|
it('should return a 200 response and route of 10 hops', function(done){
|
||||||
mailhops.lookup(mailhops.getIPsFromHeader(header), function(err, res, body){
|
mailhops.lookup(mailhops.getIPsFromHeader(header), function(err, res, body){
|
||||||
assert.equal(res.statusCode,200);
|
assert.equal(res.statusCode,200);
|
||||||
@ -147,16 +146,36 @@ describe("main", function(){
|
|||||||
var message = fs.readFileSync(__dirname+'/mailparser.json',{ encoding: 'utf8' });
|
var message = fs.readFileSync(__dirname+'/mailparser.json',{ encoding: 'utf8' });
|
||||||
var ips = mailhops.getIPsFromMailParser(JSON.parse(message));
|
var ips = mailhops.getIPsFromMailParser(JSON.parse(message));
|
||||||
|
|
||||||
it('should return an array of 0 IP addresses', function(done){
|
it('should return an array of 3 IP addresses', function(done){
|
||||||
assert.equal(ips.length,3);
|
assert.equal(ips.length,3);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a time of 0 milliseconds', function(done){
|
it('should return a time of 2000 milliseconds', function(done){
|
||||||
assert.equal(mailhops.timeTraveled(),2000);
|
assert.equal(mailhops.timeTraveled(),2000);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should find 3 Received IPs', function(done){
|
||||||
|
assert.deepEqual(ips,['67.177.226.240',
|
||||||
|
'127.0.0.1',
|
||||||
|
'69.163.253.130']);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not find id 15.1.225.42', function(done){
|
||||||
|
assert.equal(ips.indexOf('15.1.225.42'),-1);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a 200 response and route of 4 hops', function(done){
|
||||||
|
mailhops.lookup(ips, function(err, res, body){
|
||||||
|
assert.equal(res.statusCode,200);
|
||||||
|
assert.equal(body.response['route'].length,4);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user