Haraka 3.1.5 → 3.1.7

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 (79) hide show
  1. package/.prettierignore +1 -1
  2. package/{Changes.md → CHANGELOG.md} +54 -3
  3. package/CONTRIBUTORS.md +26 -26
  4. package/Plugins.md +99 -99
  5. package/README.md +68 -93
  6. package/SECURITY.md +178 -0
  7. package/bin/haraka +7 -14
  8. package/config/plugins +0 -3
  9. package/config/smtp_forward.ini +10 -0
  10. package/config/smtp_proxy.ini +10 -0
  11. package/connection.js +25 -8
  12. package/docs/Connection.md +126 -39
  13. package/docs/CoreConfig.md +92 -74
  14. package/docs/HAProxy.md +41 -25
  15. package/docs/Logging.md +68 -38
  16. package/docs/Outbound.md +124 -179
  17. package/docs/Plugins.md +38 -59
  18. package/docs/Transaction.md +78 -83
  19. package/docs/Tutorial.md +122 -209
  20. package/docs/plugins/aliases.md +1 -141
  21. package/docs/plugins/auth/auth_ldap.md +2 -39
  22. package/docs/plugins/max_unrecognized_commands.md +4 -18
  23. package/docs/plugins/process_title.md +3 -3
  24. package/docs/plugins/queue/smtp_forward.md +19 -3
  25. package/docs/plugins/queue/smtp_proxy.md +10 -2
  26. package/docs/plugins/reseed_rng.md +11 -13
  27. package/docs/plugins/tls.md +7 -7
  28. package/docs/plugins/toobusy.md +10 -4
  29. package/docs/tutorials/SettingUpOutbound.md +40 -48
  30. package/endpoint.js +32 -2
  31. package/haraka.js +1 -1
  32. package/outbound/hmail.js +42 -41
  33. package/outbound/index.js +7 -4
  34. package/outbound/tls.js +2 -43
  35. package/package.json +51 -61
  36. package/plugins/auth/auth_base.js +9 -3
  37. package/plugins/auth/auth_proxy.js +14 -11
  38. package/plugins/block_me.js +4 -2
  39. package/plugins/prevent_credential_leaks.js +3 -1
  40. package/plugins/process_title.js +6 -6
  41. package/plugins/queue/qmail-queue.js +15 -19
  42. package/plugins/queue/smtp_forward.js +12 -4
  43. package/plugins/queue/smtp_proxy.js +14 -3
  44. package/plugins/tls.js +13 -5
  45. package/plugins/xclient.js +3 -1
  46. package/server.js +22 -10
  47. package/smtp_client.js +20 -11
  48. package/test/config/block_me.recipient +1 -0
  49. package/test/config/block_me.senders +1 -0
  50. package/test/connection.js +258 -0
  51. package/test/endpoint.js +27 -0
  52. package/test/outbound/bounce_net_errors.js +3 -2
  53. package/test/outbound/hmail.js +19 -0
  54. package/test/outbound/index.js +189 -0
  55. package/test/outbound/queue.js +92 -0
  56. package/test/plugins/auth/auth_bridge.js +80 -0
  57. package/test/plugins/auth/flat_file.js +128 -0
  58. package/test/plugins/block_me.js +157 -0
  59. package/test/plugins/data.signatures.js +114 -0
  60. package/test/plugins/delay_deny.js +263 -0
  61. package/test/plugins/prevent_credential_leaks.js +178 -0
  62. package/test/plugins/process_title.js +135 -0
  63. package/test/plugins/queue/deliver.js +99 -0
  64. package/test/plugins/queue/discard.js +79 -0
  65. package/test/plugins/queue/lmtp.js +138 -0
  66. package/test/plugins/queue/qmail-queue.js +99 -0
  67. package/test/plugins/queue/quarantine.js +81 -0
  68. package/test/plugins/queue/smtp_bridge.js +154 -0
  69. package/test/plugins/queue/smtp_forward.js +42 -6
  70. package/test/plugins/queue/smtp_proxy.js +139 -0
  71. package/test/plugins/reseed_rng.js +34 -0
  72. package/test/plugins/tarpit.js +91 -0
  73. package/test/plugins/tls.js +25 -0
  74. package/test/plugins/toobusy.js +21 -0
  75. package/test/plugins/xclient.js +14 -0
  76. package/test/server.js +231 -0
  77. package/test/smtp_client.js +45 -12
  78. package/test/tls_socket.js +220 -0
  79. package/tls_socket.js +52 -2
@@ -0,0 +1,79 @@
1
+ 'use strict'
2
+
3
+ const assert = require('node:assert')
4
+ const { describe, it, beforeEach, before } = require('node:test')
5
+
6
+ const fixtures = require('haraka-test-fixtures')
7
+
8
+ before(() => {
9
+ require('haraka-constants').import(global)
10
+ })
11
+
12
+ describe('queue/discard', () => {
13
+ describe('discard hook', () => {
14
+ let plugin, conn
15
+
16
+ beforeEach(() => {
17
+ plugin = new fixtures.plugin('queue/discard')
18
+ conn = fixtures.connection.createConnection()
19
+ conn.init_transaction()
20
+ delete process.env.YES_REALLY_DO_DISCARD
21
+ })
22
+
23
+ it('calls next() when queue.wants is set to another plugin', (t, done) => {
24
+ conn.transaction.notes.set('queue.wants', 'smtp_forward')
25
+ plugin.discard((rc) => {
26
+ assert.equal(rc, undefined)
27
+ done()
28
+ }, conn)
29
+ })
30
+
31
+ it('calls next(OK) when connection.notes.discard is set', (t, done) => {
32
+ conn.notes.discard = true
33
+ plugin.discard((rc) => {
34
+ assert.equal(rc, OK)
35
+ done()
36
+ }, conn)
37
+ })
38
+
39
+ it('calls next(OK) when txn.notes.discard is set', (t, done) => {
40
+ conn.transaction.notes.discard = true
41
+ plugin.discard((rc) => {
42
+ assert.equal(rc, OK)
43
+ done()
44
+ }, conn)
45
+ })
46
+
47
+ it('calls next(OK) when queue.wants is discard', (t, done) => {
48
+ conn.transaction.notes.set('queue.wants', 'discard')
49
+ plugin.discard((rc) => {
50
+ assert.equal(rc, OK)
51
+ done()
52
+ }, conn)
53
+ })
54
+
55
+ it('calls next(OK) when YES_REALLY_DO_DISCARD env var is set', (t, done) => {
56
+ process.env.YES_REALLY_DO_DISCARD = '1'
57
+ plugin.discard((rc) => {
58
+ assert.equal(rc, OK)
59
+ done()
60
+ }, conn)
61
+ })
62
+
63
+ it('calls next() (pass-through) when no discard conditions are met', (t, done) => {
64
+ plugin.discard((rc) => {
65
+ assert.equal(rc, undefined)
66
+ done()
67
+ }, conn)
68
+ })
69
+
70
+ it('queue.wants=discard takes priority over other queue wants', (t, done) => {
71
+ // Once queue.wants is set, it's compared against 'discard'; since it equals 'discard', discard runs
72
+ conn.transaction.notes.set('queue.wants', 'discard')
73
+ plugin.discard((rc) => {
74
+ assert.equal(rc, OK)
75
+ done()
76
+ }, conn)
77
+ })
78
+ })
79
+ })
@@ -0,0 +1,138 @@
1
+ 'use strict'
2
+
3
+ const assert = require('node:assert')
4
+ const { describe, it, beforeEach, before } = require('node:test')
5
+
6
+ const fixtures = require('haraka-test-fixtures')
7
+
8
+ before(() => {
9
+ require('haraka-constants').import(global)
10
+ })
11
+
12
+ describe('queue/lmtp', () => {
13
+ describe('hook_get_mx', () => {
14
+ let plugin
15
+
16
+ beforeEach(() => {
17
+ plugin = new fixtures.plugin('queue/lmtp')
18
+ plugin.load_lmtp_ini()
19
+ })
20
+
21
+ it('calls next() when hmail does not have using_lmtp note', (t, done) => {
22
+ const hmail = { todo: { notes: {} } }
23
+ plugin.hook_get_mx(
24
+ (rc, mx) => {
25
+ assert.equal(rc, undefined)
26
+ assert.equal(mx, undefined)
27
+ done()
28
+ },
29
+ hmail,
30
+ 'example.com',
31
+ )
32
+ })
33
+
34
+ it('returns OK with default host and port when using_lmtp is set', (t, done) => {
35
+ const hmail = { todo: { notes: { using_lmtp: true } } }
36
+ plugin.cfg = { main: {} }
37
+ plugin.hook_get_mx(
38
+ (rc, mx) => {
39
+ assert.equal(rc, OK)
40
+ assert.equal(mx.using_lmtp, true)
41
+ assert.equal(mx.exchange, '127.0.0.1')
42
+ assert.equal(mx.port, 24)
43
+ assert.equal(mx.priority, 0)
44
+ done()
45
+ },
46
+ hmail,
47
+ 'example.com',
48
+ )
49
+ })
50
+
51
+ it('uses domain-specific section when available', (t, done) => {
52
+ const hmail = { todo: { notes: { using_lmtp: true } } }
53
+ plugin.cfg = {
54
+ main: { host: '127.0.0.1' },
55
+ 'example.com': { host: 'lmtp.example.com', port: 2400 },
56
+ }
57
+ plugin.hook_get_mx(
58
+ (rc, mx) => {
59
+ assert.equal(rc, OK)
60
+ assert.equal(mx.exchange, 'lmtp.example.com')
61
+ assert.equal(mx.port, 2400)
62
+ done()
63
+ },
64
+ hmail,
65
+ 'example.com',
66
+ )
67
+ })
68
+
69
+ it('falls back to main section when no domain-specific section', (t, done) => {
70
+ const hmail = { todo: { notes: { using_lmtp: true } } }
71
+ plugin.cfg = { main: { host: 'lmtp.default.com', port: 24 } }
72
+ plugin.hook_get_mx(
73
+ (rc, mx) => {
74
+ assert.equal(rc, OK)
75
+ assert.equal(mx.exchange, 'lmtp.default.com')
76
+ done()
77
+ },
78
+ hmail,
79
+ 'other.com',
80
+ )
81
+ })
82
+
83
+ it('includes path in mx when configured', (t, done) => {
84
+ const hmail = { todo: { notes: { using_lmtp: true } } }
85
+ plugin.cfg = { main: { host: '127.0.0.1', path: '/var/run/lmtp.sock' } }
86
+ plugin.hook_get_mx(
87
+ (rc, mx) => {
88
+ assert.equal(rc, OK)
89
+ assert.equal(mx.path, '/var/run/lmtp.sock')
90
+ done()
91
+ },
92
+ hmail,
93
+ 'example.com',
94
+ )
95
+ })
96
+
97
+ it('does not include path in mx when not configured', (t, done) => {
98
+ const hmail = { todo: { notes: { using_lmtp: true } } }
99
+ plugin.cfg = { main: {} }
100
+ plugin.hook_get_mx(
101
+ (rc, mx) => {
102
+ assert.equal(rc, OK)
103
+ assert.equal(mx.path, undefined)
104
+ done()
105
+ },
106
+ hmail,
107
+ 'example.com',
108
+ )
109
+ })
110
+ })
111
+
112
+ describe('hook_queue', () => {
113
+ let plugin, conn
114
+
115
+ beforeEach(() => {
116
+ plugin = new fixtures.plugin('queue/lmtp')
117
+ plugin.load_lmtp_ini()
118
+ conn = fixtures.connection.createConnection()
119
+ conn.init_transaction()
120
+ })
121
+
122
+ it('calls next() when there is no transaction', (t, done) => {
123
+ const connNoTxn = fixtures.connection.createConnection()
124
+ plugin.hook_queue((rc) => {
125
+ assert.equal(rc, undefined)
126
+ done()
127
+ }, connNoTxn)
128
+ })
129
+
130
+ it('calls next() when queue.wants is set to another plugin', (t, done) => {
131
+ conn.transaction.notes.set('queue.wants', 'smtp_forward')
132
+ plugin.hook_queue((rc) => {
133
+ assert.equal(rc, undefined)
134
+ done()
135
+ }, conn)
136
+ })
137
+ })
138
+ })
@@ -0,0 +1,99 @@
1
+ 'use strict'
2
+
3
+ const assert = require('node:assert')
4
+ const { describe, it, beforeEach, before } = require('node:test')
5
+
6
+ const fixtures = require('haraka-test-fixtures')
7
+
8
+ before(() => {
9
+ require('haraka-constants').import(global)
10
+ })
11
+
12
+ describe('queue/qmail-queue', () => {
13
+ describe('register', () => {
14
+ it('throws when qmail-queue binary is not found', () => {
15
+ const plugin = new fixtures.plugin('queue/qmail-queue')
16
+ assert.throws(() => plugin.register(), /Cannot find qmail-queue binary/)
17
+ })
18
+ })
19
+
20
+ describe('load_qmail_queue_ini', () => {
21
+ it('loads config with enable_outbound boolean', () => {
22
+ const plugin = new fixtures.plugin('queue/qmail-queue')
23
+ plugin.load_qmail_queue_ini()
24
+ assert.ok(typeof plugin.cfg.main.enable_outbound === 'boolean')
25
+ })
26
+ })
27
+
28
+ describe('hook_queue', () => {
29
+ let plugin, conn
30
+
31
+ beforeEach(() => {
32
+ plugin = new fixtures.plugin('queue/qmail-queue')
33
+ plugin.load_qmail_queue_ini()
34
+ plugin.queue_exec = '/bin/echo' // use a real binary that exists
35
+ conn = fixtures.connection.createConnection()
36
+ conn.init_transaction()
37
+ })
38
+
39
+ it('calls next() when there is no transaction', (t, done) => {
40
+ const connNoTxn = fixtures.connection.createConnection()
41
+ plugin.hook_queue((rc) => {
42
+ assert.equal(rc, undefined)
43
+ done()
44
+ }, connNoTxn)
45
+ })
46
+
47
+ it('calls next() when queue.wants is set to another plugin', (t, done) => {
48
+ conn.transaction.notes.set('queue.wants', 'smtp_forward')
49
+ plugin.hook_queue((rc) => {
50
+ assert.equal(rc, undefined)
51
+ done()
52
+ }, conn)
53
+ })
54
+
55
+ it('calls next() when queue.wants is set to discard', (t, done) => {
56
+ conn.transaction.notes.set('queue.wants', 'discard')
57
+ plugin.hook_queue((rc) => {
58
+ assert.equal(rc, undefined)
59
+ done()
60
+ }, conn)
61
+ })
62
+ })
63
+
64
+ describe('build_envelope', () => {
65
+ let plugin
66
+ beforeEach(() => {
67
+ plugin = new fixtures.plugin('queue/qmail-queue')
68
+ })
69
+
70
+ it('formats F<sender>\\0(T<rcpt>\\0)*\\0 with no padding', () => {
71
+ const buf = plugin.build_envelope({
72
+ mail_from: { address: 'snd@example.com' },
73
+ rcpt_to: [{ address: 'a@example.com' }, { address: 'b@example.com' }],
74
+ })
75
+ assert.deepEqual(buf, Buffer.from('Fsnd@example.com\x00Ta@example.com\x00Tb@example.com\x00\x00', 'utf8'))
76
+ })
77
+
78
+ it('is not truncated for large recipient sets', () => {
79
+ const rcpt_to = []
80
+ for (let i = 0; i < 500; i++) {
81
+ rcpt_to.push({ address: `recipient-with-a-fairly-long-localpart-${i}@example.com` })
82
+ }
83
+ const buf = plugin.build_envelope({ mail_from: { address: 'snd@example.com' }, rcpt_to })
84
+ assert.equal((buf.toString('utf8').match(/T/g) || []).length, 500)
85
+ assert.ok(buf.length > 4096, 'exceeds the old fixed 4096-byte cap')
86
+ assert.ok(buf.toString('utf8').includes('recipient-with-a-fairly-long-localpart-499@example.com'))
87
+ assert.equal(buf[buf.length - 1], 0)
88
+ })
89
+
90
+ it('encodes non-ASCII (SMTPUTF8) addresses correctly', () => {
91
+ const buf = plugin.build_envelope({
92
+ mail_from: { address: 'sénder@exämple.com' },
93
+ rcpt_to: [{ address: 'reçìpient@exämple.com' }],
94
+ })
95
+ assert.ok(buf.includes(Buffer.from('sénder@exämple.com', 'utf8')))
96
+ assert.ok(buf.includes(Buffer.from('reçìpient@exämple.com', 'utf8')))
97
+ })
98
+ })
99
+ })
@@ -0,0 +1,81 @@
1
+ 'use strict'
2
+
3
+ const assert = require('node:assert')
4
+ const { describe, it, beforeEach } = require('node:test')
5
+
6
+ const fixtures = require('haraka-test-fixtures')
7
+
8
+ describe('queue/quarantine', () => {
9
+ let plugin
10
+
11
+ beforeEach(() => {
12
+ plugin = new fixtures.plugin('queue/quarantine')
13
+ plugin.load_quarantine_ini()
14
+ })
15
+
16
+ describe('zeroPad', () => {
17
+ it('pads a single digit number to 2 digits', () => {
18
+ assert.equal(plugin.zeroPad(5, 2), '05')
19
+ })
20
+
21
+ it('pads a single digit to 4 digits', () => {
22
+ assert.equal(plugin.zeroPad(7, 4), '0007')
23
+ })
24
+
25
+ it('does not pad when already at target length', () => {
26
+ assert.equal(plugin.zeroPad(12, 2), '12')
27
+ })
28
+
29
+ it('does not pad when number exceeds target length', () => {
30
+ assert.equal(plugin.zeroPad(2025, 2), '2025')
31
+ })
32
+
33
+ it('handles 0 correctly', () => {
34
+ assert.equal(plugin.zeroPad(0, 2), '00')
35
+ })
36
+ })
37
+
38
+ describe('get_base_dir', () => {
39
+ it('returns default quarantine path when not configured', () => {
40
+ plugin.cfg = { main: {} }
41
+ assert.equal(plugin.get_base_dir(), '/var/spool/haraka/quarantine')
42
+ })
43
+
44
+ it('returns configured quarantine_path when set', () => {
45
+ plugin.cfg = { main: { quarantine_path: '/tmp/my-quarantine' } }
46
+ assert.equal(plugin.get_base_dir(), '/tmp/my-quarantine')
47
+ })
48
+ })
49
+
50
+ describe('quarantine hook', () => {
51
+ let conn
52
+
53
+ beforeEach(() => {
54
+ conn = fixtures.connection.createConnection()
55
+ conn.init_transaction()
56
+ })
57
+
58
+ it('calls next() when no quarantine conditions are met', (t, done) => {
59
+ plugin.quarantine((rc) => {
60
+ assert.equal(rc, undefined)
61
+ done()
62
+ }, conn)
63
+ })
64
+
65
+ it('calls next() when connection.notes.quarantine is falsy', (t, done) => {
66
+ conn.notes.quarantine = false
67
+ plugin.quarantine((rc) => {
68
+ assert.equal(rc, undefined)
69
+ done()
70
+ }, conn)
71
+ })
72
+
73
+ it('calls next() when queue.wants is set to something other than quarantine', (t, done) => {
74
+ conn.transaction.notes.set('queue.wants', 'smtp_forward')
75
+ plugin.quarantine((rc) => {
76
+ assert.equal(rc, undefined)
77
+ done()
78
+ }, conn)
79
+ })
80
+ })
81
+ })
@@ -0,0 +1,154 @@
1
+ 'use strict'
2
+
3
+ const assert = require('node:assert')
4
+ const { describe, it, beforeEach, before } = require('node:test')
5
+
6
+ const fixtures = require('haraka-test-fixtures')
7
+
8
+ before(() => {
9
+ require('haraka-constants').import(global)
10
+ })
11
+
12
+ describe('queue/smtp_bridge', () => {
13
+ describe('hook_data_post', () => {
14
+ let plugin, conn
15
+
16
+ beforeEach(() => {
17
+ plugin = new fixtures.plugin('queue/smtp_bridge')
18
+ plugin.load_flat_ini()
19
+ conn = fixtures.connection.createConnection()
20
+ conn.init_transaction()
21
+ })
22
+
23
+ it('calls next() when no transaction', (t, done) => {
24
+ const connNoTxn = fixtures.connection.createConnection()
25
+ plugin.hook_data_post((rc) => {
26
+ assert.equal(rc, undefined)
27
+ done()
28
+ }, connNoTxn)
29
+ })
30
+
31
+ it('copies auth_user from connection notes to transaction notes', (t, done) => {
32
+ conn.notes.auth_user = 'alice'
33
+ conn.notes.auth_passwd = 'secret'
34
+ plugin.hook_data_post((rc) => {
35
+ assert.equal(rc, undefined)
36
+ assert.equal(conn.transaction.notes.auth_user, 'alice')
37
+ done()
38
+ }, conn)
39
+ })
40
+
41
+ it('copies auth_passwd from connection notes to transaction notes', (t, done) => {
42
+ conn.notes.auth_user = 'bob'
43
+ conn.notes.auth_passwd = 'mypassword'
44
+ plugin.hook_data_post(() => {
45
+ assert.equal(conn.transaction.notes.auth_passwd, 'mypassword')
46
+ done()
47
+ }, conn)
48
+ })
49
+
50
+ it('copies undefined auth values when not set on connection', (t, done) => {
51
+ plugin.hook_data_post(() => {
52
+ assert.equal(conn.transaction.notes.auth_user, undefined)
53
+ assert.equal(conn.transaction.notes.auth_passwd, undefined)
54
+ done()
55
+ }, conn)
56
+ })
57
+ })
58
+
59
+ describe('hook_get_mx', () => {
60
+ let plugin
61
+
62
+ beforeEach(() => {
63
+ plugin = new fixtures.plugin('queue/smtp_bridge')
64
+ plugin.load_flat_ini()
65
+ })
66
+
67
+ it('returns OK with default priority 10 and configured host', (t, done) => {
68
+ plugin.cfg.main = { host: 'relay.example.com' }
69
+ const hmail = { todo: { notes: {} } }
70
+ plugin.hook_get_mx(
71
+ (rc, mx) => {
72
+ assert.equal(rc, OK)
73
+ assert.equal(mx.priority, 10)
74
+ assert.equal(mx.exchange, 'relay.example.com')
75
+ done()
76
+ },
77
+ hmail,
78
+ 'example.com',
79
+ )
80
+ })
81
+
82
+ it('uses configured priority when set', (t, done) => {
83
+ plugin.cfg.main = { host: 'relay.example.com', priority: 20 }
84
+ const hmail = { todo: { notes: {} } }
85
+ plugin.hook_get_mx(
86
+ (rc, mx) => {
87
+ assert.equal(rc, OK)
88
+ assert.equal(mx.priority, 20)
89
+ done()
90
+ },
91
+ hmail,
92
+ 'example.com',
93
+ )
94
+ })
95
+
96
+ it('passes auth_type from config', (t, done) => {
97
+ plugin.cfg.main = { host: 'relay.example.com', auth_type: 'PLAIN' }
98
+ const hmail = { todo: { notes: {} } }
99
+ plugin.hook_get_mx(
100
+ (rc, mx) => {
101
+ assert.equal(rc, OK)
102
+ assert.equal(mx.auth_type, 'PLAIN')
103
+ done()
104
+ },
105
+ hmail,
106
+ 'example.com',
107
+ )
108
+ })
109
+
110
+ it('passes port from config', (t, done) => {
111
+ plugin.cfg.main = { host: 'relay.example.com', port: '587' }
112
+ const hmail = { todo: { notes: {} } }
113
+ plugin.hook_get_mx(
114
+ (rc, mx) => {
115
+ assert.equal(rc, OK)
116
+ assert.equal(mx.port, '587')
117
+ done()
118
+ },
119
+ hmail,
120
+ 'example.com',
121
+ )
122
+ })
123
+
124
+ it('passes auth_user and auth_pass from hmail notes', (t, done) => {
125
+ plugin.cfg.main = { host: 'relay.example.com' }
126
+ const hmail = { todo: { notes: { auth_user: 'alice', auth_passwd: 'secret' } } }
127
+ plugin.hook_get_mx(
128
+ (rc, mx) => {
129
+ assert.equal(rc, OK)
130
+ assert.equal(mx.auth_user, 'alice')
131
+ assert.equal(mx.auth_pass, 'secret')
132
+ done()
133
+ },
134
+ hmail,
135
+ 'example.com',
136
+ )
137
+ })
138
+
139
+ it('sets port null and auth_type null when not configured', (t, done) => {
140
+ plugin.cfg.main = { host: 'relay.example.com' }
141
+ const hmail = { todo: { notes: {} } }
142
+ plugin.hook_get_mx(
143
+ (rc, mx) => {
144
+ assert.equal(rc, OK)
145
+ assert.equal(mx.port, null)
146
+ assert.equal(mx.auth_type, null)
147
+ done()
148
+ },
149
+ hmail,
150
+ 'example.com',
151
+ )
152
+ })
153
+ })
154
+ })
@@ -42,7 +42,7 @@ function makeHmail(notes = {}) {
42
42
  class MockSMTPClient extends EventEmitter {
43
43
  constructor() {
44
44
  super()
45
- this.smtp_utf8 = false
45
+ this.smtputf8 = false
46
46
  this.response = ['250 OK']
47
47
  this.next = null
48
48
  this.commands = []
@@ -140,11 +140,47 @@ describe('smtp_forward register', () => {
140
140
  assert.equal(plugin.hooks.queue, undefined)
141
141
  })
142
142
 
143
- it('TLS enabled but no outbound config in tls.ini', () => {
144
- const plugin = new fixtures.plugin('queue/smtp_forward')
145
- plugin.register()
146
- assert.equal(plugin.tls_options, undefined)
147
- assert.ok(Object.keys(plugin.hooks).length)
143
+ it('populates tls_options after register (no-op shape)', () => {
144
+ const plugin = makePlugin()
145
+ assert.ok(plugin.tls_options, 'tls_options should be populated after register')
146
+ assert.ok(Array.isArray(plugin.tls_options.no_tls_hosts))
147
+ assert.ok(Array.isArray(plugin.tls_options.force_tls_hosts))
148
+ })
149
+ })
150
+
151
+ // ─── tls_options ─────────────────────────────────────────────────────────────
152
+
153
+ describe('smtp_forward tls_options', () => {
154
+ const tls_socket = require('../../../tls_socket')
155
+ let origTlsConfig, origTlsCfg
156
+
157
+ beforeEach(() => {
158
+ // Redirect tls_socket.config at test/config so tls.ini fixtures load.
159
+ origTlsConfig = tls_socket.config
160
+ origTlsCfg = tls_socket.cfg
161
+ tls_socket.config = require('haraka-config').module_config(path.resolve('test'))
162
+ tls_socket.cfg = undefined
163
+ })
164
+
165
+ afterEach(() => {
166
+ tls_socket.config = origTlsConfig
167
+ tls_socket.cfg = origTlsCfg
168
+ })
169
+
170
+ it('inherits rejectUnauthorized/minVersion/ciphers from tls.ini [main]', () => {
171
+ const plugin = makePlugin()
172
+ assert.equal(plugin.tls_options.rejectUnauthorized, false)
173
+ assert.equal(plugin.tls_options.minVersion, 'TLSv1')
174
+ assert.ok(plugin.tls_options.ciphers)
175
+ })
176
+
177
+ it('reload re-derives tls_options', () => {
178
+ const plugin = makePlugin()
179
+ const first = plugin.tls_options
180
+ plugin.load_smtp_forward_ini()
181
+ assert.ok(plugin.tls_options)
182
+ assert.notEqual(plugin.tls_options, first, 'reload returns a fresh object')
183
+ assert.equal(plugin.tls_options.rejectUnauthorized, false)
148
184
  })
149
185
  })
150
186