Haraka 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.yaml +5 -9
- package/.prettierrc.yml +1 -0
- package/CONTRIBUTORS.md +11 -0
- package/Changes.md +1365 -1214
- package/Plugins.md +117 -105
- package/README.md +4 -13
- package/bin/haraka +197 -298
- package/config/auth_flat_file.ini +1 -0
- package/config/dhparams.pem +8 -0
- package/config/mail_from.is_resolvable.ini +4 -2
- package/config/me +1 -0
- package/config/outbound.ini +0 -2
- package/config/plugins +36 -35
- package/config/smtp.ini +0 -1
- package/config/smtp.json +17 -0
- package/config/tls_cert.pem +23 -0
- package/config/tls_key.pem +28 -0
- package/connection.js +46 -73
- package/contrib/bsd-rc.d/haraka +3 -1
- package/contrib/plugin2npm.sh +6 -36
- package/docs/CoreConfig.md +2 -2
- package/docs/Logging.md +7 -21
- package/docs/Outbound.md +104 -201
- package/docs/Plugins.md +2 -2
- package/docs/Transaction.md +59 -82
- package/docs/plugins/queue/smtp_proxy.md +5 -10
- package/docs/plugins/tls.md +29 -9
- package/endpoint.js +16 -13
- package/haraka.js +10 -14
- package/host_pool.js +5 -5
- package/line_socket.js +3 -4
- package/logger.js +44 -28
- package/outbound/client_pool.js +27 -23
- package/outbound/config.js +4 -6
- package/outbound/fsync_writestream.js +1 -1
- package/outbound/hmail.js +178 -218
- package/outbound/index.js +86 -99
- package/outbound/qfile.js +1 -1
- package/outbound/queue.js +51 -44
- package/outbound/timer_queue.js +3 -2
- package/outbound/tls.js +19 -7
- package/package.json +59 -48
- package/plugins/.eslintrc.yaml +0 -6
- package/plugins/auth/auth_base.js +4 -2
- package/plugins/auth/auth_proxy.js +14 -12
- package/plugins/auth/auth_vpopmaild.js +1 -1
- package/plugins/block_me.js +1 -1
- package/plugins/data.signatures.js +2 -4
- package/plugins/early_talker.js +2 -1
- package/plugins/mail_from.is_resolvable.js +65 -135
- package/plugins/queue/deliver.js +4 -5
- package/plugins/queue/lmtp.js +11 -14
- package/plugins/queue/qmail-queue.js +2 -2
- package/plugins/queue/quarantine.js +2 -2
- package/plugins/queue/rabbitmq.js +16 -17
- package/plugins/queue/smtp_forward.js +3 -3
- package/plugins/queue/smtp_proxy.js +10 -1
- package/plugins/queue/test.js +2 -2
- package/plugins/rcpt_to.host_list_base.js +5 -5
- package/plugins/rcpt_to.in_host_list.js +2 -2
- package/plugins/relay.js +6 -7
- package/plugins/reseed_rng.js +1 -1
- package/plugins/status.js +37 -33
- package/plugins/tls.js +2 -2
- package/plugins/xclient.js +3 -2
- package/plugins.js +50 -54
- package/run_tests +3 -30
- package/server.js +190 -190
- package/smtp_client.js +30 -23
- package/{tests → test}/config/plugins +0 -2
- package/{tests → test}/config/smtp.ini +1 -1
- package/test/config/tls/example.com/_.example.com.key +28 -0
- package/test/config/tls/example.com/example.com.crt +25 -0
- package/test/connection.js +302 -0
- package/test/endpoint.js +94 -0
- package/{tests → test}/fixtures/line_socket.js +1 -1
- package/{tests → test}/fixtures/util_hmailitem.js +19 -25
- package/{tests → test}/host_pool.js +42 -57
- package/test/logger.js +258 -0
- package/test/outbound/hmail.js +141 -0
- package/test/outbound/index.js +220 -0
- package/test/outbound/qfile.js +126 -0
- package/test/outbound_bounce_net_errors.js +142 -0
- package/{tests → test}/outbound_bounce_rfc3464.js +110 -122
- package/test/plugins/auth/auth_base.js +484 -0
- package/test/plugins/auth/auth_vpopmaild.js +83 -0
- package/test/plugins/early_talker.js +104 -0
- package/test/plugins/mail_from.is_resolvable.js +35 -0
- package/test/plugins/queue/smtp_forward.js +206 -0
- package/test/plugins/rcpt_to.host_list_base.js +122 -0
- package/test/plugins/rcpt_to.in_host_list.js +193 -0
- package/test/plugins/relay.js +303 -0
- package/test/plugins/status.js +130 -0
- package/test/plugins/tls.js +70 -0
- package/test/plugins.js +228 -0
- package/test/rfc1869.js +73 -0
- package/test/server.js +491 -0
- package/test/smtp_client.js +299 -0
- package/test/tls_socket.js +273 -0
- package/test/transaction.js +270 -0
- package/tls_socket.js +202 -252
- package/transaction.js +8 -23
- package/CONTRIBUTING.md +0 -1
- package/bin/dkimverify +0 -40
- package/config/access.domains +0 -13
- package/config/attachment.ctype.regex +0 -2
- package/config/attachment.filename.regex +0 -1
- package/config/avg.ini +0 -5
- package/config/bounce.ini +0 -15
- package/config/data.headers.ini +0 -61
- package/config/dkim/dkim_key_gen.sh +0 -78
- package/config/dkim_sign.ini +0 -4
- package/config/dkim_verify.ini +0 -7
- package/config/dnsbl.ini +0 -23
- package/config/greylist.ini +0 -43
- package/config/helo.checks.ini +0 -52
- package/config/messagesniffer.ini +0 -18
- package/config/spamassassin.ini +0 -56
- package/dkim.js +0 -614
- package/docs/plugins/avg.md +0 -35
- package/docs/plugins/bounce.md +0 -69
- package/docs/plugins/clamd.md +0 -147
- package/docs/plugins/esets.md +0 -8
- package/docs/plugins/greylist.md +0 -90
- package/docs/plugins/helo.checks.md +0 -135
- package/docs/plugins/messagesniffer.md +0 -163
- package/docs/plugins/spamassassin.md +0 -180
- package/outbound/mx_lookup.js +0 -70
- package/plugins/auth/auth_ldap.js +0 -3
- package/plugins/avg.js +0 -162
- package/plugins/backscatterer.js +0 -25
- package/plugins/bounce.js +0 -381
- package/plugins/clamd.js +0 -382
- package/plugins/data.uribl.js +0 -4
- package/plugins/dkim_sign.js +0 -395
- package/plugins/dkim_verify.js +0 -62
- package/plugins/dns_list_base.js +0 -221
- package/plugins/dnsbl.js +0 -146
- package/plugins/dnswl.js +0 -58
- package/plugins/esets.js +0 -71
- package/plugins/graph.js +0 -5
- package/plugins/greylist.js +0 -645
- package/plugins/helo.checks.js +0 -533
- package/plugins/messagesniffer.js +0 -381
- package/plugins/rcpt_to.ldap.js +0 -3
- package/plugins/rcpt_to.max_count.js +0 -24
- package/plugins/spamassassin.js +0 -384
- package/tests/config/dkim/example.com/dns +0 -29
- package/tests/config/dkim/example.com/private +0 -6
- package/tests/config/dkim/example.com/public +0 -4
- package/tests/config/dkim/example.com/selector +0 -1
- package/tests/config/dkim.private.key +0 -6
- package/tests/config/dkim_sign.ini +0 -4
- package/tests/config/helo.checks.ini +0 -52
- package/tests/connection.js +0 -327
- package/tests/endpoint.js +0 -128
- package/tests/fixtures/vm_harness.js +0 -59
- package/tests/logger.js +0 -327
- package/tests/outbound/hmail.js +0 -112
- package/tests/outbound/index.js +0 -324
- package/tests/outbound/qfile.js +0 -67
- package/tests/outbound_bounce_net_errors.js +0 -173
- package/tests/plugins/auth/auth_base.js +0 -463
- package/tests/plugins/auth/auth_vpopmaild.js +0 -91
- package/tests/plugins/bounce.js +0 -307
- package/tests/plugins/clamd.js +0 -224
- package/tests/plugins/deprecated/relay_acl.js +0 -140
- package/tests/plugins/deprecated/relay_all.js +0 -59
- package/tests/plugins/dkim_sign.js +0 -315
- package/tests/plugins/dkim_signer.js +0 -108
- package/tests/plugins/dns_list_base.js +0 -259
- package/tests/plugins/dnsbl.js +0 -101
- package/tests/plugins/early_talker.js +0 -115
- package/tests/plugins/greylist.js +0 -58
- package/tests/plugins/helo.checks.js +0 -525
- package/tests/plugins/mail_from.is_resolvable.js +0 -116
- package/tests/plugins/queue/smtp_forward.js +0 -221
- package/tests/plugins/rcpt_to.host_list_base.js +0 -132
- package/tests/plugins/rcpt_to.in_host_list.js +0 -218
- package/tests/plugins/relay.js +0 -339
- package/tests/plugins/spamassassin.js +0 -171
- package/tests/plugins/status.js +0 -138
- package/tests/plugins/tls.js +0 -84
- package/tests/plugins.js +0 -247
- package/tests/rfc1869.js +0 -61
- package/tests/server.js +0 -510
- package/tests/smtp_client/auth.js +0 -105
- package/tests/smtp_client/basic.js +0 -101
- package/tests/smtp_client.js +0 -80
- package/tests/tls_socket.js +0 -333
- package/tests/transaction.js +0 -284
- /package/docs/{plugins → deprecated}/dkim_sign.md +0 -0
- /package/docs/{plugins → deprecated}/dkim_verify.md +0 -0
- /package/docs/{plugins → deprecated}/dnsbl.md +0 -0
- /package/docs/{plugins → deprecated}/dnswl.md +0 -0
- /package/{tests → test}/.eslintrc.yaml +0 -0
- /package/{tests → test}/config/auth_flat_file.ini +0 -0
- /package/{tests → test}/config/dhparams.pem +0 -0
- /package/{tests → test}/config/host_list +0 -0
- /package/{tests → test}/config/outbound_tls_cert.pem +0 -0
- /package/{tests → test}/config/outbound_tls_key.pem +0 -0
- /package/{tests → test}/config/smtp_forward.ini +0 -0
- /package/{tests → test}/config/tls/ec.pem +0 -0
- /package/{tests → test}/config/tls/haraka.local.pem +0 -0
- /package/{tests → test}/config/tls/mismatched.pem +0 -0
- /package/{tests → test}/config/tls.ini +0 -0
- /package/{tests → test}/config/tls_cert.pem +0 -0
- /package/{tests → test}/config/tls_key.pem +0 -0
- /package/{tests → test}/fixtures/todo_qfile.txt +0 -0
- /package/{tests → test}/installation/config/test-plugin-flat +0 -0
- /package/{tests → test}/installation/config/test-plugin.ini +0 -0
- /package/{tests → test}/installation/config/tls.ini +0 -0
- /package/{tests → test}/installation/node_modules/load_first/index.js +0 -0
- /package/{tests → test}/installation/node_modules/load_first/package.json +0 -0
- /package/{tests → test}/installation/node_modules/test-plugin/config/test-plugin-flat +0 -0
- /package/{tests → test}/installation/node_modules/test-plugin/config/test-plugin.ini +0 -0
- /package/{tests → test}/installation/node_modules/test-plugin/package.json +0 -0
- /package/{tests → test}/installation/node_modules/test-plugin/test-plugin.js +0 -0
- /package/{tests → test}/installation/plugins/base_plugin.js +0 -0
- /package/{tests → test}/installation/plugins/folder_plugin/index.js +0 -0
- /package/{tests → test}/installation/plugins/folder_plugin/package.json +0 -0
- /package/{tests → test}/installation/plugins/inherits.js +0 -0
- /package/{tests → test}/installation/plugins/load_first.js +0 -0
- /package/{tests → test}/installation/plugins/plugin.js +0 -0
- /package/{tests → test}/installation/plugins/tls.js +0 -0
- /package/{tests → test}/loud/config/dhparams.pem +0 -0
- /package/{tests → test}/loud/config/tls/goobered.pem +0 -0
- /package/{tests → test}/loud/config/tls.ini +0 -0
- /package/{tests → test}/mail_specimen/base64-root-part.txt +0 -0
- /package/{tests → test}/mail_specimen/varied-fold-lengths-preserve-data.txt +0 -0
- /package/{tests → test}/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_fixed +0 -0
- /package/{tests → test}/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka +0 -0
- /package/{tests → test}/queue/1508269674999_1508269674999_0_34002_socVUF_1_haraka +0 -0
- /package/{tests → test}/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka +0 -0
- /package/{tests → test}/queue/multibyte +0 -0
- /package/{tests → test}/queue/plain +0 -0
- /package/{tests → test}/queue/zero-length +0 -0
- /package/{tests → test}/test-queue/delete-me +0 -0
package/tests/logger.js
DELETED
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const util = require('util');
|
|
3
|
-
|
|
4
|
-
function _set_up (callback) {
|
|
5
|
-
this.logger = require('../logger');
|
|
6
|
-
callback();
|
|
7
|
-
}
|
|
8
|
-
function _tear_down (callback) {
|
|
9
|
-
callback();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
exports.init = {
|
|
13
|
-
setUp : _set_up,
|
|
14
|
-
tearDown : _tear_down,
|
|
15
|
-
'logger' (test) {
|
|
16
|
-
test.expect(1);
|
|
17
|
-
test.ok(this.logger);
|
|
18
|
-
test.done();
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
exports.log = {
|
|
23
|
-
setUp : _set_up,
|
|
24
|
-
tearDown : _tear_down,
|
|
25
|
-
'log' (test) {
|
|
26
|
-
this.logger.deferred_logs = [];
|
|
27
|
-
test.expect(3);
|
|
28
|
-
test.equal(0, this.logger.deferred_logs.length);
|
|
29
|
-
test.ok(this.logger.log('WARN','test warning'));
|
|
30
|
-
test.equal(1, this.logger.deferred_logs.length);
|
|
31
|
-
test.done();
|
|
32
|
-
},
|
|
33
|
-
'log, w/deferred' (test) {
|
|
34
|
-
test.expect(1);
|
|
35
|
-
this.logger.plugins = { plugin_list: true };
|
|
36
|
-
this.logger.deferred_logs.push( { level: 'INFO', data: 'log test info'} );
|
|
37
|
-
test.ok(this.logger.log('INFO', 'another test info'));
|
|
38
|
-
test.done();
|
|
39
|
-
},
|
|
40
|
-
'log in logfmt' (test) {
|
|
41
|
-
this.logger.deferred_logs = [];
|
|
42
|
-
test.expect(3);
|
|
43
|
-
this.logger.format = this.logger.formats.LOGFMT;
|
|
44
|
-
test.equal(0, this.logger.deferred_logs.length);
|
|
45
|
-
test.ok(this.logger.log('WARN','test warning'));
|
|
46
|
-
test.equal(1, this.logger.deferred_logs.length);
|
|
47
|
-
test.done();
|
|
48
|
-
},
|
|
49
|
-
'log in logfmt w/deferred' (test) {
|
|
50
|
-
test.expect(1);
|
|
51
|
-
this.logger.plugins = { plugin_list: true };
|
|
52
|
-
this.logger.deferred_logs.push( { level: 'INFO', data: 'log test info'} );
|
|
53
|
-
test.ok(this.logger.log('INFO', 'another test info'));
|
|
54
|
-
test.done();
|
|
55
|
-
},
|
|
56
|
-
'log in json' (test) {
|
|
57
|
-
this.logger.deferred_logs = [];
|
|
58
|
-
test.expect(3);
|
|
59
|
-
this.logger.format = this.logger.formats.JSON;
|
|
60
|
-
test.equal(0, this.logger.deferred_logs.length);
|
|
61
|
-
test.ok(this.logger.log('WARN','test warning'));
|
|
62
|
-
test.equal(1, this.logger.deferred_logs.length);
|
|
63
|
-
test.done();
|
|
64
|
-
},
|
|
65
|
-
'log in json w/deferred' (test) {
|
|
66
|
-
test.expect(1);
|
|
67
|
-
this.logger.plugins = { plugin_list: true };
|
|
68
|
-
this.logger.deferred_logs.push( { level: 'INFO', data: 'log test info'} );
|
|
69
|
-
test.ok(this.logger.log('INFO', 'another test info'));
|
|
70
|
-
test.done();
|
|
71
|
-
},
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
exports.level = {
|
|
75
|
-
setUp : _set_up,
|
|
76
|
-
tearDown : _tear_down,
|
|
77
|
-
'both INFO and LOGINFO are log levels' (test) {
|
|
78
|
-
test.expect(2);
|
|
79
|
-
test.equal(this.logger.levels.INFO, 6);
|
|
80
|
-
test.equal(this.logger.levels.LOGINFO, 6);
|
|
81
|
-
test.done();
|
|
82
|
-
},
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
exports.set_format = {
|
|
86
|
-
setUp : _set_up,
|
|
87
|
-
tearDown : _tear_down,
|
|
88
|
-
'set format to DEFAULT' (test) {
|
|
89
|
-
test.expect(1);
|
|
90
|
-
this.logger.format = '';
|
|
91
|
-
this.logger.set_format('DEFAULT');
|
|
92
|
-
test.equal(this.logger.format, this.logger.formats.DEFAULT);
|
|
93
|
-
test.done();
|
|
94
|
-
},
|
|
95
|
-
'set format to LOGFMT' (test) {
|
|
96
|
-
test.expect(1);
|
|
97
|
-
this.logger.format = '';
|
|
98
|
-
this.logger.set_format('LOGFMT');
|
|
99
|
-
test.equal(this.logger.format, this.logger.formats.LOGFMT);
|
|
100
|
-
test.done();
|
|
101
|
-
},
|
|
102
|
-
'set format to JSON' (test) {
|
|
103
|
-
test.expect(1);
|
|
104
|
-
this.logger.format = '';
|
|
105
|
-
this.logger.set_format('JSON');
|
|
106
|
-
test.equal(this.logger.format, this.logger.formats.JSON);
|
|
107
|
-
test.done();
|
|
108
|
-
},
|
|
109
|
-
'set format to DEFAULT if empty' (test) {
|
|
110
|
-
test.expect(1);
|
|
111
|
-
this.logger.format = '';
|
|
112
|
-
this.logger.set_format('');
|
|
113
|
-
test.equal(this.logger.format, this.logger.formats.DEFAULT);
|
|
114
|
-
test.done();
|
|
115
|
-
},
|
|
116
|
-
'set format to DEFAULT if lowercase' (test) {
|
|
117
|
-
test.expect(1);
|
|
118
|
-
this.logger.format = '';
|
|
119
|
-
this.logger.set_format('default');
|
|
120
|
-
test.equal(this.logger.format, this.logger.formats.DEFAULT);
|
|
121
|
-
test.done();
|
|
122
|
-
},
|
|
123
|
-
'set format to DEFAULT if invalid' (test) {
|
|
124
|
-
test.expect(1);
|
|
125
|
-
this.logger.format = '';
|
|
126
|
-
this.logger.set_format('invalid');
|
|
127
|
-
test.equal(this.logger.format, this.logger.formats.DEFAULT);
|
|
128
|
-
test.done();
|
|
129
|
-
},
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
exports.set_loglevel = {
|
|
133
|
-
setUp : _set_up,
|
|
134
|
-
tearDown : _tear_down,
|
|
135
|
-
'set loglevel to LOGINFO' (test) {
|
|
136
|
-
test.expect(1);
|
|
137
|
-
this.logger.set_loglevel('LOGINFO');
|
|
138
|
-
test.equal(this.logger.loglevel, this.logger.levels.LOGINFO);
|
|
139
|
-
test.done();
|
|
140
|
-
},
|
|
141
|
-
'set loglevel to INFO' (test) {
|
|
142
|
-
test.expect(1);
|
|
143
|
-
this.logger.set_loglevel('INFO');
|
|
144
|
-
test.equal(this.logger.loglevel, this.logger.levels.INFO);
|
|
145
|
-
test.done();
|
|
146
|
-
},
|
|
147
|
-
'set loglevel to EMERG' (test) {
|
|
148
|
-
test.expect(1);
|
|
149
|
-
this.logger.set_loglevel('emerg');
|
|
150
|
-
test.equal(this.logger.loglevel, this.logger.levels.EMERG);
|
|
151
|
-
test.done();
|
|
152
|
-
},
|
|
153
|
-
'set loglevel to 6' (test) {
|
|
154
|
-
test.expect(1);
|
|
155
|
-
this.logger.set_loglevel(6);
|
|
156
|
-
test.equal(this.logger.loglevel, 6);
|
|
157
|
-
test.done();
|
|
158
|
-
},
|
|
159
|
-
'set loglevel to WARN if invalid' (test) {
|
|
160
|
-
test.expect(1);
|
|
161
|
-
this.logger.set_loglevel('invalid');
|
|
162
|
-
test.equal(this.logger.loglevel, this.logger.levels.WARN);
|
|
163
|
-
test.done();
|
|
164
|
-
},
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
exports.set_timestamps = {
|
|
168
|
-
setUp : _set_up,
|
|
169
|
-
tearDown : _tear_down,
|
|
170
|
-
'set timestamps to false' (test) {
|
|
171
|
-
test.expect(1);
|
|
172
|
-
this.logger.timestamps = undefined;
|
|
173
|
-
this.logger.set_timestamps(false);
|
|
174
|
-
test.equal(this.logger.timestamps, false);
|
|
175
|
-
test.done();
|
|
176
|
-
},
|
|
177
|
-
'set timestamps to true' (test) {
|
|
178
|
-
test.expect(1);
|
|
179
|
-
this.logger.timestamps = undefined;
|
|
180
|
-
this.logger.set_timestamps(true);
|
|
181
|
-
test.equal(this.logger.timestamps, true);
|
|
182
|
-
test.done();
|
|
183
|
-
},
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
exports.would_log = {
|
|
187
|
-
setUp : _set_up,
|
|
188
|
-
tearDown : _tear_down,
|
|
189
|
-
'should' (test) {
|
|
190
|
-
test.expect(3);
|
|
191
|
-
this.logger.loglevel = 4;
|
|
192
|
-
test.equal(false, this.logger.would_log(7));
|
|
193
|
-
test.equal(false, this.logger.would_log(6));
|
|
194
|
-
test.equal(false, this.logger.would_log(5));
|
|
195
|
-
test.done();
|
|
196
|
-
},
|
|
197
|
-
'should not' (test) {
|
|
198
|
-
test.expect(4);
|
|
199
|
-
this.logger.loglevel = 4;
|
|
200
|
-
test.equal(true, this.logger.would_log(4));
|
|
201
|
-
test.equal(true, this.logger.would_log(3));
|
|
202
|
-
test.equal(true, this.logger.would_log(2));
|
|
203
|
-
test.equal(true, this.logger.would_log(1));
|
|
204
|
-
test.done();
|
|
205
|
-
},
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
exports.log_respond = {
|
|
209
|
-
setUp : _set_up,
|
|
210
|
-
tearDown : _tear_down,
|
|
211
|
-
'invalid retval' (test) {
|
|
212
|
-
test.expect(1);
|
|
213
|
-
test.equal(false, this.logger.log_respond(901));
|
|
214
|
-
test.done();
|
|
215
|
-
},
|
|
216
|
-
'valid retval' (test) {
|
|
217
|
-
test.expect(1);
|
|
218
|
-
const data = { level: 'INFO', data: "test data" };
|
|
219
|
-
test.equal(true, this.logger.log_respond(900, 'test msg', data));
|
|
220
|
-
test.done();
|
|
221
|
-
},
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
exports.dump_logs = {
|
|
225
|
-
setUp : _set_up,
|
|
226
|
-
tearDown : _tear_down,
|
|
227
|
-
'empty' (test) {
|
|
228
|
-
test.expect(1);
|
|
229
|
-
test.ok(this.logger.dump_logs(0));
|
|
230
|
-
test.done();
|
|
231
|
-
},
|
|
232
|
-
'with deferred' (test) {
|
|
233
|
-
test.expect(2);
|
|
234
|
-
this.logger.deferred_logs.push( { level: 'info', data: 'test info'} );
|
|
235
|
-
this.logger.deferred_logs.push( { level: 'INFO', data: 'test info, color'} );
|
|
236
|
-
this.logger.deferred_logs.push( { level: 'WARN', data: 'test warn, color'} );
|
|
237
|
-
test.ok(this.logger.dump_logs(0));
|
|
238
|
-
test.ok(this.logger.deferred_logs.length === 0);
|
|
239
|
-
test.done();
|
|
240
|
-
},
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
exports.colors = {
|
|
244
|
-
setUp : _set_up,
|
|
245
|
-
tearDown : _tear_down,
|
|
246
|
-
'colors' (test) {
|
|
247
|
-
test.expect(1);
|
|
248
|
-
test.ok(this.logger.colors);
|
|
249
|
-
test.done();
|
|
250
|
-
},
|
|
251
|
-
'colorize' (test) {
|
|
252
|
-
test.expect(4);
|
|
253
|
-
test.ok(this.logger.colorize);
|
|
254
|
-
test.equal('function', typeof this.logger.colorize);
|
|
255
|
-
test.equal('error', this.logger.colorize('bad-color', 'error'));
|
|
256
|
-
const expected = util.inspect.colors ? '\u001b[34mgood\u001b[39m' : 'good';
|
|
257
|
-
test.equal(expected, this.logger.colorize('blue', 'good'));
|
|
258
|
-
test.done();
|
|
259
|
-
},
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
exports.log_if_level = {
|
|
263
|
-
setUp : _set_up,
|
|
264
|
-
tearDown : _tear_down,
|
|
265
|
-
'log_if_level is a function' (test) {
|
|
266
|
-
test.expect(1);
|
|
267
|
-
test.ok('function' === typeof this.logger.log_if_level);
|
|
268
|
-
test.done();
|
|
269
|
-
},
|
|
270
|
-
'log_if_level test log entry' (test) {
|
|
271
|
-
test.expect(5);
|
|
272
|
-
this.logger.loglevel = 9;
|
|
273
|
-
const f = this.logger.log_if_level('INFO', 'LOGINFO');
|
|
274
|
-
test.ok(f);
|
|
275
|
-
test.ok('function' === typeof f);
|
|
276
|
-
test.ok(f('test info message'));
|
|
277
|
-
test.equal(1, this.logger.deferred_logs.length);
|
|
278
|
-
// console.log(this.logger.deferred_logs[0]);
|
|
279
|
-
test.equal('INFO', this.logger.deferred_logs[0].level);
|
|
280
|
-
test.done();
|
|
281
|
-
},
|
|
282
|
-
'log_if_level null case' (test) {
|
|
283
|
-
test.expect(2);
|
|
284
|
-
this.logger.loglevel = 9;
|
|
285
|
-
const f = this.logger.log_if_level('INFO', 'LOGINFO');
|
|
286
|
-
test.ok(f(null));
|
|
287
|
-
test.equal(2, this.logger.deferred_logs.length);
|
|
288
|
-
test.done();
|
|
289
|
-
},
|
|
290
|
-
'log_if_level false' (test) {
|
|
291
|
-
test.expect(2);
|
|
292
|
-
this.logger.loglevel = 9;
|
|
293
|
-
const f = this.logger.log_if_level('INFO', 'LOGINFO');
|
|
294
|
-
test.ok(f(false));
|
|
295
|
-
test.equal(3, this.logger.deferred_logs.length);
|
|
296
|
-
test.done();
|
|
297
|
-
},
|
|
298
|
-
'log_if_level 0' (test) {
|
|
299
|
-
test.expect(2);
|
|
300
|
-
this.logger.loglevel = 9;
|
|
301
|
-
const f = this.logger.log_if_level('INFO', 'LOGINFO');
|
|
302
|
-
test.ok(f(0));
|
|
303
|
-
test.equal(4, this.logger.deferred_logs.length);
|
|
304
|
-
test.done();
|
|
305
|
-
},
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
exports.add_log_methods = {
|
|
309
|
-
setUp : _set_up,
|
|
310
|
-
tearDown : _tear_down,
|
|
311
|
-
'ignores non-objects' (test) {
|
|
312
|
-
test.expect(2);
|
|
313
|
-
test.equal(undefined, this.logger.add_log_methods(''));
|
|
314
|
-
test.equal(undefined, this.logger.add_log_methods(function foo (){}));
|
|
315
|
-
test.done();
|
|
316
|
-
},
|
|
317
|
-
'adds functions to an object' (test) {
|
|
318
|
-
const testObj = {};
|
|
319
|
-
this.logger.add_log_methods(testObj);
|
|
320
|
-
const levels = ['DATA','PROTOCOL','DEBUG','INFO','NOTICE','WARN','ERROR','CRIT','ALERT','EMERG'];
|
|
321
|
-
test.expect(levels.length);
|
|
322
|
-
for (const level of levels) {
|
|
323
|
-
test.ok('function' === typeof(testObj[`log${level.toLowerCase()}`]));
|
|
324
|
-
}
|
|
325
|
-
test.done();
|
|
326
|
-
},
|
|
327
|
-
}
|
package/tests/outbound/hmail.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
|
|
5
|
-
const Hmail = require('../../outbound/hmail');
|
|
6
|
-
const outbound = require('../../outbound/index');
|
|
7
|
-
|
|
8
|
-
// const fixtures = path.resolve('tests', 'fixtures');
|
|
9
|
-
|
|
10
|
-
exports.HMailItem = {
|
|
11
|
-
'normal queue file' (test) {
|
|
12
|
-
test.expect(1);
|
|
13
|
-
this.hmail = new Hmail('1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka', 'tests/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka', {});
|
|
14
|
-
this.hmail.on('ready', () => {
|
|
15
|
-
// console.log(this.hmail);
|
|
16
|
-
test.ok(this.hmail)
|
|
17
|
-
test.done()
|
|
18
|
-
})
|
|
19
|
-
this.hmail.on('error', err => {
|
|
20
|
-
console.log(err)
|
|
21
|
-
test.equal(err, undefined)
|
|
22
|
-
test.done()
|
|
23
|
-
})
|
|
24
|
-
},
|
|
25
|
-
'normal TODO w/multibyte chars loads w/o error' (test) {
|
|
26
|
-
test.expect(1);
|
|
27
|
-
this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_1_qfile', 'tests/fixtures/todo_qfile.txt', {});
|
|
28
|
-
this.hmail.on('ready', () => {
|
|
29
|
-
// console.log(this.hmail);
|
|
30
|
-
test.ok(this.hmail)
|
|
31
|
-
test.done()
|
|
32
|
-
})
|
|
33
|
-
this.hmail.on('error', err => {
|
|
34
|
-
console.log(err)
|
|
35
|
-
test.equal(err, undefined)
|
|
36
|
-
test.done()
|
|
37
|
-
})
|
|
38
|
-
},
|
|
39
|
-
'too short TODO length declared' (test) {
|
|
40
|
-
test.expect(1);
|
|
41
|
-
this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka', 'tests/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka', {});
|
|
42
|
-
this.hmail.on('ready', () => {
|
|
43
|
-
// console.log(this.hmail);
|
|
44
|
-
test.ok(this.hmail)
|
|
45
|
-
test.done();
|
|
46
|
-
})
|
|
47
|
-
this.hmail.on('error', (err) => {
|
|
48
|
-
console.log(err);
|
|
49
|
-
test.ok(err);
|
|
50
|
-
test.done();
|
|
51
|
-
})
|
|
52
|
-
},
|
|
53
|
-
'too long TODO length declared' (test) {
|
|
54
|
-
test.expect(1);
|
|
55
|
-
this.hmail = new Hmail('1508269674999_1508269674999_0_34002_socVUF_1_haraka', 'tests/queue/1508269674999_1508269674999_0_34002_socVUF_1_haraka', {});
|
|
56
|
-
this.hmail.on('ready', () => {
|
|
57
|
-
// console.log(this.hmail);
|
|
58
|
-
test.ok(this.hmail)
|
|
59
|
-
test.done();
|
|
60
|
-
})
|
|
61
|
-
this.hmail.on('error', (err) => {
|
|
62
|
-
console.log(err);
|
|
63
|
-
test.ok(err);
|
|
64
|
-
test.done();
|
|
65
|
-
})
|
|
66
|
-
},
|
|
67
|
-
'zero-length file load skip w/o crash' (test) {
|
|
68
|
-
test.expect(1);
|
|
69
|
-
this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_2_zero', 'tests/queue/zero-length', {});
|
|
70
|
-
this.hmail.on('ready', () => {
|
|
71
|
-
test.ok(this.hmail)
|
|
72
|
-
test.done();
|
|
73
|
-
})
|
|
74
|
-
this.hmail.on('error', (err) => {
|
|
75
|
-
console.log(err);
|
|
76
|
-
test.ok(err);
|
|
77
|
-
test.done();
|
|
78
|
-
})
|
|
79
|
-
},
|
|
80
|
-
'lifecycle, reads and writes a haraka queue file' (test) {
|
|
81
|
-
test.expect(1);
|
|
82
|
-
|
|
83
|
-
this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_2_qfile', 'tests/fixtures/todo_qfile.txt', {});
|
|
84
|
-
|
|
85
|
-
this.hmail.on('error', (err) => {
|
|
86
|
-
// console.log(err);
|
|
87
|
-
test.equals(err, undefined);
|
|
88
|
-
test.done();
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
this.hmail.on('ready', () => {
|
|
92
|
-
|
|
93
|
-
const tmpfile = path.resolve('tests', 'test-queue', 'delete-me');
|
|
94
|
-
const ws = new fs.createWriteStream(tmpfile)
|
|
95
|
-
|
|
96
|
-
outbound.build_todo(this.hmail.todo, ws, () => {
|
|
97
|
-
// console.log('returned from build_todo, piping')
|
|
98
|
-
// console.log(this.hmail.todo)
|
|
99
|
-
// test.equals(this.hmail.todo.message_stream.headers.length, 22);
|
|
100
|
-
|
|
101
|
-
const ds = this.hmail.data_stream()
|
|
102
|
-
ds.pipe(ws, { line_endings: '\r\n', dot_stuffing: true, ending_dot: false });
|
|
103
|
-
|
|
104
|
-
ws.on('close', () => {
|
|
105
|
-
// console.log(this.hmail.todo)
|
|
106
|
-
test.equal(fs.statSync(tmpfile).size, 4204);
|
|
107
|
-
test.done();
|
|
108
|
-
})
|
|
109
|
-
})
|
|
110
|
-
})
|
|
111
|
-
},
|
|
112
|
-
}
|