How to use the haraka-test-fixtures.stub function in haraka-test-fixtures

To help you get started, we’ve selected a few haraka-test-fixtures examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github haraka / Haraka / tests / plugins / log.syslog.js View on Github external
'use strict';

var fixtures     = require('haraka-test-fixtures');

var stub         = fixtures.stub.stub;

var _set_up = function (done) {
    this.backup = { plugin: { Syslog: {} } };

    try {
        this.plugin = new fixtures.plugin('log.syslog');
    }
    catch (e) {
        console.log(e);
    }

    // stub out functions
    this.log = stub();
    this.log.level = 'INFO';
    this.log.data = "this is a test log message";
github haraka / Haraka / tests / plugins / aliases.js View on Github external
'use strict';

const Address      = require('address-rfc2821').Address;
const fixtures     = require('haraka-test-fixtures');

const stub         = fixtures.stub.stub;
const Connection   = fixtures.connection;

const _set_up = function (done) {

    // needed for tests
    this.plugin = new fixtures.plugin('aliases');
    this.recip  = new Address('');
    this.params = [this.recip];

    this.connection = Connection.createConnection();
    this.connection.loginfo = stub();
    this.connection.transaction = {
        notes: stub(),
        rcpt_to: [ this.params ],
    };
github haraka / Haraka / tests / plugins / connect.fcrdns.js View on Github external
'use strict';

var dns          = require('dns');

var fixtures     = require('haraka-test-fixtures');

var stub         = fixtures.stub.stub;

var _set_up = function (done) {

    this.plugin = new fixtures.plugin('connect.fcrdns');
    this.plugin.register();

    this.connection = fixtures.connection.createConnection();
    this.connection.auth_results = stub();

    this.plugin.hook_connect_init(function () {
        done();
    }, this.connection);
};

exports.refresh_config = {
    setUp : _set_up,
github haraka / Haraka / tests / fixtures / line_socket.js View on Github external
'use strict';

const events   = require('events');
const fixtures = require('haraka-test-fixtures');
const stub     = fixtures.stub.stub;

class Socket extends events.EventEmitter {
    constructor (port, host) {
        super();
        this.port = port;
        this.host = host;
        this.setTimeout = stub();
        this.setKeepAlive = stub();
        this.destroy = stub();
    }
}

exports.Socket = Socket;

exports.connect = (port, host, cb) => new Socket(port, host)
github haraka / Haraka / tests / plugins / spamassassin.js View on Github external
'use strict';

const Address      = require('address-rfc2821');
const fixtures     = require('haraka-test-fixtures');

const Connection   = fixtures.connection;
const stub         = fixtures.stub.stub;

function _set_up (done) {

    this.plugin = new fixtures.plugin('spamassassin');
    this.plugin.cfg = { main: { spamc_auth_header: 'X-Haraka-Relaying123' } };

    this.connection = Connection.createConnection();
    this.connection.transaction = stub;
    this.connection.transaction.notes = {};

    done();
}

exports.register = {
    setUp : _set_up,
    'loads the spamassassin plugin' (test) {
github haraka / Haraka / tests / plugins / helo.checks.js View on Github external
'use strict';

const path         = require('path');
const fixtures     = require('haraka-test-fixtures');

const stub         = fixtures.stub.stub;

const _set_up = function (done) {

    this.plugin = new fixtures.plugin('helo.checks');
    this.plugin.config.root_path = path.resolve(__dirname, '../../config');

    this.connection = fixtures.connection.createConnection();
    this.connection.remote.ip='208.75.199.19';

    this.plugin.register();

    done();
}

exports.init = {
    setUp: _set_up,
github haraka / Haraka / tests / plugins / karma.js View on Github external
'use strict';

var Address      = require('address-rfc2821').Address;
var fixtures     = require('haraka-test-fixtures');

var Connection   = fixtures.connection;
var ResultStore  = fixtures.result_store;
var stub         = fixtures.stub.stub;

var _set_up = function (done) {

    this.plugin = new fixtures.plugin('karma');

    this.plugin.cfg = { main: {} };
    this.plugin.deny_hooks = {'connect': true};
    this.plugin.tarpit_hooks = ['connect'];

    this.connection = Connection.createConnection({}, { notes: {} });

    this.connection.transaction = stub;
    this.connection.transaction.results = new ResultStore(this.plugin);

    done();
};
github haraka / Haraka / tests / plugins / limit.js View on Github external
'use strict';

var fixtures     = require('haraka-test-fixtures');

var Connection   = fixtures.connection;
var stub         = fixtures.stub.stub;

var _set_up = function (done) {

    this.plugin = new fixtures.plugin('limit');

    this.plugin.cfg = { main: {} };

    this.connection = Connection.createConnection();
    this.connection.transaction = stub;

    this.plugin.register();
    done();
};

exports.login_init = {
    setUp : _set_up,

haraka-test-fixtures

Haraka Test Fixtures

MIT
Latest version published 1 month ago

Package Health Score

64 / 100
Full package analysis

Similar packages