forked from smfreegard/Haraka
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
with backwards compat (if locally set)
- Loading branch information
Showing
4 changed files
with
97 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
var stub = require('../fixtures/stub'), | ||
Connection = require('../fixtures/stub_connection'), | ||
Plugin = require('../fixtures/stub_plugin'), | ||
configfile = require('../../configfile'), | ||
config = require('../../config'), | ||
// Header = require('../../mailheader').Header, | ||
ResultStore = require("../../result_store"); | ||
|
||
function _set_up(callback) { | ||
this.backup = {}; | ||
|
||
this.plugin = Plugin('connect.geoip'); | ||
this.plugin.config = config; | ||
this.plugin.cfg = { main: {} }; | ||
|
||
this.connection = Connection.createConnection(); | ||
this.connection.results = new ResultStore(this.plugin); | ||
|
||
callback(); | ||
} | ||
function _tear_down(callback) { | ||
callback(); | ||
} | ||
|
||
// ServedBy ll: [ 47.6738, -122.3419 ], | ||
// WMISD [ 38, -97 ] | ||
|
||
exports.haversine = { | ||
setUp : _set_up, | ||
tearDown : _tear_down, | ||
'WA to MI': function (test) { | ||
test.expect(2); | ||
var r = this.plugin.haversine(47.673, -122.3419, 38, -97); | ||
test.equal(true, (r > 2000)); | ||
test.equal(true, (r < 2500)); | ||
// console.log(r); | ||
test.done(); | ||
} | ||
}; | ||
|
||
exports.hook_connect = { | ||
setUp : _set_up, | ||
tearDown : _tear_down, | ||
|
||
'seattle: ': function (test) { | ||
test.expect(2); | ||
var cb = function (rc) { | ||
test.equal(undefined, rc); | ||
var r = this.connection.results.get('connect.geoip'); | ||
// console.log(r); | ||
test.ok(r); | ||
test.done(); | ||
}.bind(this); | ||
this.connection.remote_ip='192.48.85.146'; | ||
this.plugin.hook_connect(cb, this.connection); | ||
}, | ||
'michigan: ': function (test) { | ||
test.expect(2); | ||
var cb = function (rc) { | ||
test.equal(undefined, rc); | ||
var r = this.connection.results.get('connect.geoip'); | ||
// console.log(r); | ||
test.ok(r); | ||
test.done(); | ||
}.bind(this); | ||
this.connection.remote_ip='199.176.179.3'; | ||
this.plugin.hook_connect(cb, this.connection); | ||
}, | ||
}; |