Haraka 3.1.3 → 3.1.5

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.
Files changed (65) hide show
  1. package/.prettierignore +2 -0
  2. package/CONTRIBUTORS.md +23 -1
  3. package/Changes.md +52 -0
  4. package/Plugins.md +81 -64
  5. package/README.md +1 -1
  6. package/bin/haraka +7 -5
  7. package/connection.js +15 -19
  8. package/docs/Plugins.md +1 -1
  9. package/docs/plugins/aliases.md +0 -2
  10. package/docs/plugins/queue/qmail-queue.md +0 -1
  11. package/logger.js +2 -2
  12. package/outbound/hmail.js +76 -83
  13. package/outbound/index.js +36 -34
  14. package/outbound/queue.js +231 -176
  15. package/package.json +26 -29
  16. package/plugins/prevent_credential_leaks.js +2 -2
  17. package/plugins/process_title.js +1 -1
  18. package/plugins/queue/smtp_forward.js +5 -5
  19. package/plugins/status.js +8 -5
  20. package/plugins/tls.js +1 -1
  21. package/plugins.js +19 -14
  22. package/rfc1869.js +10 -10
  23. package/run_tests +8 -2
  24. package/server.js +15 -10
  25. package/smtp_client.js +10 -15
  26. package/test/config/tls/haraka.local.pem +47 -47
  27. package/test/connection.js +286 -147
  28. package/test/endpoint.js +5 -4
  29. package/test/fixtures/line_socket.js +1 -0
  30. package/test/fixtures/util_hmailitem.js +1 -1
  31. package/test/host_pool.js +57 -31
  32. package/test/logger.js +75 -135
  33. package/test/outbound/bounce_net_errors.js +132 -0
  34. package/test/outbound/bounce_rfc3464.js +226 -0
  35. package/test/outbound/hmail.js +140 -104
  36. package/test/outbound/index.js +61 -101
  37. package/test/outbound/qfile.js +25 -25
  38. package/test/outbound/queue.js +233 -0
  39. package/test/plugins/auth/auth_base.js +39 -44
  40. package/test/plugins/auth/auth_vpopmaild.js +8 -9
  41. package/test/plugins/queue/smtp_forward.js +953 -183
  42. package/test/plugins/rcpt_to.host_list_base.js +58 -93
  43. package/test/plugins/rcpt_to.in_host_list.js +126 -175
  44. package/test/plugins/record_envelope_addresses.js +93 -0
  45. package/test/plugins/status.js +10 -10
  46. package/test/plugins/tls.js +11 -21
  47. package/test/plugins/xclient.js +102 -0
  48. package/test/plugins.js +10 -13
  49. package/test/rfc1869.js +71 -48
  50. package/test/server.js +281 -436
  51. package/test/smtp_client.js +1194 -220
  52. package/test/tls_socket.js +74 -243
  53. package/test/transaction.js +486 -201
  54. package/tls_socket.js +19 -23
  55. package/transaction.js +33 -10
  56. package/config/rabbitmq.ini +0 -10
  57. package/config/rabbitmq_amqplib.ini +0 -19
  58. package/docs/plugins/queue/rabbitmq.md +0 -34
  59. package/docs/plugins/queue/rabbitmq_amqplib.md +0 -51
  60. package/plugins/queue/rabbitmq.js +0 -141
  61. package/plugins/queue/rabbitmq_amqplib.js +0 -96
  62. package/test/config/tls/ec.pem +0 -23
  63. package/test/config/tls/mismatched.pem +0 -49
  64. package/test/outbound_bounce_net_errors.js +0 -157
  65. package/test/outbound_bounce_rfc3464.js +0 -366
package/test/host_pool.js CHANGED
@@ -1,20 +1,20 @@
1
1
  'use strict'
2
2
 
3
- const assert = require('node:assert')
3
+ const { describe, it } = require('node:test')
4
+ const assert = require('node:assert/strict')
4
5
 
5
6
  const HostPool = require('../host_pool')
6
7
 
7
8
  describe('HostPool', () => {
8
- it('get a host', (done) => {
9
+ it('get a host', () => {
9
10
  const pool = new HostPool('1.1.1.1:1111, 2.2.2.2:2222')
10
11
  const host = pool.get_host()
11
12
 
12
13
  assert.ok(/\d\.\d\.\d\.\d/.test(host.host), `'${host.host}' looks like a IP`)
13
14
  assert.ok(/\d\d\d\d/.test(host.port), `'${host.port}' looks like a port`)
14
- done()
15
15
  })
16
16
 
17
- it('uses all the list', (done) => {
17
+ it('uses all the list', () => {
18
18
  const pool = new HostPool('1.1.1.1:1111, 2.2.2.2:2222')
19
19
 
20
20
  const host1 = pool.get_host()
@@ -24,10 +24,9 @@ describe('HostPool', () => {
24
24
  assert.notEqual(host1.host, host2.host)
25
25
  assert.notEqual(host3.host, host2.host)
26
26
  assert.equal(host3.host, host1.host)
27
- done()
28
27
  })
29
28
 
30
- it('default port 25', (done) => {
29
+ it('default port 25', () => {
31
30
  const pool = new HostPool('1.1.1.1, 2.2.2.2')
32
31
 
33
32
  const host1 = pool.get_host()
@@ -35,11 +34,24 @@ describe('HostPool', () => {
35
34
 
36
35
  assert.equal(host1.port, 25, `is port 25: ${host1.port}`)
37
36
  assert.equal(host2.port, 25, `is port 25: ${host2.port}`)
38
- done()
39
37
  })
40
38
 
41
- it('dead host', (done) => {
42
- const pool = new HostPool('1.1.1.1:1111, 2.2.2.2:2222')
39
+ it('dead host', () => {
40
+ const pool = new HostPool('1.1.1.1:1111, 2.2.2.2:2222', 0.001)
41
+ pool.get_socket = () => ({
42
+ pretendTimeout: () => {},
43
+ setTimeout(ms, cb) {
44
+ this.pretendTimeout = cb
45
+ },
46
+ listeners: {},
47
+ on(ev, cb) {
48
+ this.listeners[ev] = cb
49
+ },
50
+ connect(port, host, cb) {
51
+ cb()
52
+ }, // immediately "connects" to stop retry loop
53
+ destroy() {},
54
+ })
43
55
 
44
56
  pool.failed('1.1.1.1', '1111')
45
57
 
@@ -51,17 +63,30 @@ describe('HostPool', () => {
51
63
  assert.equal(host.host, '2.2.2.2', 'dead host is not returned')
52
64
  host = pool.get_host()
53
65
  assert.equal(host.host, '2.2.2.2', 'dead host is not returned')
54
- done()
55
66
  })
56
67
 
57
68
  // if they're *all* dead, we return a host to try anyway, to keep from
58
69
  // accidentally DOS'ing ourselves if there's a transient but widespread
59
70
  // network outage
60
- it("they're all dead", (done) => {
71
+ it("they're all dead", () => {
61
72
  let host1
62
73
  let host2
63
74
 
64
- const pool = new HostPool('1.1.1.1:1111, 2.2.2.2:2222')
75
+ const pool = new HostPool('1.1.1.1:1111, 2.2.2.2:2222', 0.001)
76
+ pool.get_socket = () => ({
77
+ pretendTimeout: () => {},
78
+ setTimeout(ms, cb) {
79
+ this.pretendTimeout = cb
80
+ },
81
+ listeners: {},
82
+ on(ev, cb) {
83
+ this.listeners[ev] = cb
84
+ },
85
+ connect(port, host, cb) {
86
+ cb()
87
+ }, // immediately "connects" to stop retry loop
88
+ destroy() {},
89
+ })
65
90
 
66
91
  host1 = pool.get_host()
67
92
 
@@ -79,13 +104,12 @@ describe('HostPool', () => {
79
104
  host2 = pool.get_host()
80
105
  assert.ok(host2, "if they're all dead, try one anyway")
81
106
  assert.notEqual(host1.host, host2.host, 'rotation continues')
82
- done()
83
107
  })
84
108
 
85
109
  // after .01 secs the timer to retry the dead host will fire, and then
86
110
  // we connect using this mock socket, whose "connect" always succeeds
87
111
  // so the code brings the dead host back to life
88
- it('host dead checking timer', (done) => {
112
+ it('host dead checking timer', async () => {
89
113
  let num_reqs = 0
90
114
  const MockSocket = function MockSocket(pool) {
91
115
  // these are the methods called from probe_dead_host
@@ -141,22 +165,24 @@ describe('HostPool', () => {
141
165
 
142
166
  // probe_dead_host() will hit two failures and one success (based on
143
167
  // num_reqs above). So we wait at least 10s for that to happen:
144
- const timer = setTimeout(() => {
145
- clearInterval(interval)
146
- assert.ok(false, 'probe_dead_host failed')
147
- done()
148
- }, 10 * 1000)
149
-
150
- const interval = setInterval(
151
- () => {
152
- if (!pool.dead_hosts['1.1.1.1:1111']) {
153
- clearTimeout(timer)
154
- clearInterval(interval)
155
- assert.ok(true, 'timer un-deaded it')
156
- done()
157
- }
158
- },
159
- retry_secs * 1000 * 3,
160
- )
168
+ await new Promise((resolve, reject) => {
169
+ const timer = setTimeout(() => {
170
+ clearInterval(interval)
171
+ reject(new Error('probe_dead_host failed'))
172
+ }, 10 * 1000)
173
+
174
+ const interval = setInterval(
175
+ () => {
176
+ if (!pool.dead_hosts['1.1.1.1:1111']) {
177
+ clearTimeout(timer)
178
+ clearInterval(interval)
179
+ resolve()
180
+ }
181
+ },
182
+ retry_secs * 1000 * 3,
183
+ )
184
+ })
185
+
186
+ assert.ok(true, 'timer un-deaded it')
161
187
  })
162
188
  })
package/test/logger.js CHANGED
@@ -1,9 +1,11 @@
1
- const assert = require('node:assert')
1
+ 'use strict'
2
+
3
+ const { describe, it, beforeEach } = require('node:test')
4
+ const assert = require('node:assert/strict')
2
5
  const util = require('node:util')
3
6
 
4
- const _set_up = (done) => {
7
+ const _set_up = () => {
5
8
  this.logger = require('../logger')
6
- done()
7
9
  }
8
10
 
9
11
  describe('logger', () => {
@@ -16,55 +18,23 @@ describe('logger', () => {
16
18
  })
17
19
 
18
20
  describe('log', () => {
19
- it('log', () => {
20
- this.logger.deferred_logs = []
21
- assert.equal(0, this.logger.deferred_logs.length)
22
- assert.ok(this.logger.log('WARN', 'test warning'))
23
- assert.equal(1, this.logger.deferred_logs.length)
24
- })
25
-
26
- it('log, w/deferred', () => {
27
- this.logger.plugins = { plugin_list: true }
28
- this.logger.deferred_logs.push({
29
- level: 'INFO',
30
- data: 'log test info',
21
+ const formats = ['DEFAULT', 'LOGFMT', 'JSON']
22
+
23
+ for (const fmt of formats) {
24
+ it(`log in ${fmt} format`, () => {
25
+ this.logger.deferred_logs = []
26
+ this.logger.format = this.logger.formats[fmt]
27
+ assert.ok(this.logger.log('WARN', 'test warning'))
28
+ assert.equal(this.logger.deferred_logs.length, 1)
31
29
  })
32
- assert.ok(this.logger.log('INFO', 'another test info'))
33
- })
34
30
 
35
- it('log in logfmt', () => {
36
- this.logger.deferred_logs = []
37
- this.logger.format = this.logger.formats.LOGFMT
38
- assert.equal(0, this.logger.deferred_logs.length)
39
- assert.ok(this.logger.log('WARN', 'test warning'))
40
- assert.equal(1, this.logger.deferred_logs.length)
41
- })
42
-
43
- it('log in logfmt w/deferred', () => {
44
- this.logger.plugins = { plugin_list: true }
45
- this.logger.deferred_logs.push({
46
- level: 'INFO',
47
- data: 'log test info',
31
+ it(`log in ${fmt} format w/deferred`, () => {
32
+ this.logger.format = this.logger.formats[fmt]
33
+ this.logger.plugins = { plugin_list: true }
34
+ this.logger.deferred_logs.push({ level: 'INFO', data: 'log test info' })
35
+ assert.ok(this.logger.log('INFO', 'another test info'))
48
36
  })
49
- assert.ok(this.logger.log('INFO', 'another test info'))
50
- })
51
-
52
- it('log in json', () => {
53
- this.logger.deferred_logs = []
54
- this.logger.format = this.logger.formats.JSON
55
- assert.equal(0, this.logger.deferred_logs.length)
56
- assert.ok(this.logger.log('WARN', 'test warning'))
57
- assert.equal(1, this.logger.deferred_logs.length)
58
- })
59
-
60
- it('log in json w/deferred', () => {
61
- this.logger.plugins = { plugin_list: true }
62
- this.logger.deferred_logs.push({
63
- level: 'INFO',
64
- data: 'log test info',
65
- })
66
- assert.ok(this.logger.log('INFO', 'another test info'))
67
- })
37
+ }
68
38
  })
69
39
 
70
40
  describe('level', () => {
@@ -75,68 +45,40 @@ describe('logger', () => {
75
45
  })
76
46
 
77
47
  describe('set_format', () => {
78
- it('set format to DEFAULT', () => {
79
- this.logger.format = ''
80
- this.logger.set_format('DEFAULT')
81
- assert.equal(this.logger.format, this.logger.formats.DEFAULT)
82
- })
83
-
84
- it('set format to LOGFMT', () => {
85
- this.logger.format = ''
86
- this.logger.set_format('LOGFMT')
87
- assert.equal(this.logger.format, this.logger.formats.LOGFMT)
88
- })
89
-
90
- it('set format to JSON', () => {
91
- this.logger.format = ''
92
- this.logger.set_format('JSON')
93
- assert.equal(this.logger.format, this.logger.formats.JSON)
94
- })
95
-
96
- it('set format to DEFAULT if empty', () => {
97
- this.logger.format = ''
98
- this.logger.set_format('')
99
- assert.equal(this.logger.format, this.logger.formats.DEFAULT)
100
- })
101
-
102
- it('set format to DEFAULT if lowercase', () => {
103
- this.logger.format = ''
104
- this.logger.set_format('default')
105
- assert.equal(this.logger.format, this.logger.formats.DEFAULT)
106
- })
107
-
108
- it('set format to DEFAULT if invalid', () => {
109
- this.logger.format = ''
110
- this.logger.set_format('invalid')
111
- assert.equal(this.logger.format, this.logger.formats.DEFAULT)
112
- })
48
+ // [input, expected format key]
49
+ const cases = [
50
+ ['DEFAULT', 'DEFAULT'],
51
+ ['LOGFMT', 'LOGFMT'],
52
+ ['JSON', 'JSON'],
53
+ ['', 'DEFAULT'], // empty → DEFAULT
54
+ ['default', 'DEFAULT'], // case-insensitive → DEFAULT
55
+ ['invalid', 'DEFAULT'], // unknown → DEFAULT
56
+ ]
57
+ for (const [input, expectedKey] of cases) {
58
+ it(`set_format(${JSON.stringify(input)}) → ${expectedKey}`, () => {
59
+ this.logger.format = ''
60
+ this.logger.set_format(input)
61
+ assert.equal(this.logger.format, this.logger.formats[expectedKey])
62
+ })
63
+ }
113
64
  })
114
65
 
115
66
  describe('set_loglevel', () => {
116
- it('set loglevel to LOGINFO', () => {
117
- this.logger.set_loglevel('LOGINFO')
118
- assert.equal(this.logger.loglevel, this.logger.levels.LOGINFO)
119
- })
120
-
121
- it('set loglevel to INFO', () => {
122
- this.logger.set_loglevel('INFO')
123
- assert.equal(this.logger.loglevel, this.logger.levels.INFO)
124
- })
125
-
126
- it('set loglevel to EMERG', () => {
127
- this.logger.set_loglevel('emerg')
128
- assert.equal(this.logger.loglevel, this.logger.levels.EMERG)
129
- })
130
-
131
- it('set loglevel to 6', () => {
132
- this.logger.set_loglevel(6)
133
- assert.equal(this.logger.loglevel, 6)
134
- })
135
-
136
- it('set loglevel to WARN if invalid', () => {
137
- this.logger.set_loglevel('invalid')
138
- assert.equal(this.logger.loglevel, this.logger.levels.WARN)
139
- })
67
+ // [input, expected level key or null for numeric assertion]
68
+ const cases = [
69
+ ['LOGINFO', 'LOGINFO'],
70
+ ['INFO', 'INFO'],
71
+ ['emerg', 'EMERG'], // case-insensitive
72
+ [6, null], // numeric passthrough
73
+ ['invalid', 'WARN'], // unknown → WARN
74
+ ]
75
+ for (const [input, expectedKey] of cases) {
76
+ it(`set_loglevel(${JSON.stringify(input)}) → ${expectedKey ?? input}`, () => {
77
+ this.logger.set_loglevel(input)
78
+ const expected = expectedKey ? this.logger.levels[expectedKey] : input
79
+ assert.equal(this.logger.loglevel, expected)
80
+ })
81
+ }
140
82
  })
141
83
 
142
84
  describe('set_timestamps', () => {
@@ -219,40 +161,38 @@ describe('logger', () => {
219
161
  })
220
162
 
221
163
  describe('log_if_level', () => {
222
- it('log_if_level is a function', () => {
223
- assert.ok('function' === typeof this.logger.log_if_level)
164
+ it('is a function', () => {
165
+ assert.equal(typeof this.logger.log_if_level, 'function')
224
166
  })
225
167
 
226
- it('log_if_level test log entry', () => {
168
+ it('returns a logging function', () => {
227
169
  this.logger.loglevel = 9
228
170
  const f = this.logger.log_if_level('INFO', 'LOGINFO')
229
- assert.ok(f)
230
- assert.ok('function' === typeof f)
231
- assert.ok(f('test info message'))
232
- assert.equal(1, this.logger.deferred_logs.length)
233
- // console.log(this.logger.deferred_logs[0]);
234
- assert.equal('INFO', this.logger.deferred_logs[0].level)
235
- })
236
-
237
- it('log_if_level null case', () => {
238
- this.logger.loglevel = 9
239
- const f = this.logger.log_if_level('INFO', 'LOGINFO')
240
- assert.ok(f(null))
241
- assert.equal(2, this.logger.deferred_logs.length)
242
- })
243
-
244
- it('log_if_level false', () => {
245
- this.logger.loglevel = 9
246
- const f = this.logger.log_if_level('INFO', 'LOGINFO')
247
- assert.ok(f(false))
248
- assert.equal(3, this.logger.deferred_logs.length)
249
- })
171
+ assert.equal(typeof f, 'function')
172
+ })
173
+
174
+ // Each of these runs independently with a fresh deferred_logs
175
+ for (const [label, msg] of [
176
+ ['string', 'test info message'],
177
+ ['null', null],
178
+ ['false', false],
179
+ ['0 (falsy number)', 0],
180
+ ]) {
181
+ it(`logs ${label} value and appends to deferred_logs`, () => {
182
+ this.logger.loglevel = 9
183
+ this.logger.deferred_logs = []
184
+ const f = this.logger.log_if_level('INFO', 'LOGINFO')
185
+ assert.ok(f(msg))
186
+ assert.equal(this.logger.deferred_logs.length, 1)
187
+ })
188
+ }
250
189
 
251
- it('log_if_level 0', () => {
190
+ it('records correct level in deferred log entry', () => {
252
191
  this.logger.loglevel = 9
192
+ this.logger.deferred_logs = []
253
193
  const f = this.logger.log_if_level('INFO', 'LOGINFO')
254
- assert.ok(f(0))
255
- assert.equal(4, this.logger.deferred_logs.length)
194
+ f('test info message')
195
+ assert.equal(this.logger.deferred_logs[0].level, 'INFO')
256
196
  })
257
197
  })
258
198
 
@@ -0,0 +1,132 @@
1
+ 'use strict'
2
+
3
+ // Testing bounce email contents related to errors occurring during SMTP dialog.
4
+ // Strategy: create an HMailItem via fixtures, invoke an outbound method, then
5
+ // verify that the correct bounce/temp_fail handler is called.
6
+
7
+ const { describe, it, beforeEach, afterEach } = require('node:test')
8
+ const assert = require('node:assert')
9
+ const dns = require('node:dns')
10
+ const fs = require('node:fs')
11
+ const path = require('node:path')
12
+
13
+ const constants = require('haraka-constants')
14
+
15
+ // Load outbound/index FIRST to avoid the circular-dependency boot-order issue:
16
+ // hmail.js → require('./index') while index.js is still loading causes queue.js
17
+ // to capture a stale (empty) module.exports for hmail.js.
18
+ const outbound = require('../../outbound')
19
+ const HMailItem = outbound.HMailItem
20
+ const TODOItem = require('../../outbound/todo')
21
+
22
+ const util_hmailitem = require('../fixtures/util_hmailitem')
23
+
24
+ const outbound_context = { TODOItem, exports: outbound }
25
+ const queue_dir = path.resolve(__dirname, '../test-queue')
26
+
27
+ // ── Helpers ───────────────────────────────────────────────────────────────────
28
+
29
+ const ensureQueueDir = () => fs.promises.mkdir(queue_dir, { recursive: true })
30
+
31
+ const cleanQueueDir = async () => {
32
+ if (!fs.existsSync(queue_dir)) return
33
+ for (const file of fs.readdirSync(queue_dir)) {
34
+ const full = path.resolve(queue_dir, file)
35
+ if (fs.lstatSync(full).isDirectory()) throw new Error(`unexpected subdirectory: ${full}`)
36
+ fs.unlinkSync(full)
37
+ }
38
+ }
39
+
40
+ /** Creates a mock HMailItem, resolving with it or rejecting on error. */
41
+ const mockHMailItem = (ctx, opts = {}) =>
42
+ new Promise((resolve, reject) => {
43
+ util_hmailitem.newMockHMailItem(ctx, reject, opts, resolve)
44
+ })
45
+
46
+ /**
47
+ * Intercepts `HMailItem.prototype[method]`, calls `assertion(this)` when invoked,
48
+ * then triggers the action under test via `trigger()`.
49
+ */
50
+ const interceptAndAssert = (method, assertion, trigger) =>
51
+ new Promise((resolve, reject) => {
52
+ const orig = HMailItem.prototype[method]
53
+ HMailItem.prototype[method] = function () {
54
+ try {
55
+ assertion(this)
56
+ resolve()
57
+ } catch (e) {
58
+ reject(e)
59
+ } finally {
60
+ HMailItem.prototype[method] = orig
61
+ }
62
+ }
63
+ trigger()
64
+ })
65
+
66
+ // ── Tests ─────────────────────────────────────────────────────────────────────
67
+
68
+ // [method, dsn_status, optional setup fn, trigger fn, test name]
69
+ const testCases = [
70
+ {
71
+ name: 'get_mx=DENY triggers bounce with dsn_status 5.1.2',
72
+ method: 'bounce',
73
+ status: '5.1.2',
74
+ setup: (h) => {
75
+ h.domain = h.todo.domain
76
+ },
77
+ trigger: (h) => HMailItem.prototype.get_mx_respond.apply(h, [constants.deny, {}]),
78
+ },
79
+ {
80
+ name: 'get_mx=DENYSOFT triggers temp_fail with dsn_status 4.1.2',
81
+ method: 'temp_fail',
82
+ status: '4.1.2',
83
+ setup: (h) => {
84
+ h.domain = h.todo.domain
85
+ },
86
+ trigger: (h) => HMailItem.prototype.get_mx_respond.apply(h, [constants.denysoft, {}]),
87
+ },
88
+ {
89
+ name: 'get_mx_error({code:NXDOMAIN}) triggers bounce with dsn_status 5.1.2',
90
+ method: 'bounce',
91
+ status: '5.1.2',
92
+ trigger: (h) => HMailItem.prototype.get_mx_error.apply(h, [{ code: dns.NXDOMAIN }]),
93
+ },
94
+ {
95
+ name: "get_mx_error({code:'SOME-OTHER-ERR'}) triggers temp_fail with dsn_status 4.1.0",
96
+ method: 'temp_fail',
97
+ status: '4.1.0',
98
+ trigger: (h) => HMailItem.prototype.get_mx_error.apply(h, [{ code: 'SOME-OTHER-ERR' }, {}]),
99
+ },
100
+ {
101
+ name: 'found_mx with empty exchange triggers bounce with dsn_status 5.1.2',
102
+ method: 'bounce',
103
+ status: '5.1.2',
104
+ trigger: (h) => HMailItem.prototype.found_mx.apply(h, [[{ priority: 0, exchange: '' }]]),
105
+ },
106
+ {
107
+ name: 'try_deliver with empty mxlist triggers temp_fail with dsn_status 5.1.2',
108
+ method: 'temp_fail',
109
+ status: '5.1.2',
110
+ setup: (h) => {
111
+ h.mxlist = []
112
+ },
113
+ trigger: (h) => HMailItem.prototype.try_deliver.apply(h, []),
114
+ },
115
+ ]
116
+
117
+ describe('outbound_bounce_net_errors', () => {
118
+ beforeEach(ensureQueueDir)
119
+ afterEach(cleanQueueDir)
120
+
121
+ for (const { name, method, status, setup, trigger } of testCases) {
122
+ it(name, async () => {
123
+ const mock_hmail = await mockHMailItem(outbound_context)
124
+ if (setup) setup(mock_hmail)
125
+ await interceptAndAssert(
126
+ method,
127
+ (h) => assert.equal(h.todo.rcpt_to[0].dsn_status, status, 'dsn_status'),
128
+ () => trigger(mock_hmail),
129
+ )
130
+ })
131
+ }
132
+ })