<commit_before>
var stub             = require('../fixtures/stub'),
    Connection       = require('../fixtures/stub_connection'),
    Plugin           = require('../fixtures/stub_plugin');

function _set_up(callback) {
    this.backup = {};

    // needed for tests
    this.plugin = Plugin('connect.asn');
    this.plugin.cfg = { main: {} };
    this.connection = Connection.createConnection();

    callback();
}
function _tear_down(callback) {
    callback();
}

exports.parse_monkey = {
    setUp : _set_up,
    tearDown : _tear_down,

    '15169/23': function (test) {
        test.expect(1);
        test.deepEqual(
                {net: '172.16.31.10/23', asn: '15169', org: 'Google Inc.', date: '2000-03-30', country: undefined},
                this.plugin.parse_monkey('172.16.31.10/23 | AS15169 | Google Inc. | 2000-03-30')
                );
        test.done();
    },
    '15169/16': function (test) {
        test.expect(1);
        test.deepEqual(
                {net: '192.168.3.11/16', asn: '15169', org: 'Google Inc.', date: '2000-03-30', country: 'US'},
                this.plugin.parse_monkey('192.168.3.11/16 | AS15169 | Google Inc. | 2000-03-30 | US')
                );
        test.done();
    },
};

exports.parse_routeviews = {
    setUp : _set_up,
    tearDown : _tear_down,

    '40431 string, asn-only': function (test) {
        test.expect(1);
        test.deepEqual(
                '',
                this.plugin.parse_routeviews('40431')
                );
        test.done();
    },
    '40431 string': function (test) {
        test.expect(1);
        test.deepEqual(
                {asn: '40431', net: '192.168.3.11/21'},
                this.plugin.parse_routeviews('40431 192.168.3.11 21')
                );
        test.done();
    },
    '40431 array': function (test) {
        test.expect(1);
        test.deepEqual(
                {asn: '40431', net: '192.168.3.11/21' },
                this.plugin.parse_routeviews(['40431','192.168.3.11','21'])
                );
        test.done();
    },
};

exports.parse_cymru = {
    setUp : _set_up,
    tearDown : _tear_down,

    '40431': function (test) {
        test.expect(1);
        test.deepEqual(
                { asn: '40431', net: '192.168.3.11/21', country: 'US', assignor: 'arin', date: '2007-03-02' },
                this.plugin.parse_cymru('40431 | 192.168.3.11/21 | US | arin | 2007-03-02')
                );
        test.done();
    },
    '10290': function (test) {
        test.expect(1);
        test.deepEqual(
                { asn: '10290', net: '172.16.17.32/24', country: 'US', assignor: 'arin', date: ''},
                this.plugin.parse_cymru('10290 | 172.16.17.32/24 | US | arin |')
                );
        test.done();
    },
};

exports.get_dns_results = {
    setUp : _set_up,
    tearDown : _tear_down,

    'origin.asn.cymru.com': function (test) {
        var cb = function () {
            test.equal('origin.asn.cymru.com', arguments[0]);
            test.equal('40431', arguments[1].asn);
            test.equal('192.168.3.11/21', arguments[1].net);
            test.done();
        };
        test.expect(4);
        test.ok(
                this.plugin.get_dns_results('origin.asn.cymru.com', '172.16.17.32', cb)
            );
    },
    'asn.routeviews.org': function (test) {
        test.expect(3);
        var cb = function () {
            test.equal('asn.routeviews.org', arguments[0]);
            if (arguments[1].asn && arguments[1].asn === '40431') {
                test.equal('40431', arguments[1].asn);
            }
            else {
                test.ok("Node DNS (c-ares) bug");
            }
            test.done();
        };
        test.ok(
                this.plugin.get_dns_results('asn.routeviews.org', '172.16.17.32', cb)
            );
    },
    'origin.asn.spameatingmonkey.net': function (test) {
        var cb = function () {
            test.equal('origin.asn.spameatingmonkey.net', arguments[0]);
            test.equal('40431', arguments[1].asn);
            test.equal('US', arguments[1].country);
            test.done();
        };
        test.expect(4);
        test.ok(
                this.plugin.get_dns_results('origin.asn.spameatingmonkey.net', '172.16.17.32', cb)
            );<commit_msg>asn: log the obj results (for curiosities sake)<commit_after>
var stub             = require('../fixtures/stub'),
    Connection       = require('../fixtures/stub_connection'),
    Plugin           = require('../fixtures/stub_plugin');

function _set_up(callback) {
    this.backup = {};

    // needed for tests
    this.plugin = Plugin('connect.asn');
    this.plugin.cfg = { main: {} };
    this.connection = Connection.createConnection();

    callback();
}
function _tear_down(callback) {
    callback();
}

exports.parse_monkey = {
    setUp : _set_up,
    tearDown : _tear_down,

    '15169/23': function (test) {
        test.expect(1);
        test.deepEqual(
                {net: '172.16.31.10/23', asn: '15169', org: 'Google Inc.', date: '2000-03-30', country: undefined},
                this.plugin.parse_monkey('172.16.31.10/23 | AS15169 | Google Inc. | 2000-03-30')
                );
        test.done();
    },
    '15169/16': function (test) {
        test.expect(1);
        test.deepEqual(
                {net: '192.168.3.11/16', asn: '15169', org: 'Google Inc.', date: '2000-03-30', country: 'US'},
                this.plugin.parse_monkey('192.168.3.11/16 | AS15169 | Google Inc. | 2000-03-30 | US')
                );
        test.done();
    },
};

exports.parse_routeviews = {
    setUp : _set_up,
    tearDown : _tear_down,

    '40431 string, asn-only': function (test) {
        test.expect(1);
        test.deepEqual(
                '',
                this.plugin.parse_routeviews('40431')
                );
        test.done();
    },
    '40431 string': function (test) {
        test.expect(1);
        test.deepEqual(
                {asn: '40431', net: '192.168.3.11/21'},
                this.plugin.parse_routeviews('40431 192.168.3.11 21')
                );
        test.done();
    },
    '40431 array': function (test) {
        test.expect(1);
        test.deepEqual(
                {asn: '40431', net: '192.168.3.11/21' },
                this.plugin.parse_routeviews(['40431','192.168.3.11','21'])
                );
        test.done();
    },
};

exports.parse_cymru = {
    setUp : _set_up,
    tearDown : _tear_down,

    '40431': function (test) {
        test.expect(1);
        test.deepEqual(
                { asn: '40431', net: '192.168.3.11/21', country: 'US', assignor: 'arin', date: '2007-03-02' },
                this.plugin.parse_cymru('40431 | 192.168.3.11/21 | US | arin | 2007-03-02')
                );
        test.done();
    },
    '10290': function (test) {
        test.expect(1);
        test.deepEqual(
                { asn: '10290', net: '172.16.17.32/24', country: 'US', assignor: 'arin', date: ''},
                this.plugin.parse_cymru('10290 | 172.16.17.32/24 | US | arin |')
                );
        test.done();
    },
};

exports.get_dns_results = {
    setUp : _set_up,
    tearDown : _tear_down,

    'origin.asn.cymru.com': function (test) {
        var cb = function (zone, obj) {
            test.equal('origin.asn.cymru.com', zone);
            test.equal('40431', obj.asn);
            test.equal('192.168.3.11/21', obj.net);
            test.done();
        };
        test.expect(4);
        test.ok(
                this.plugin.get_dns_results('origin.asn.cymru.com', '172.16.17.32', cb)
            );
    },
    'asn.routeviews.org': function (test) {
        test.expect(3);
        var cb = function (zone, obj) {
            test.equal('asn.routeviews.org', zone);
            if (obj.asn && obj.asn === '40431') {
                test.equal('40431', obj.asn);
            }
            else {
                test.ok("Node DNS (c-ares) bug");
                console.log(obj);
            }
            test.done();
        };
        test.ok(
                this.plugin.get_dns_results('asn.routeviews.org', '172.16.17.32', cb)
            );
    },
    'origin.asn.spameatingmonkey.net': function (test) {
        var cb = function (zone, obj) {
            test.equal('origin.asn.spameatingmonkey.net', zone);
            test.equal('40431', obj.asn);
            test.equal('US', obj.country);
            test.done();
        };
        test.expect(4);
        test.ok(
                this.plugin.get_dns_results('origin.asn.spameatingmonkey.net', '172.16.17.32', cb)
            );
{'fraction_non_alphanumeric': 0.1710955710955711, 'fraction_numerical': 0.08321678321678322, 'mean_word_length': 1.6773790951638066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 32, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1755876', 'n_tokens_mistral': 3382, 'n_tokens_neox': 2876, 'n_words': 464}