Haraka 3.1.4 → 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.
- package/CONTRIBUTORS.md +1 -1
- package/Changes.md +14 -0
- package/package.json +8 -10
- package/plugins/queue/smtp_forward.js +4 -4
- package/run_tests +3 -15
- package/smtp_client.js +8 -6
- package/test/endpoint.js +5 -4
- package/test/host_pool.js +57 -31
- package/test/logger.js +75 -135
- package/test/outbound/bounce_net_errors.js +87 -131
- package/test/outbound/bounce_rfc3464.js +177 -254
- package/test/plugins/auth/auth_base.js +39 -44
- package/test/plugins/auth/auth_vpopmaild.js +8 -9
- package/test/plugins/queue/smtp_forward.js +953 -183
- package/test/plugins/rcpt_to.host_list_base.js +58 -93
- package/test/plugins/rcpt_to.in_host_list.js +126 -175
- package/test/plugins/record_envelope_addresses.js +8 -8
- package/test/plugins/status.js +10 -10
- package/test/plugins/tls.js +9 -19
- package/test/plugins/xclient.js +75 -110
- package/test/plugins.js +10 -13
- package/test/rfc1869.js +50 -70
- package/test/server.js +281 -436
- package/test/smtp_client.js +1192 -218
- package/test/tls_socket.js +104 -0
- package/tls_socket.js +16 -20
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const assert = require('node:assert')
|
|
2
|
+
const assert = require('node:assert/strict')
|
|
3
|
+
const { describe, it, beforeEach } = require('node:test')
|
|
3
4
|
|
|
4
5
|
const { Address } = require('address-rfc2821')
|
|
5
6
|
const fixtures = require('haraka-test-fixtures')
|
|
6
7
|
|
|
7
|
-
const _set_up = (
|
|
8
|
+
const _set_up = () => {
|
|
8
9
|
this.plugin = new fixtures.plugin('rcpt_to.host_list_base')
|
|
9
10
|
this.plugin.cfg = {}
|
|
10
11
|
this.plugin.host_list = {}
|
|
11
12
|
|
|
12
13
|
this.connection = fixtures.connection.createConnection()
|
|
13
14
|
this.connection.init_transaction()
|
|
14
|
-
|
|
15
|
-
done()
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
describe('rcpt_to.host_list_base', () => {
|
|
@@ -32,109 +31,75 @@ describe('rcpt_to.host_list_base', () => {
|
|
|
32
31
|
describe('in_host_regex', () => {
|
|
33
32
|
beforeEach(_set_up)
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
it('miss', () => {
|
|
41
|
-
this.plugin.host_list_regex = ['miss.com']
|
|
42
|
-
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
43
|
-
const r = this.plugin.in_host_regex('test.com')
|
|
44
|
-
assert.equal(false, r)
|
|
45
|
-
})
|
|
34
|
+
const setRegex = (patterns) => {
|
|
35
|
+
this.plugin.host_list_regex = patterns
|
|
36
|
+
this.plugin.hl_re = new RegExp(`^(?:${patterns.join('|')})$`, 'i')
|
|
37
|
+
}
|
|
46
38
|
|
|
47
|
-
it('
|
|
48
|
-
this.plugin.
|
|
49
|
-
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
50
|
-
const r = this.plugin.in_host_regex('test.com')
|
|
51
|
-
assert.equal(true, r)
|
|
39
|
+
it('returns false when hl_re is not set', () => {
|
|
40
|
+
assert.equal(this.plugin.in_host_regex('test.com'), false)
|
|
52
41
|
})
|
|
53
42
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
43
|
+
const cases = [
|
|
44
|
+
{ desc: 'miss', patterns: ['miss.com'], domain: 'test.com', expected: false },
|
|
45
|
+
{ desc: 'exact hit', patterns: ['test.com'], domain: 'test.com', expected: true },
|
|
46
|
+
{ desc: 're hit', patterns: ['.*est.com'], domain: 'test.com', expected: true },
|
|
47
|
+
]
|
|
48
|
+
for (const { desc, patterns, domain, expected } of cases) {
|
|
49
|
+
it(desc, () => {
|
|
50
|
+
setRegex(patterns)
|
|
51
|
+
assert.equal(this.plugin.in_host_regex(domain), expected)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
60
54
|
})
|
|
61
55
|
|
|
62
56
|
describe('hook_mail', () => {
|
|
63
57
|
beforeEach(_set_up)
|
|
64
58
|
|
|
65
|
-
|
|
66
|
-
this.
|
|
67
|
-
this.plugin.
|
|
68
|
-
|
|
69
|
-
assert.equal(undefined, rc)
|
|
70
|
-
assert.equal(undefined, msg)
|
|
71
|
-
done()
|
|
72
|
-
},
|
|
73
|
-
this.connection,
|
|
74
|
-
[new Address('<>')],
|
|
75
|
-
)
|
|
76
|
-
})
|
|
59
|
+
const setRegex = (patterns) => {
|
|
60
|
+
this.plugin.host_list_regex = patterns
|
|
61
|
+
this.plugin.hl_re = new RegExp(`^(?:${patterns.join('|')})$`, 'i')
|
|
62
|
+
}
|
|
77
63
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
assert.equal(undefined, rc)
|
|
83
|
-
assert.equal(undefined, msg)
|
|
84
|
-
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
85
|
-
assert.notEqual(-1, res.msg.indexOf('mail_from!local'))
|
|
86
|
-
done()
|
|
87
|
-
},
|
|
88
|
-
this.connection,
|
|
89
|
-
[new Address('<user@example.com>')],
|
|
90
|
-
)
|
|
91
|
-
})
|
|
64
|
+
const callMailHook = (addr) =>
|
|
65
|
+
new Promise((resolve) => {
|
|
66
|
+
this.plugin.hook_mail((rc, msg) => resolve({ rc, msg }), this.connection, [new Address(addr)])
|
|
67
|
+
})
|
|
92
68
|
|
|
93
|
-
it('
|
|
94
|
-
this.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
assert.equal(undefined, msg)
|
|
99
|
-
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
100
|
-
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
101
|
-
done()
|
|
102
|
-
},
|
|
103
|
-
this.connection,
|
|
104
|
-
[new Address('<user@example.com>')],
|
|
105
|
-
)
|
|
69
|
+
it('null sender always passes when relaying', async () => {
|
|
70
|
+
this.connection.relaying = true
|
|
71
|
+
const { rc, msg } = await callMailHook('<>')
|
|
72
|
+
assert.equal(rc, undefined)
|
|
73
|
+
assert.equal(msg, undefined)
|
|
106
74
|
})
|
|
107
75
|
|
|
108
|
-
it('
|
|
109
|
-
this.plugin.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
116
|
-
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
117
|
-
done()
|
|
118
|
-
},
|
|
119
|
-
this.connection,
|
|
120
|
-
[new Address('<user@example.com>')],
|
|
121
|
-
)
|
|
76
|
+
it('miss: records mail_from!local in results', async () => {
|
|
77
|
+
this.plugin.host_list = { 'miss.com': true }
|
|
78
|
+
const { rc, msg } = await callMailHook('<user@example.com>')
|
|
79
|
+
assert.equal(rc, undefined)
|
|
80
|
+
assert.equal(msg, undefined)
|
|
81
|
+
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
82
|
+
assert.ok(res.msg.includes('mail_from!local'))
|
|
122
83
|
})
|
|
123
84
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
assert.equal(undefined, rc)
|
|
130
|
-
assert.equal(undefined, msg)
|
|
131
|
-
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
132
|
-
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
133
|
-
done()
|
|
85
|
+
for (const [desc, setup] of [
|
|
86
|
+
[
|
|
87
|
+
'hit',
|
|
88
|
+
() => {
|
|
89
|
+
this.plugin.host_list = { 'example.com': true }
|
|
134
90
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
)
|
|
138
|
-
|
|
91
|
+
],
|
|
92
|
+
['hit, regex, exact', () => setRegex(['example.com'])],
|
|
93
|
+
['hit, regex, pattern', () => setRegex(['.*mple.com'])],
|
|
94
|
+
]) {
|
|
95
|
+
it(desc, async () => {
|
|
96
|
+
setup()
|
|
97
|
+
const { rc, msg } = await callMailHook('<user@example.com>')
|
|
98
|
+
assert.equal(rc, undefined)
|
|
99
|
+
assert.equal(msg, undefined)
|
|
100
|
+
const res = this.connection.transaction.results.get('rcpt_to.host_list_base')
|
|
101
|
+
assert.ok(res.pass.includes('mail_from'))
|
|
102
|
+
})
|
|
103
|
+
}
|
|
139
104
|
})
|
|
140
105
|
})
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const assert = require('node:assert')
|
|
2
|
+
const assert = require('node:assert/strict')
|
|
3
|
+
const { describe, it, beforeEach } = require('node:test')
|
|
3
4
|
|
|
4
5
|
const { Address } = require('address-rfc2821')
|
|
5
6
|
const fixtures = require('haraka-test-fixtures')
|
|
7
|
+
require('haraka-constants').import(global)
|
|
6
8
|
|
|
7
|
-
const _set_up = (
|
|
9
|
+
const _set_up = () => {
|
|
8
10
|
this.plugin = new fixtures.plugin('rcpt_to.in_host_list')
|
|
9
11
|
this.plugin.inherits('rcpt_to.host_list_base')
|
|
10
12
|
this.plugin.cfg = {}
|
|
@@ -15,8 +17,6 @@ const _set_up = (done) => {
|
|
|
15
17
|
results: new fixtures.results(this.connection),
|
|
16
18
|
notes: {},
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
done()
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
describe('in_host_list', () => {
|
|
@@ -34,207 +34,158 @@ describe('in_host_list', () => {
|
|
|
34
34
|
describe('in_host_regex', () => {
|
|
35
35
|
beforeEach(_set_up)
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const setRegex = (patterns) => {
|
|
38
|
+
this.plugin.host_list_regex = patterns
|
|
39
|
+
this.plugin.hl_re = new RegExp(`^(?:${patterns.join('|')})$`, 'i')
|
|
40
|
+
}
|
|
40
41
|
|
|
41
|
-
it('
|
|
42
|
-
this.plugin.host_list_regex = ['miss.com']
|
|
43
|
-
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
42
|
+
it('returns false when hl_re is not set', () => {
|
|
44
43
|
assert.equal(this.plugin.in_host_regex('test.com'), false)
|
|
45
44
|
})
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
46
|
+
const cases = [
|
|
47
|
+
{ desc: 'miss', patterns: ['miss.com'], domain: 'test.com', expected: false },
|
|
48
|
+
{ desc: 'exact hit', patterns: ['test.com'], domain: 'test.com', expected: true },
|
|
49
|
+
{ desc: 're hit', patterns: ['.*est.com'], domain: 'test.com', expected: true },
|
|
50
|
+
]
|
|
51
|
+
for (const { desc, patterns, domain, expected } of cases) {
|
|
52
|
+
it(desc, () => {
|
|
53
|
+
setRegex(patterns)
|
|
54
|
+
assert.equal(this.plugin.in_host_regex(domain), expected)
|
|
55
|
+
})
|
|
56
|
+
}
|
|
58
57
|
})
|
|
59
58
|
|
|
60
59
|
describe('hook_mail', () => {
|
|
61
60
|
beforeEach(_set_up)
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
this.
|
|
65
|
-
this.plugin.
|
|
66
|
-
|
|
67
|
-
assert.equal(undefined, rc)
|
|
68
|
-
assert.equal(undefined, msg)
|
|
69
|
-
done()
|
|
70
|
-
},
|
|
71
|
-
this.connection,
|
|
72
|
-
[new Address('<>')],
|
|
73
|
-
)
|
|
74
|
-
})
|
|
62
|
+
const setRegex = (patterns) => {
|
|
63
|
+
this.plugin.host_list_regex = patterns
|
|
64
|
+
this.plugin.hl_re = new RegExp(`^(?:${patterns.join('|')})$`, 'i')
|
|
65
|
+
}
|
|
75
66
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
assert.equal(undefined, rc)
|
|
81
|
-
assert.equal(undefined, msg)
|
|
82
|
-
const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
|
|
83
|
-
assert.notEqual(-1, res.msg.indexOf('mail_from!local'))
|
|
84
|
-
done()
|
|
85
|
-
},
|
|
86
|
-
this.connection,
|
|
87
|
-
[new Address('<user@example.com>')],
|
|
88
|
-
)
|
|
89
|
-
})
|
|
67
|
+
const callMailHook = (addr) =>
|
|
68
|
+
new Promise((resolve) => {
|
|
69
|
+
this.plugin.hook_mail((rc, msg) => resolve({ rc, msg }), this.connection, [new Address(addr)])
|
|
70
|
+
})
|
|
90
71
|
|
|
91
|
-
it('
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
assert.equal(undefined, msg)
|
|
97
|
-
const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
|
|
98
|
-
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
99
|
-
done()
|
|
100
|
-
},
|
|
101
|
-
this.connection,
|
|
102
|
-
[new Address('<user@example.com>')],
|
|
103
|
-
)
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
it('hit, regex, exact', (done) => {
|
|
107
|
-
this.plugin.host_list_regex = ['example.com']
|
|
108
|
-
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
109
|
-
this.plugin.hook_mail(
|
|
110
|
-
(rc, msg) => {
|
|
111
|
-
assert.equal(undefined, rc)
|
|
112
|
-
assert.equal(undefined, msg)
|
|
113
|
-
const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
|
|
114
|
-
assert.notEqual(-1, res.pass.indexOf('mail_from'))
|
|
115
|
-
done()
|
|
116
|
-
},
|
|
117
|
-
this.connection,
|
|
118
|
-
[new Address('<user@example.com>')],
|
|
119
|
-
)
|
|
72
|
+
it('null sender always passes when relaying', async () => {
|
|
73
|
+
this.connection.relaying = true
|
|
74
|
+
const { rc, msg } = await callMailHook('<>')
|
|
75
|
+
assert.equal(rc, undefined)
|
|
76
|
+
assert.equal(msg, undefined)
|
|
120
77
|
})
|
|
121
78
|
|
|
122
|
-
it('
|
|
123
|
-
this.plugin.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
79
|
+
it('miss: records mail_from!local in results', async () => {
|
|
80
|
+
this.plugin.host_list = { 'miss.com': true }
|
|
81
|
+
const { rc, msg } = await callMailHook('<user@example.com>')
|
|
82
|
+
assert.equal(rc, undefined)
|
|
83
|
+
assert.equal(msg, undefined)
|
|
84
|
+
const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
|
|
85
|
+
assert.ok(res.msg.includes('mail_from!local'))
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
for (const [desc, setup] of [
|
|
89
|
+
[
|
|
90
|
+
'hit',
|
|
91
|
+
() => {
|
|
92
|
+
this.plugin.host_list = { 'example.com': true }
|
|
133
93
|
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
)
|
|
137
|
-
|
|
94
|
+
],
|
|
95
|
+
['hit, regex, exact', () => setRegex(['example.com'])],
|
|
96
|
+
['hit, regex, pattern', () => setRegex(['.*mple.com'])],
|
|
97
|
+
]) {
|
|
98
|
+
it(desc, async () => {
|
|
99
|
+
setup()
|
|
100
|
+
const { rc, msg } = await callMailHook('<user@example.com>')
|
|
101
|
+
assert.equal(rc, undefined)
|
|
102
|
+
assert.equal(msg, undefined)
|
|
103
|
+
const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
|
|
104
|
+
assert.ok(res.pass.includes('mail_from'))
|
|
105
|
+
})
|
|
106
|
+
}
|
|
138
107
|
})
|
|
139
108
|
|
|
140
109
|
describe('hook_rcpt', () => {
|
|
141
110
|
beforeEach(_set_up)
|
|
142
111
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
(rc, msg) => {
|
|
148
|
-
assert.equal(undefined, rc)
|
|
149
|
-
assert.equal(undefined, msg)
|
|
150
|
-
},
|
|
151
|
-
this.connection,
|
|
152
|
-
[new Address('test@test.com')],
|
|
153
|
-
)
|
|
154
|
-
assert.ok(true)
|
|
155
|
-
done()
|
|
156
|
-
})
|
|
112
|
+
const setRegex = (patterns) => {
|
|
113
|
+
this.plugin.host_list_regex = patterns
|
|
114
|
+
this.plugin.hl_re = new RegExp(`^(?:${patterns.join('|')})$`, 'i')
|
|
115
|
+
}
|
|
157
116
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
assert.equal(OK, rc)
|
|
163
|
-
assert.equal(undefined, msg)
|
|
164
|
-
done()
|
|
165
|
-
},
|
|
166
|
-
this.connection,
|
|
167
|
-
[new Address('test@test.com')],
|
|
168
|
-
)
|
|
169
|
-
})
|
|
117
|
+
const callRcptHook = (addr) =>
|
|
118
|
+
new Promise((resolve) => {
|
|
119
|
+
this.plugin.hook_rcpt((rc, msg) => resolve({ rc, msg }), this.connection, [new Address(addr)])
|
|
120
|
+
})
|
|
170
121
|
|
|
171
|
-
it('
|
|
172
|
-
|
|
173
|
-
this.
|
|
174
|
-
|
|
175
|
-
assert.equal(undefined, rc)
|
|
176
|
-
assert.equal(undefined, msg)
|
|
177
|
-
done()
|
|
178
|
-
},
|
|
179
|
-
this.connection,
|
|
180
|
-
[new Address('test@test.com')],
|
|
181
|
-
)
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
it('hit regex, exact', (done) => {
|
|
185
|
-
this.plugin.host_list_regex = ['test.com']
|
|
186
|
-
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
122
|
+
it('missing txn: does not call next (returns early)', () => {
|
|
123
|
+
// When transaction is missing the plugin returns without calling next()
|
|
124
|
+
delete this.connection.transaction
|
|
125
|
+
let nextCalled = false
|
|
187
126
|
this.plugin.hook_rcpt(
|
|
188
|
-
(
|
|
189
|
-
|
|
190
|
-
assert.equal(undefined, msg)
|
|
191
|
-
done()
|
|
127
|
+
() => {
|
|
128
|
+
nextCalled = true
|
|
192
129
|
},
|
|
193
130
|
this.connection,
|
|
194
131
|
[new Address('test@test.com')],
|
|
195
132
|
)
|
|
133
|
+
assert.equal(nextCalled, false)
|
|
196
134
|
})
|
|
197
135
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
assert.equal(OK, rc)
|
|
204
|
-
assert.equal(undefined, msg)
|
|
205
|
-
done()
|
|
136
|
+
const cases = [
|
|
137
|
+
{
|
|
138
|
+
desc: 'hit list',
|
|
139
|
+
setup: () => {
|
|
140
|
+
this.plugin.host_list = { 'test.com': true }
|
|
206
141
|
},
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
|
|
215
|
-
this.plugin.hook_rcpt(
|
|
216
|
-
(rc, msg) => {
|
|
217
|
-
assert.equal(undefined, rc)
|
|
218
|
-
assert.equal(undefined, msg)
|
|
219
|
-
done()
|
|
142
|
+
addr: 'test@test.com',
|
|
143
|
+
expectedRC: OK,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
desc: 'miss list',
|
|
147
|
+
setup: () => {
|
|
148
|
+
this.plugin.host_list = { 'miss.com': true }
|
|
220
149
|
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
150
|
+
addr: 'test@test.com',
|
|
151
|
+
expectedRC: undefined,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
desc: 'hit regex, exact',
|
|
155
|
+
setup: () => setRegex(['test.com']),
|
|
156
|
+
addr: 'test@test.com',
|
|
157
|
+
expectedRC: OK,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
desc: 'hit regex, pattern',
|
|
161
|
+
setup: () => setRegex(['.est.com']),
|
|
162
|
+
addr: 'test@test.com',
|
|
163
|
+
expectedRC: OK,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
desc: 'miss regex, pattern',
|
|
167
|
+
setup: () => setRegex(['a.est.com']),
|
|
168
|
+
addr: 'test@test.com',
|
|
169
|
+
expectedRC: undefined,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
desc: 'rcpt miss, relaying to local sender',
|
|
173
|
+
setup: () => {
|
|
174
|
+
this.connection.relaying = true
|
|
175
|
+
this.connection.transaction.notes = { local_sender: true }
|
|
234
176
|
},
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
177
|
+
addr: 'test@test.com',
|
|
178
|
+
expectedRC: OK,
|
|
179
|
+
},
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
for (const { desc, setup, addr, expectedRC } of cases) {
|
|
183
|
+
it(desc, async () => {
|
|
184
|
+
setup()
|
|
185
|
+
const { rc, msg } = await callRcptHook(addr)
|
|
186
|
+
assert.equal(rc, expectedRC)
|
|
187
|
+
assert.equal(msg, undefined)
|
|
188
|
+
})
|
|
189
|
+
}
|
|
239
190
|
})
|
|
240
191
|
})
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const assert = require('node:assert')
|
|
3
|
+
const assert = require('node:assert/strict')
|
|
4
|
+
const { describe, it, beforeEach } = require('node:test')
|
|
4
5
|
|
|
5
6
|
const { Address } = require('address-rfc2821')
|
|
6
7
|
const fixtures = require('haraka-test-fixtures')
|
|
7
8
|
|
|
8
|
-
const _set_up = (
|
|
9
|
+
const _set_up = () => {
|
|
9
10
|
this.plugin = new fixtures.plugin('record_envelope_addresses')
|
|
10
11
|
this.connection = fixtures.connection.createConnection()
|
|
11
12
|
this.connection.init_transaction()
|
|
12
|
-
done()
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
describe('record_envelope_addresses', () => {
|
|
16
16
|
beforeEach(_set_up)
|
|
17
17
|
|
|
18
18
|
describe('hook_mail', () => {
|
|
19
|
-
it('adds X-Envelope-From header from MAIL FROM address', (done) => {
|
|
19
|
+
it('adds X-Envelope-From header from MAIL FROM address', (t, done) => {
|
|
20
20
|
const addr = new Address('<sender@example.com>')
|
|
21
21
|
this.plugin.hook_mail(
|
|
22
22
|
() => {
|
|
@@ -30,7 +30,7 @@ describe('record_envelope_addresses', () => {
|
|
|
30
30
|
)
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
-
it('does not throw when connection has no transaction', (done) => {
|
|
33
|
+
it('does not throw when connection has no transaction', (t, done) => {
|
|
34
34
|
this.connection.transaction = null
|
|
35
35
|
const addr = new Address('<sender@example.com>')
|
|
36
36
|
this.plugin.hook_mail(
|
|
@@ -45,7 +45,7 @@ describe('record_envelope_addresses', () => {
|
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
describe('hook_rcpt', () => {
|
|
48
|
-
it('adds X-Envelope-To header from RCPT TO address', (done) => {
|
|
48
|
+
it('adds X-Envelope-To header from RCPT TO address', (t, done) => {
|
|
49
49
|
const addr = new Address('<rcpt@example.com>')
|
|
50
50
|
this.plugin.hook_rcpt(
|
|
51
51
|
() => {
|
|
@@ -59,7 +59,7 @@ describe('record_envelope_addresses', () => {
|
|
|
59
59
|
)
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
-
it('adds X-Envelope-To header for each recipient', (done) => {
|
|
62
|
+
it('adds X-Envelope-To header for each recipient', (t, done) => {
|
|
63
63
|
const addr1 = new Address('<one@example.com>')
|
|
64
64
|
const addr2 = new Address('<two@example.com>')
|
|
65
65
|
let calls = 0
|
|
@@ -77,7 +77,7 @@ describe('record_envelope_addresses', () => {
|
|
|
77
77
|
this.plugin.hook_rcpt(next, this.connection, [addr2])
|
|
78
78
|
})
|
|
79
79
|
|
|
80
|
-
it('does not throw when connection has no transaction', (done) => {
|
|
80
|
+
it('does not throw when connection has no transaction', (t, done) => {
|
|
81
81
|
this.connection.transaction = null
|
|
82
82
|
const addr = new Address('<rcpt@example.com>')
|
|
83
83
|
this.plugin.hook_rcpt(
|