Haraka 2.8.28 → 3.0.1
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 +2 -10
- package/Changes.md +84 -2
- package/Dockerfile +1 -1
- package/Plugins.md +9 -4
- package/README.md +2 -6
- package/bin/haraka +5 -4
- package/config/outbound.ini +0 -7
- package/config/plugins +1 -1
- package/config/smtp.ini +1 -1
- package/config/smtp_forward.ini +2 -8
- package/config/smtp_proxy.ini +0 -6
- package/connection.js +178 -204
- package/coverage/lcov.info +13863 -0
- package/coverage/tmp/coverage-42958-1658373250585-0.json +1 -0
- package/coverage/tmp/coverage-42961-1658373250529-0.json +1 -0
- package/dkim.js +66 -73
- package/docs/Body.md +1 -22
- package/docs/CoreConfig.md +2 -2
- package/docs/Header.md +1 -47
- package/docs/Outbound.md +8 -36
- package/endpoint.js +1 -1
- package/haraka.js +1 -1
- package/host_pool.js +8 -12
- package/logger.js +25 -32
- package/outbound/client_pool.js +11 -153
- package/outbound/config.js +5 -11
- package/outbound/hmail.js +109 -143
- package/outbound/index.js +13 -25
- package/outbound/mx_lookup.js +10 -7
- package/outbound/queue.js +8 -12
- package/outbound/timer_queue.js +2 -4
- package/outbound/tls.js +17 -18
- package/outbound/todo.js +1 -0
- package/package.json +57 -55
- package/plugins/auth/auth_base.js +39 -63
- package/plugins/auth/auth_bridge.js +3 -4
- package/plugins/auth/auth_proxy.js +16 -16
- package/plugins/auth/auth_vpopmaild.js +30 -37
- package/plugins/auth/flat_file.js +9 -13
- package/plugins/avg.js +9 -11
- package/plugins/backscatterer.js +1 -1
- package/plugins/block_me.js +2 -6
- package/plugins/bounce.js +106 -124
- package/plugins/clamd.js +59 -63
- package/plugins/data.signatures.js +6 -6
- package/plugins/data.uribl.js +1 -415
- package/plugins/delay_deny.js +19 -20
- package/plugins/dkim_sign.js +56 -62
- package/plugins/dkim_verify.js +9 -8
- package/plugins/dns_list_base.js +43 -42
- package/plugins/dnsbl.js +41 -46
- package/plugins/dnswl.js +23 -26
- package/plugins/early_talker.js +24 -28
- package/plugins/esets.js +8 -11
- package/plugins/greylist.js +161 -190
- package/plugins/helo.checks.js +175 -197
- package/plugins/mail_from.is_resolvable.js +38 -38
- package/plugins/messagesniffer.js +33 -40
- package/plugins/prevent_credential_leaks.js +7 -5
- package/plugins/process_title.js +16 -17
- package/plugins/queue/deliver.js +2 -2
- package/plugins/queue/lmtp.js +5 -6
- package/plugins/queue/qmail-queue.js +11 -13
- package/plugins/queue/quarantine.js +25 -34
- package/plugins/queue/rabbitmq.js +3 -2
- package/plugins/queue/rabbitmq_amqplib.js +9 -9
- package/plugins/queue/smtp_bridge.js +5 -4
- package/plugins/queue/smtp_forward.js +81 -89
- package/plugins/queue/smtp_proxy.js +21 -22
- package/plugins/queue/test.js +2 -1
- package/plugins/rcpt_to.host_list_base.js +20 -30
- package/plugins/rcpt_to.in_host_list.js +12 -14
- package/plugins/rcpt_to.max_count.js +7 -5
- package/plugins/record_envelope_addresses.js +4 -6
- package/plugins/relay.js +64 -74
- package/plugins/reseed_rng.js +1 -2
- package/plugins/spamassassin.js +56 -68
- package/plugins/status.js +2 -3
- package/plugins/tarpit.js +8 -11
- package/plugins/tls.js +14 -17
- package/plugins/toobusy.js +6 -8
- package/plugins/xclient.js +14 -25
- package/plugins.js +24 -29
- package/rfc1869.js +2 -2
- package/server.js +3 -13
- package/smtp_client.js +138 -215
- package/tests/config/smtp_forward.ini +0 -6
- package/tests/fixtures/line_socket.js +1 -1
- package/tests/fixtures/util_hmailitem.js +5 -7
- package/tests/fixtures/vm_harness.js +2 -2
- package/tests/host_pool.js +13 -14
- package/tests/installation/plugins/inherits.js +1 -2
- package/tests/logger.js +2 -2
- package/tests/plugins/bounce.js +6 -8
- package/tests/plugins/dkim_signer.js +7 -7
- package/tests/plugins/dns_list_base.js +7 -7
- package/tests/plugins/helo.checks.js +1 -1
- package/tests/plugins/mail_from.is_resolvable.js +10 -54
- package/tests/plugins/queue/smtp_forward.js +11 -11
- package/tests/plugins/rcpt_to.host_list_base.js +1 -1
- package/tests/plugins/rcpt_to.in_host_list.js +1 -1
- package/tests/plugins/spamassassin.js +1 -1
- package/tests/queue/multibyte +0 -0
- package/tests/queue/plain +0 -0
- package/tests/rfc1869.js +4 -1
- package/tests/server.js +15 -9
- package/tests/smtp_client/auth.js +4 -14
- package/tests/smtp_client/basic.js +5 -15
- package/tests/smtp_client.js +7 -3
- package/tests/transaction.js +72 -19
- package/tls_socket.js +75 -85
- package/transaction.js +7 -9
- package/attachment_stream.js +0 -118
- package/bin/spf +0 -48
- package/chunkemitter.js +0 -75
- package/config/data.uribl.excludes +0 -202
- package/config/data.uribl.ini +0 -37
- package/config/spf.ini +0 -1
- package/docs/plugins/attachment.md +0 -92
- package/docs/plugins/data.uribl.md +0 -120
- package/docs/plugins/spf.md +0 -142
- package/mailbody.js +0 -502
- package/mailheader.js +0 -304
- package/messagestream.js +0 -441
- package/plugins/aliases.js +0 -120
- package/plugins/attachment.js +0 -503
- package/plugins/connect.p0f.js +0 -5
- package/plugins/spf.js +0 -327
- package/spf.js +0 -689
- package/tests/mailbody.js +0 -348
- package/tests/mailheader.js +0 -138
- package/tests/messagestream.js +0 -34
- package/tests/plugins/aliases.js +0 -376
- package/tests/plugins/spf.js +0 -251
- package/tests/spf.js +0 -96
package/tests/plugins/aliases.js
DELETED
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const Address = require('address-rfc2821').Address;
|
|
4
|
-
const fixtures = require('haraka-test-fixtures');
|
|
5
|
-
|
|
6
|
-
const stub = fixtures.stub.stub;
|
|
7
|
-
const Connection = fixtures.connection;
|
|
8
|
-
|
|
9
|
-
const _set_up = function (done) {
|
|
10
|
-
|
|
11
|
-
// needed for tests
|
|
12
|
-
this.plugin = new fixtures.plugin('aliases');
|
|
13
|
-
this.recip = new Address('<test1@example.com>');
|
|
14
|
-
this.params = [this.recip];
|
|
15
|
-
|
|
16
|
-
this.connection = Connection.createConnection();
|
|
17
|
-
this.connection.loginfo = stub();
|
|
18
|
-
this.connection.transaction = {
|
|
19
|
-
notes: stub(),
|
|
20
|
-
rcpt_to: [ this.params ],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// some test data
|
|
24
|
-
this.configfile = {
|
|
25
|
-
"test1" : { "action" : "drop" },
|
|
26
|
-
"test2" : { "action" : "drop" },
|
|
27
|
-
"test2-specific" : { "action" : "alias", "to" : "test2" },
|
|
28
|
-
"test3" : { "action" : "alias", "to" : "test3-works" },
|
|
29
|
-
"test4" : { "action" : "alias", "to" : "test4" },
|
|
30
|
-
"test5" : { "action" : "alias", "to" : "test5-works@success.com" },
|
|
31
|
-
"test6" : { "action" : "alias", "to" : "test6-works@success.com" },
|
|
32
|
-
"test7" : { "action" : "fail", "to" : "should_fail" },
|
|
33
|
-
"test8" : { "to" : "should_fail" },
|
|
34
|
-
"test9" : { "action" : "alias" },
|
|
35
|
-
"@example.co" : { "action" : "drop" },
|
|
36
|
-
"test11@example.org" : { "action" : "drop" },
|
|
37
|
-
"@demo.com" : { "action" : "alias", "to" : "test12-works@success.com" },
|
|
38
|
-
"test13@example.net" : { "action" : "alias", "to" : "test13-works@success.com" },
|
|
39
|
-
"test14@example.net" : { "action" : "alias", "to" : ["alice@success.com", "bob@success.com"] }
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
this.plugin.config.get = function (file, type) {
|
|
43
|
-
return this.configfile;
|
|
44
|
-
}.bind(this);
|
|
45
|
-
|
|
46
|
-
this.plugin.inherits = stub();
|
|
47
|
-
|
|
48
|
-
// going to need these in multiple tests
|
|
49
|
-
this.plugin.register();
|
|
50
|
-
|
|
51
|
-
done();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
exports.aliases = {
|
|
55
|
-
setUp : _set_up,
|
|
56
|
-
'should have register function' (test) {
|
|
57
|
-
test.expect(2);
|
|
58
|
-
test.ok(this.plugin);
|
|
59
|
-
test.equal('function', typeof this.plugin.register);
|
|
60
|
-
test.done();
|
|
61
|
-
},
|
|
62
|
-
'register function should inherit from queue/discard' (test) {
|
|
63
|
-
test.expect(2);
|
|
64
|
-
test.ok(this.plugin.inherits.called);
|
|
65
|
-
test.equals(this.plugin.inherits.args[0], 'queue/discard');
|
|
66
|
-
test.done();
|
|
67
|
-
},
|
|
68
|
-
'register function should call register_hook()' (test) {
|
|
69
|
-
test.expect(1);
|
|
70
|
-
test.ok(this.plugin.register_hook.called);
|
|
71
|
-
test.done();
|
|
72
|
-
},
|
|
73
|
-
'register_hook() should register for propper hook' (test) {
|
|
74
|
-
test.expect(1);
|
|
75
|
-
test.equals(this.plugin.register_hook.args[0], 'rcpt');
|
|
76
|
-
test.done();
|
|
77
|
-
},
|
|
78
|
-
'register_hook() should register available function' (test) {
|
|
79
|
-
test.expect(3);
|
|
80
|
-
test.equals(this.plugin.register_hook.args[1], 'aliases');
|
|
81
|
-
test.ok(this.plugin.aliases);
|
|
82
|
-
test.equal('function', typeof this.plugin.aliases);
|
|
83
|
-
test.done();
|
|
84
|
-
},
|
|
85
|
-
'aliases hook always returns next()' (test) {
|
|
86
|
-
function next (action) {
|
|
87
|
-
test.expect(1);
|
|
88
|
-
test.equals(undefined, action);
|
|
89
|
-
test.done();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
93
|
-
},
|
|
94
|
-
'should drop test1@example.com' (test) {
|
|
95
|
-
const next = function (action) {
|
|
96
|
-
test.expect(1);
|
|
97
|
-
test.ok(this.connection.transaction.notes.discard);
|
|
98
|
-
test.done();
|
|
99
|
-
}.bind(this);
|
|
100
|
-
|
|
101
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
102
|
-
},
|
|
103
|
-
'should drop test2-testing@example.com' (test) {
|
|
104
|
-
// these will get reset in _set_up everytime
|
|
105
|
-
this.recip = new Address('<test2-testing@example.com>');
|
|
106
|
-
this.params = [this.recip];
|
|
107
|
-
|
|
108
|
-
const next = function (action) {
|
|
109
|
-
test.expect(1);
|
|
110
|
-
test.ok(this.connection.transaction.notes.discard);
|
|
111
|
-
test.done();
|
|
112
|
-
}.bind(this);
|
|
113
|
-
|
|
114
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
115
|
-
},
|
|
116
|
-
'should drop test2-specific@example.com' (test) {
|
|
117
|
-
// these will get reset in _set_up everytime
|
|
118
|
-
this.recip = new Address('<test2-specific@example.com>');
|
|
119
|
-
this.params = [this.recip];
|
|
120
|
-
const result = new Address('<test2@example.com>');
|
|
121
|
-
|
|
122
|
-
const next = function (action) {
|
|
123
|
-
test.expect(4);
|
|
124
|
-
test.equals(undefined, this.connection.transaction.notes.discard);
|
|
125
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
126
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
127
|
-
test.deepEqual(this.connection.transaction.rcpt_to.pop(), result);
|
|
128
|
-
test.done();
|
|
129
|
-
}.bind(this);
|
|
130
|
-
|
|
131
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
132
|
-
},
|
|
133
|
-
'should map test3@example.com to test3-works@example.com' (test) {
|
|
134
|
-
// these will get reset in _set_up everytime
|
|
135
|
-
this.recip = new Address('<test3@example.com>');
|
|
136
|
-
this.params = [this.recip];
|
|
137
|
-
const result = new Address('<test3-works@example.com>');
|
|
138
|
-
|
|
139
|
-
const next = function (action) {
|
|
140
|
-
test.expect(3);
|
|
141
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
142
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
143
|
-
test.deepEqual(this.connection.transaction.rcpt_to.pop(), result);
|
|
144
|
-
test.done();
|
|
145
|
-
}.bind(this);
|
|
146
|
-
|
|
147
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
148
|
-
},
|
|
149
|
-
'should map test4-testing@example.com to test4@example.com' (test) {
|
|
150
|
-
// these will get reset in _set_up everytime
|
|
151
|
-
this.recip = new Address('<test4-testing@example.com>');
|
|
152
|
-
this.params = [this.recip];
|
|
153
|
-
const result = new Address('<test4@example.com>');
|
|
154
|
-
|
|
155
|
-
const next = function (action) {
|
|
156
|
-
test.expect(3);
|
|
157
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
158
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
159
|
-
test.deepEqual(this.connection.transaction.rcpt_to.pop(), result);
|
|
160
|
-
test.done();
|
|
161
|
-
}.bind(this);
|
|
162
|
-
|
|
163
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
164
|
-
},
|
|
165
|
-
'should map test4+testing@example.com to test4@example.com' (test) {
|
|
166
|
-
// these will get reset in _set_up everytime
|
|
167
|
-
this.recip = new Address('<test4+testing@example.com>');
|
|
168
|
-
this.params = [this.recip];
|
|
169
|
-
const result = new Address('<test4@example.com>');
|
|
170
|
-
|
|
171
|
-
const next = function (action) {
|
|
172
|
-
test.expect(3);
|
|
173
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
174
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
175
|
-
test.deepEqual(this.connection.transaction.rcpt_to.pop(), result);
|
|
176
|
-
test.done();
|
|
177
|
-
}.bind(this);
|
|
178
|
-
|
|
179
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
180
|
-
},
|
|
181
|
-
'should map test5@example.com to test5-works@success.com' (test) {
|
|
182
|
-
// these will get reset in _set_up everytime
|
|
183
|
-
this.recip = new Address('<test5@example.com>');
|
|
184
|
-
this.params = [this.recip];
|
|
185
|
-
const result = new Address('<test5-works@success.com>');
|
|
186
|
-
|
|
187
|
-
const next = function (action) {
|
|
188
|
-
test.expect(3);
|
|
189
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
190
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
191
|
-
test.deepEqual(this.connection.transaction.rcpt_to.pop(), result);
|
|
192
|
-
test.done();
|
|
193
|
-
}.bind(this);
|
|
194
|
-
|
|
195
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
196
|
-
},
|
|
197
|
-
'should map test6-testing@example.com to test6-works@success.com' (test) {
|
|
198
|
-
// these will get reset in _set_up everytime
|
|
199
|
-
this.recip = new Address('<test6-testing@example.com>');
|
|
200
|
-
this.params = [this.recip];
|
|
201
|
-
const result = new Address('<test6-works@success.com>');
|
|
202
|
-
|
|
203
|
-
const next = function (action) {
|
|
204
|
-
test.expect(3);
|
|
205
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
206
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
207
|
-
test.deepEqual(this.connection.transaction.rcpt_to.pop(), result);
|
|
208
|
-
test.done();
|
|
209
|
-
}.bind(this);
|
|
210
|
-
|
|
211
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
212
|
-
},
|
|
213
|
-
'should drop @example.co' (test) {
|
|
214
|
-
this.recip = new Address('<oc.elpmaxe@example.co>');
|
|
215
|
-
this.params = [this.recip];
|
|
216
|
-
|
|
217
|
-
const next = function (action) {
|
|
218
|
-
test.expect(1);
|
|
219
|
-
test.ok(this.connection.transaction.notes.discard);
|
|
220
|
-
test.done();
|
|
221
|
-
}.bind(this);
|
|
222
|
-
|
|
223
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
224
|
-
},
|
|
225
|
-
'should drop test11@example.com' (test) {
|
|
226
|
-
this.recip = new Address('<test11@example.org>');
|
|
227
|
-
this.params = [this.recip];
|
|
228
|
-
|
|
229
|
-
const next = function (action) {
|
|
230
|
-
test.expect(1);
|
|
231
|
-
test.ok(this.connection.transaction.notes.discard);
|
|
232
|
-
test.done();
|
|
233
|
-
}.bind(this);
|
|
234
|
-
|
|
235
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
236
|
-
},
|
|
237
|
-
'should map @demo.com to test12-works@success.com' (test) {
|
|
238
|
-
// these will get reset in _set_up everytime
|
|
239
|
-
this.recip = new Address('<demo2014@demo.com>');
|
|
240
|
-
this.params = [this.recip];
|
|
241
|
-
const result = new Address('<test12-works@success.com>');
|
|
242
|
-
|
|
243
|
-
const next = function (action) {
|
|
244
|
-
test.expect(3);
|
|
245
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
246
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
247
|
-
test.deepEqual(this.connection.transaction.rcpt_to.pop(), result);
|
|
248
|
-
test.done();
|
|
249
|
-
}.bind(this);
|
|
250
|
-
|
|
251
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
252
|
-
},
|
|
253
|
-
'should map test13@example.net to test13-works@success.com' (test) {
|
|
254
|
-
// these will get reset in _set_up everytime
|
|
255
|
-
this.recip = new Address('<test13@example.net>');
|
|
256
|
-
this.params = [this.recip];
|
|
257
|
-
const result = new Address('<test13-works@success.com>');
|
|
258
|
-
|
|
259
|
-
const next = function (action) {
|
|
260
|
-
test.expect(3);
|
|
261
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
262
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
263
|
-
test.deepEqual(this.connection.transaction.rcpt_to.pop(), result);
|
|
264
|
-
test.done();
|
|
265
|
-
}.bind(this);
|
|
266
|
-
|
|
267
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
268
|
-
},
|
|
269
|
-
'should map test13+subaddress@example.net to test13-works@success.com' (test) {
|
|
270
|
-
// these will get reset in _set_up everytime
|
|
271
|
-
this.recip = new Address('<test13+subaddress@example.net>');
|
|
272
|
-
this.params = [this.recip];
|
|
273
|
-
const result = new Address('<test13-works@success.com>');
|
|
274
|
-
|
|
275
|
-
const next = function (action) {
|
|
276
|
-
test.expect(3);
|
|
277
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
278
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
279
|
-
test.deepEqual(this.connection.transaction.rcpt_to.pop(), result);
|
|
280
|
-
test.done();
|
|
281
|
-
}.bind(this);
|
|
282
|
-
|
|
283
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
284
|
-
},
|
|
285
|
-
'should explode test14@example.net to alice@success.com and bob@success.com' (test) {
|
|
286
|
-
// these will get reset in _set_up everytime
|
|
287
|
-
this.recip = new Address('<test14@example.net>');
|
|
288
|
-
this.params = [this.recip];
|
|
289
|
-
const result = [new Address('<alice@success.com>'), new Address('<bob@success.com>')];
|
|
290
|
-
|
|
291
|
-
const next = function (action) {
|
|
292
|
-
test.expect(3);
|
|
293
|
-
test.ok(this.connection.transaction.rcpt_to);
|
|
294
|
-
test.ok(Array.isArray(this.connection.transaction.rcpt_to));
|
|
295
|
-
test.deepEqual(this.connection.transaction.rcpt_to, result);
|
|
296
|
-
test.done();
|
|
297
|
-
}.bind(this);
|
|
298
|
-
|
|
299
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
300
|
-
},
|
|
301
|
-
'should not drop test1@example.com, no config' (test) {
|
|
302
|
-
// empty config data
|
|
303
|
-
this.configfile = {};
|
|
304
|
-
this.plugin.config.get = function (file, type) {
|
|
305
|
-
return this.configfile;
|
|
306
|
-
}.bind(this);
|
|
307
|
-
|
|
308
|
-
const next = function (action) {
|
|
309
|
-
test.expect(1);
|
|
310
|
-
test.equals(undefined, this.connection.transaction.notes.discard);
|
|
311
|
-
test.done();
|
|
312
|
-
}.bind(this);
|
|
313
|
-
|
|
314
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
315
|
-
},
|
|
316
|
-
'should not drop test1@example.com, config undefined' (test) {
|
|
317
|
-
// undefined config data
|
|
318
|
-
this.configfile = undefined;
|
|
319
|
-
this.plugin.config.get = function (file, type) {
|
|
320
|
-
return this.configfile;
|
|
321
|
-
}.bind(this);
|
|
322
|
-
|
|
323
|
-
const next = function (action) {
|
|
324
|
-
test.expect(1);
|
|
325
|
-
test.equals(undefined, this.connection.transaction.notes.discard);
|
|
326
|
-
test.done();
|
|
327
|
-
}.bind(this);
|
|
328
|
-
|
|
329
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
330
|
-
},
|
|
331
|
-
'should fail with loginfo on unknown action' (test) {
|
|
332
|
-
// these will get reset in _set_up everytime
|
|
333
|
-
this.recip = new Address('<test7@example.com>');
|
|
334
|
-
this.params = [this.recip];
|
|
335
|
-
|
|
336
|
-
const next = function (action) {
|
|
337
|
-
test.expect(2);
|
|
338
|
-
test.ok(this.connection.loginfo.called);
|
|
339
|
-
test.equals(this.connection.loginfo.args[1],
|
|
340
|
-
`unknown action: ${this.configfile.test7.action}`);
|
|
341
|
-
test.done();
|
|
342
|
-
}.bind(this);
|
|
343
|
-
|
|
344
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
345
|
-
},
|
|
346
|
-
'should fail with loginfo on missing action' (test) {
|
|
347
|
-
// these will get reset in _set_up everytime
|
|
348
|
-
this.recip = new Address('<test8@example.com>');
|
|
349
|
-
this.params = [this.recip];
|
|
350
|
-
|
|
351
|
-
const next = function (action) {
|
|
352
|
-
test.expect(2);
|
|
353
|
-
test.ok(this.connection.loginfo.called);
|
|
354
|
-
test.equals(this.connection.loginfo.args[1],
|
|
355
|
-
"unknown action: <missing>");
|
|
356
|
-
test.done();
|
|
357
|
-
}.bind(this);
|
|
358
|
-
|
|
359
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
360
|
-
},
|
|
361
|
-
'action alias should fail with loginfo on missing to' (test) {
|
|
362
|
-
// these will get reset in _set_up everytime
|
|
363
|
-
this.recip = new Address('<test9@example.com>');
|
|
364
|
-
this.params = [this.recip];
|
|
365
|
-
|
|
366
|
-
const next = function (action) {
|
|
367
|
-
test.expect(2);
|
|
368
|
-
test.ok(this.connection.loginfo.called);
|
|
369
|
-
test.equals(this.connection.loginfo.args[1],
|
|
370
|
-
'alias failed for test9, no "to" field in alias config');
|
|
371
|
-
test.done();
|
|
372
|
-
}.bind(this);
|
|
373
|
-
|
|
374
|
-
this.plugin.aliases(next, this.connection, this.params);
|
|
375
|
-
}
|
|
376
|
-
}
|
package/tests/plugins/spf.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const Address = require('address-rfc2821').Address;
|
|
4
|
-
const fixtures = require('haraka-test-fixtures');
|
|
5
|
-
const constants = require('haraka-constants');
|
|
6
|
-
|
|
7
|
-
const SPF = require('../../spf').SPF;
|
|
8
|
-
const spf = new SPF();
|
|
9
|
-
|
|
10
|
-
const _set_up = function (done) {
|
|
11
|
-
|
|
12
|
-
this.plugin = new fixtures.plugin('spf');
|
|
13
|
-
this.plugin.timeout = 8000;
|
|
14
|
-
this.plugin.load_spf_ini();
|
|
15
|
-
|
|
16
|
-
// uncomment this line to see detailed SPF evaluation
|
|
17
|
-
this.plugin.SPF.prototype.log_debug = () => {};
|
|
18
|
-
|
|
19
|
-
this.connection = fixtures.connection.createConnection();
|
|
20
|
-
this.connection.transaction = fixtures.transaction.createTransaction();
|
|
21
|
-
this.connection.transaction.results = new fixtures.results(this.connection);
|
|
22
|
-
|
|
23
|
-
done();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
exports.return_results = {
|
|
27
|
-
setUp : _set_up,
|
|
28
|
-
'result, none, reject=false' (test) {
|
|
29
|
-
function next () {
|
|
30
|
-
test.equal(undefined, arguments[0]);
|
|
31
|
-
test.done();
|
|
32
|
-
}
|
|
33
|
-
test.expect(1);
|
|
34
|
-
this.plugin.cfg.deny.mfrom_none=false;
|
|
35
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_NONE, 'test@example.com');
|
|
36
|
-
},
|
|
37
|
-
'result, none, reject=true' (test) {
|
|
38
|
-
function next () {
|
|
39
|
-
test.equal(DENY, arguments[0]);
|
|
40
|
-
test.done();
|
|
41
|
-
}
|
|
42
|
-
test.expect(1);
|
|
43
|
-
this.plugin.cfg.deny.mfrom_none=true;
|
|
44
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_NONE, 'test@example.com');
|
|
45
|
-
},
|
|
46
|
-
'result, neutral' (test) {
|
|
47
|
-
function next () {
|
|
48
|
-
test.equal(undefined, arguments[0]);
|
|
49
|
-
test.done();
|
|
50
|
-
}
|
|
51
|
-
test.expect(1);
|
|
52
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_NEUTRAL, 'test@example.com');
|
|
53
|
-
},
|
|
54
|
-
'result, pass' (test) {
|
|
55
|
-
function next () {
|
|
56
|
-
test.equal(undefined, arguments[0]);
|
|
57
|
-
test.done();
|
|
58
|
-
}
|
|
59
|
-
test.expect(1);
|
|
60
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_PASS, 'test@example.com');
|
|
61
|
-
},
|
|
62
|
-
'result, softfail, reject=false' (test) {
|
|
63
|
-
function next () {
|
|
64
|
-
test.equal(undefined, arguments[0]);
|
|
65
|
-
test.done();
|
|
66
|
-
}
|
|
67
|
-
test.expect(1);
|
|
68
|
-
this.plugin.cfg.deny.mfrom_softfail=false;
|
|
69
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_SOFTFAIL, 'test@example.com');
|
|
70
|
-
},
|
|
71
|
-
'result, softfail, reject=true' (test) {
|
|
72
|
-
function next () {
|
|
73
|
-
test.equal(DENY, arguments[0]);
|
|
74
|
-
test.done();
|
|
75
|
-
}
|
|
76
|
-
test.expect(1);
|
|
77
|
-
this.plugin.cfg.deny.mfrom_softfail=true;
|
|
78
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_SOFTFAIL, 'test@example.com');
|
|
79
|
-
},
|
|
80
|
-
'result, fail, reject=false' (test) {
|
|
81
|
-
function next () {
|
|
82
|
-
test.equal(undefined, arguments[0]);
|
|
83
|
-
test.done();
|
|
84
|
-
}
|
|
85
|
-
test.expect(1);
|
|
86
|
-
this.plugin.cfg.deny.mfrom_fail=false;
|
|
87
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_FAIL, 'test@example.com');
|
|
88
|
-
},
|
|
89
|
-
'result, fail, reject=true' (test) {
|
|
90
|
-
function next () {
|
|
91
|
-
test.equal(DENY, arguments[0]);
|
|
92
|
-
test.done();
|
|
93
|
-
}
|
|
94
|
-
test.expect(1);
|
|
95
|
-
this.plugin.cfg.deny.mfrom_fail=true;
|
|
96
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_FAIL, 'test@example.com');
|
|
97
|
-
},
|
|
98
|
-
'result, temperror, reject=false' (test) {
|
|
99
|
-
function next () {
|
|
100
|
-
test.equal(undefined, arguments[0]);
|
|
101
|
-
test.done();
|
|
102
|
-
}
|
|
103
|
-
test.expect(1);
|
|
104
|
-
this.plugin.cfg.defer.mfrom_temperror=false;
|
|
105
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_TEMPERROR, 'test@example.com');
|
|
106
|
-
},
|
|
107
|
-
'result, temperror, reject=true' (test) {
|
|
108
|
-
function next () {
|
|
109
|
-
test.equal(DENYSOFT, arguments[0]);
|
|
110
|
-
test.done();
|
|
111
|
-
}
|
|
112
|
-
test.expect(1);
|
|
113
|
-
this.plugin.cfg.defer.mfrom_temperror=true;
|
|
114
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_TEMPERROR, 'test@example.com');
|
|
115
|
-
},
|
|
116
|
-
'result, permerror, reject=false' (test) {
|
|
117
|
-
function next () {
|
|
118
|
-
test.equal(undefined, arguments[0]);
|
|
119
|
-
test.done();
|
|
120
|
-
}
|
|
121
|
-
test.expect(1);
|
|
122
|
-
this.plugin.cfg.deny.mfrom_permerror=false;
|
|
123
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_PERMERROR, 'test@example.com');
|
|
124
|
-
},
|
|
125
|
-
'result, permerror, reject=true' (test) {
|
|
126
|
-
function next () {
|
|
127
|
-
test.equal(DENY, arguments[0]);
|
|
128
|
-
test.done();
|
|
129
|
-
}
|
|
130
|
-
test.expect(1);
|
|
131
|
-
this.plugin.cfg.deny.mfrom_permerror=true;
|
|
132
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', spf.SPF_PERMERROR, 'test@example.com');
|
|
133
|
-
},
|
|
134
|
-
'result, unknown' (test) {
|
|
135
|
-
function next () {
|
|
136
|
-
test.equal(undefined, arguments[0]);
|
|
137
|
-
test.done();
|
|
138
|
-
}
|
|
139
|
-
test.expect(1);
|
|
140
|
-
this.plugin.return_results(next, this.connection, spf, 'mfrom', 'unknown', 'test@example.com');
|
|
141
|
-
},
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
exports.hook_helo = {
|
|
145
|
-
setUp : _set_up,
|
|
146
|
-
'rfc1918' (test) {
|
|
147
|
-
let completed = 0;
|
|
148
|
-
function next (rc) {
|
|
149
|
-
completed++;
|
|
150
|
-
test.equal(undefined, rc);
|
|
151
|
-
if (completed >= 2) test.done();
|
|
152
|
-
}
|
|
153
|
-
test.expect(2);
|
|
154
|
-
this.connection.remote.is_private=true;
|
|
155
|
-
this.plugin.helo_spf(next, this.connection);
|
|
156
|
-
this.plugin.helo_spf(next, this.connection, 'helo.sender.com');
|
|
157
|
-
},
|
|
158
|
-
'IPv4 literal' (test) {
|
|
159
|
-
function next (rc) {
|
|
160
|
-
test.equal(undefined, rc);
|
|
161
|
-
test.done();
|
|
162
|
-
}
|
|
163
|
-
test.expect(1);
|
|
164
|
-
this.connection.remote.ip='190.168.1.1';
|
|
165
|
-
this.plugin.helo_spf(next, this.connection, '[190.168.1.1]' );
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const test_addr = new Address('<test@example.com>');
|
|
171
|
-
|
|
172
|
-
exports.hook_mail = {
|
|
173
|
-
setUp : _set_up,
|
|
174
|
-
'rfc1918' (test) {
|
|
175
|
-
function next () {
|
|
176
|
-
test.equal(undefined, arguments[0]);
|
|
177
|
-
test.done();
|
|
178
|
-
}
|
|
179
|
-
test.expect(1);
|
|
180
|
-
this.connection.remote.is_private=true;
|
|
181
|
-
this.connection.remote.ip='192.168.1.1';
|
|
182
|
-
this.plugin.hook_mail(next, this.connection, [test_addr]);
|
|
183
|
-
},
|
|
184
|
-
'rfc1918 relaying' (test) {
|
|
185
|
-
function next () {
|
|
186
|
-
test.ok([undefined, constants.CONT].includes(arguments[0]));
|
|
187
|
-
test.done();
|
|
188
|
-
}
|
|
189
|
-
test.expect(1);
|
|
190
|
-
this.connection.set('remote.is_private', true);
|
|
191
|
-
this.connection.set('remote.ip','192.168.1.1');
|
|
192
|
-
this.connection.relaying=true;
|
|
193
|
-
this.plugin.hook_mail(next, this.connection, [test_addr]);
|
|
194
|
-
},
|
|
195
|
-
'no txn' (test) {
|
|
196
|
-
function next () {
|
|
197
|
-
test.equal(undefined, arguments[0]);
|
|
198
|
-
test.done();
|
|
199
|
-
}
|
|
200
|
-
test.expect(1);
|
|
201
|
-
this.connection.remote.ip='207.85.1.1';
|
|
202
|
-
delete this.connection.transaction;
|
|
203
|
-
this.plugin.hook_mail(next, this.connection);
|
|
204
|
-
},
|
|
205
|
-
'txn, no helo' (test) {
|
|
206
|
-
function next () {
|
|
207
|
-
test.equal(undefined, arguments[0]);
|
|
208
|
-
test.done();
|
|
209
|
-
}
|
|
210
|
-
test.expect(1);
|
|
211
|
-
this.plugin.cfg.deny.mfrom_fail = false;
|
|
212
|
-
this.connection.remote.ip='207.85.1.1';
|
|
213
|
-
this.plugin.hook_mail(next, this.connection, [test_addr]);
|
|
214
|
-
},
|
|
215
|
-
'txn' (test) {
|
|
216
|
-
function next (rc) {
|
|
217
|
-
test.equal(undefined, rc);
|
|
218
|
-
test.done();
|
|
219
|
-
}
|
|
220
|
-
test.expect(1);
|
|
221
|
-
this.connection.set('remote', 'ip', '207.85.1.1');
|
|
222
|
-
this.connection.set('hello', 'host', 'mail.example.com');
|
|
223
|
-
this.plugin.hook_mail(next, this.connection, [test_addr]);
|
|
224
|
-
},
|
|
225
|
-
'txn, relaying' (test) {
|
|
226
|
-
function next (rc) {
|
|
227
|
-
test.equal(undefined, rc);
|
|
228
|
-
test.done();
|
|
229
|
-
}
|
|
230
|
-
test.expect(1);
|
|
231
|
-
this.connection.set('remote.ip', '207.85.1.1');
|
|
232
|
-
this.connection.relaying=true;
|
|
233
|
-
this.connection.set('hello.host', 'mail.example.com');
|
|
234
|
-
this.plugin.hook_mail(next, this.connection, [test_addr]);
|
|
235
|
-
},
|
|
236
|
-
'txn, relaying, is_private' (test) {
|
|
237
|
-
function next (rc) {
|
|
238
|
-
test.equal(undefined, rc);
|
|
239
|
-
test.done();
|
|
240
|
-
}
|
|
241
|
-
test.expect(1);
|
|
242
|
-
this.plugin.cfg.relay.context='myself';
|
|
243
|
-
this.plugin.cfg.deny_relay.mfrom_fail = true;
|
|
244
|
-
this.connection.set('remote.ip', '127.0.1.1');
|
|
245
|
-
this.connection.set('remote.is_private', true);
|
|
246
|
-
this.connection.relaying = true;
|
|
247
|
-
this.connection.set('hello.host', 'www.tnpi.net');
|
|
248
|
-
this.plugin.nu.public_ip = '66.128.51.165';
|
|
249
|
-
this.plugin.hook_mail(next, this.connection, [new Address('<nonexist@tnpi.net>')]);
|
|
250
|
-
},
|
|
251
|
-
}
|