Haraka 3.1.0 → 3.1.2

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 (160) hide show
  1. package/.prettierignore +4 -0
  2. package/CONTRIBUTORS.md +5 -5
  3. package/Changes.md +69 -50
  4. package/Plugins.md +3 -1
  5. package/README.md +1 -1
  6. package/bin/haraka +475 -478
  7. package/config/outbound.ini +3 -0
  8. package/connection.js +1072 -1108
  9. package/docs/Connection.md +29 -30
  10. package/docs/CoreConfig.md +38 -39
  11. package/docs/CustomReturnCodes.md +0 -1
  12. package/docs/HAProxy.md +2 -2
  13. package/docs/Header.md +1 -1
  14. package/docs/Logging.md +29 -5
  15. package/docs/Outbound.md +93 -78
  16. package/docs/Plugins.md +103 -108
  17. package/docs/Transaction.md +49 -51
  18. package/docs/Tutorial.md +127 -143
  19. package/docs/deprecated/access.md +0 -1
  20. package/docs/deprecated/backscatterer.md +2 -3
  21. package/docs/deprecated/connect.rdns_access.md +18 -27
  22. package/docs/deprecated/data.headers.md +0 -1
  23. package/docs/deprecated/data.nomsgid.md +1 -2
  24. package/docs/deprecated/data.noreceived.md +1 -2
  25. package/docs/deprecated/data.rfc5322_header_checks.md +1 -2
  26. package/docs/deprecated/dkim_sign.md +13 -17
  27. package/docs/deprecated/dkim_verify.md +9 -17
  28. package/docs/deprecated/dnsbl.md +36 -38
  29. package/docs/deprecated/dnswl.md +41 -43
  30. package/docs/deprecated/lookup_rdns.strict.md +21 -34
  31. package/docs/deprecated/mail_from.access.md +17 -25
  32. package/docs/deprecated/mail_from.blocklist.md +9 -12
  33. package/docs/deprecated/mail_from.nobounces.md +1 -2
  34. package/docs/deprecated/rcpt_to.access.md +20 -27
  35. package/docs/deprecated/rcpt_to.blocklist.md +10 -13
  36. package/docs/deprecated/rcpt_to.routes.md +0 -1
  37. package/docs/deprecated/rdns.regexp.md +13 -15
  38. package/docs/plugins/aliases.md +89 -89
  39. package/docs/plugins/auth/auth_bridge.md +5 -7
  40. package/docs/plugins/auth/auth_ldap.md +11 -14
  41. package/docs/plugins/auth/auth_proxy.md +10 -12
  42. package/docs/plugins/auth/auth_vpopmaild.md +5 -6
  43. package/docs/plugins/auth/flat_file.md +4 -4
  44. package/docs/plugins/block_me.md +3 -3
  45. package/docs/plugins/data.signatures.md +1 -2
  46. package/docs/plugins/delay_deny.md +3 -4
  47. package/docs/plugins/max_unrecognized_commands.md +4 -4
  48. package/docs/plugins/prevent_credential_leaks.md +6 -6
  49. package/docs/plugins/process_title.md +18 -18
  50. package/docs/plugins/queue/deliver.md +2 -3
  51. package/docs/plugins/queue/discard.md +4 -4
  52. package/docs/plugins/queue/lmtp.md +1 -3
  53. package/docs/plugins/queue/qmail-queue.md +7 -9
  54. package/docs/plugins/queue/quarantine.md +16 -21
  55. package/docs/plugins/queue/rabbitmq.md +8 -11
  56. package/docs/plugins/queue/rabbitmq_amqplib.md +43 -39
  57. package/docs/plugins/queue/smtp_bridge.md +7 -10
  58. package/docs/plugins/queue/smtp_forward.md +42 -34
  59. package/docs/plugins/queue/smtp_proxy.md +30 -29
  60. package/docs/plugins/queue/test.md +1 -3
  61. package/docs/plugins/rcpt_to.in_host_list.md +6 -6
  62. package/docs/plugins/rcpt_to.max_count.md +1 -1
  63. package/docs/plugins/record_envelope_addresses.md +3 -3
  64. package/docs/plugins/reseed_rng.md +6 -6
  65. package/docs/plugins/status.md +9 -8
  66. package/docs/plugins/tarpit.md +7 -11
  67. package/docs/plugins/tls.md +12 -17
  68. package/docs/plugins/toobusy.md +4 -4
  69. package/docs/plugins/xclient.md +3 -3
  70. package/docs/tutorials/Migrating_from_v1_to_v2.md +19 -41
  71. package/docs/tutorials/SettingUpOutbound.md +6 -9
  72. package/endpoint.js +35 -38
  73. package/eslint.config.mjs +22 -19
  74. package/haraka.js +42 -47
  75. package/host_pool.js +75 -79
  76. package/http/html/404.html +45 -49
  77. package/http/html/index.html +39 -28
  78. package/http/package.json +2 -4
  79. package/line_socket.js +27 -28
  80. package/logger.js +182 -201
  81. package/outbound/client_pool.js +34 -27
  82. package/outbound/config.js +64 -59
  83. package/outbound/fsync_writestream.js +24 -25
  84. package/outbound/hmail.js +888 -835
  85. package/outbound/index.js +194 -187
  86. package/outbound/qfile.js +49 -52
  87. package/outbound/queue.js +197 -190
  88. package/outbound/timer_queue.js +41 -43
  89. package/outbound/tls.js +68 -61
  90. package/outbound/todo.js +11 -11
  91. package/package.json +38 -33
  92. package/plugins/.eslintrc.yaml +0 -1
  93. package/plugins/auth/auth_base.js +123 -127
  94. package/plugins/auth/auth_bridge.js +7 -7
  95. package/plugins/auth/auth_proxy.js +121 -126
  96. package/plugins/auth/auth_vpopmaild.js +84 -85
  97. package/plugins/auth/flat_file.js +18 -17
  98. package/plugins/block_me.js +31 -31
  99. package/plugins/data.signatures.js +13 -13
  100. package/plugins/delay_deny.js +65 -61
  101. package/plugins/prevent_credential_leaks.js +23 -23
  102. package/plugins/process_title.js +125 -128
  103. package/plugins/profile.js +5 -5
  104. package/plugins/queue/deliver.js +3 -3
  105. package/plugins/queue/discard.js +13 -14
  106. package/plugins/queue/lmtp.js +16 -17
  107. package/plugins/queue/qmail-queue.js +54 -55
  108. package/plugins/queue/quarantine.js +68 -70
  109. package/plugins/queue/rabbitmq.js +80 -87
  110. package/plugins/queue/rabbitmq_amqplib.js +75 -54
  111. package/plugins/queue/smtp_bridge.js +16 -16
  112. package/plugins/queue/smtp_forward.js +175 -179
  113. package/plugins/queue/smtp_proxy.js +69 -71
  114. package/plugins/queue/test.js +9 -9
  115. package/plugins/rcpt_to.host_list_base.js +30 -34
  116. package/plugins/rcpt_to.in_host_list.js +19 -19
  117. package/plugins/record_envelope_addresses.js +4 -4
  118. package/plugins/reseed_rng.js +4 -4
  119. package/plugins/status.js +90 -97
  120. package/plugins/tarpit.js +25 -14
  121. package/plugins/tls.js +68 -68
  122. package/plugins/toobusy.js +21 -23
  123. package/plugins/xclient.js +51 -53
  124. package/plugins.js +276 -293
  125. package/rfc1869.js +30 -35
  126. package/server.js +308 -299
  127. package/smtp_client.js +244 -228
  128. package/test/.eslintrc.yaml +0 -1
  129. package/test/connection.js +127 -134
  130. package/test/endpoint.js +53 -47
  131. package/test/fixtures/line_socket.js +12 -12
  132. package/test/fixtures/util_hmailitem.js +89 -85
  133. package/test/host_pool.js +90 -92
  134. package/test/installation/plugins/base_plugin.js +2 -2
  135. package/test/installation/plugins/folder_plugin/index.js +2 -3
  136. package/test/installation/plugins/inherits.js +3 -3
  137. package/test/installation/plugins/load_first.js +2 -3
  138. package/test/installation/plugins/plugin.js +1 -3
  139. package/test/installation/plugins/tls.js +2 -4
  140. package/test/logger.js +135 -116
  141. package/test/outbound/hmail.js +49 -35
  142. package/test/outbound/index.js +118 -101
  143. package/test/outbound/qfile.js +51 -53
  144. package/test/outbound_bounce_net_errors.js +84 -69
  145. package/test/outbound_bounce_rfc3464.js +235 -165
  146. package/test/plugins/auth/auth_base.js +420 -279
  147. package/test/plugins/auth/auth_vpopmaild.js +38 -39
  148. package/test/plugins/queue/smtp_forward.js +126 -104
  149. package/test/plugins/rcpt_to.host_list_base.js +85 -67
  150. package/test/plugins/rcpt_to.in_host_list.js +159 -112
  151. package/test/plugins/status.js +71 -64
  152. package/test/plugins/tls.js +37 -34
  153. package/test/plugins.js +97 -92
  154. package/test/rfc1869.js +19 -26
  155. package/test/server.js +293 -272
  156. package/test/smtp_client.js +180 -176
  157. package/test/tls_socket.js +62 -66
  158. package/test/transaction.js +159 -160
  159. package/tls_socket.js +331 -333
  160. package/transaction.js +129 -137
@@ -1,92 +1,96 @@
1
- 'use strict';
1
+ 'use strict'
2
2
  const assert = require('node:assert')
3
3
 
4
- const { Address } = require('address-rfc2821');
5
- const fixtures = require('haraka-test-fixtures');
6
- const utils = require('haraka-utils');
4
+ const { Address } = require('address-rfc2821')
5
+ const fixtures = require('haraka-test-fixtures')
6
+ const utils = require('haraka-utils')
7
7
 
8
8
  const _set_up = (done) => {
9
-
10
- this.plugin = new fixtures.plugin('auth/auth_base');
9
+ this.plugin = new fixtures.plugin('auth/auth_base')
11
10
 
12
11
  this.plugin.get_plain_passwd = (user, cb) => {
13
- if (user === 'test') return cb('testpass');
14
- return cb(null);
15
- };
12
+ if (user === 'test') return cb('testpass')
13
+ return cb(null)
14
+ }
16
15
 
17
- this.connection = fixtures.connection.createConnection();
18
- this.connection.capabilities=null;
16
+ this.connection = fixtures.connection.createConnection()
17
+ this.connection.capabilities = null
19
18
 
20
- done();
19
+ done()
21
20
  }
22
21
 
23
22
  const _set_up_2 = (done) => {
24
-
25
- this.plugin = new fixtures.plugin('auth/auth_base');
23
+ this.plugin = new fixtures.plugin('auth/auth_base')
26
24
 
27
25
  this.plugin.get_plain_passwd = (user, connection, cb) => {
28
- connection.notes.auth_custom_note = 'custom_note';
29
- if (user === 'test') return cb('testpass');
30
- return cb(null);
31
- };
26
+ connection.notes.auth_custom_note = 'custom_note'
27
+ if (user === 'test') return cb('testpass')
28
+ return cb(null)
29
+ }
32
30
 
33
- this.connection = fixtures.connection.createConnection();
34
- this.connection.capabilities=null;
31
+ this.connection = fixtures.connection.createConnection()
32
+ this.connection.capabilities = null
35
33
 
36
- done();
34
+ done()
37
35
  }
38
36
 
39
37
  const _set_up_custom_pwcb_opts = (done) => {
40
- this.plugin = new fixtures.plugin('auth/auth_base');
38
+ this.plugin = new fixtures.plugin('auth/auth_base')
41
39
 
42
40
  this.plugin.check_plain_passwd = (connection, user, passwd, pwok_cb) => {
43
41
  switch (user) {
44
- case 'legacyok_nomessage': return pwok_cb(true);
45
- case 'legacyfail_nomessage': return pwok_cb(false);
46
- case 'legacyok_message': return pwok_cb(true, 'GREAT SUCCESS');
47
- case 'legacyfail_message': return pwok_cb(false, 'FAIL 123');
48
- case 'newok': return pwok_cb(true, {message: 'KOKOKO', code: 215});
49
- case 'newfail': return pwok_cb(false, {message: 'OHOHOH', code: 555});
50
- default: throw 'what?!';
42
+ case 'legacyok_nomessage':
43
+ return pwok_cb(true)
44
+ case 'legacyfail_nomessage':
45
+ return pwok_cb(false)
46
+ case 'legacyok_message':
47
+ return pwok_cb(true, 'GREAT SUCCESS')
48
+ case 'legacyfail_message':
49
+ return pwok_cb(false, 'FAIL 123')
50
+ case 'newok':
51
+ return pwok_cb(true, { message: 'KOKOKO', code: 215 })
52
+ case 'newfail':
53
+ return pwok_cb(false, { message: 'OHOHOH', code: 555 })
54
+ default:
55
+ throw 'what?!'
51
56
  }
52
- };
57
+ }
53
58
 
54
- this.connection = fixtures.connection.createConnection();
55
- this.connection.capabilities=null;
56
- this.connection.notes.resp_strings = [];
59
+ this.connection = fixtures.connection.createConnection()
60
+ this.connection.capabilities = null
61
+ this.connection.notes.resp_strings = []
57
62
  this.connection.respond = (code, msg, cb) => {
58
- this.connection.notes.resp_strings.push([code, msg]);
59
- return cb();
63
+ this.connection.notes.resp_strings.push([code, msg])
64
+ return cb()
60
65
  }
61
66
 
62
- done();
67
+ done()
63
68
  }
64
69
 
65
70
  describe('auth_base', () => {
66
-
67
71
  describe('hook_capabilities', () => {
68
72
  beforeEach(_set_up)
69
73
 
70
74
  it('no TLS, no auth', (done) => {
71
75
  this.plugin.hook_capabilities((rc, msg) => {
72
- assert.equal(undefined, rc);
73
- assert.equal(undefined, msg);
74
- assert.equal(null, this.connection.capabilities);
75
- done();
76
- }, this.connection);
76
+ assert.equal(undefined, rc)
77
+ assert.equal(undefined, msg)
78
+ assert.equal(null, this.connection.capabilities)
79
+ done()
80
+ }, this.connection)
77
81
  })
78
82
 
79
83
  it('with TLS, auth is offered', (done) => {
80
- this.connection.tls.enabled=true;
81
- this.connection.capabilities=[];
84
+ this.connection.tls.enabled = true
85
+ this.connection.capabilities = []
82
86
  this.plugin.hook_capabilities((rc, msg) => {
83
- assert.equal(undefined, rc);
84
- assert.equal(undefined, msg);
85
- assert.ok(this.connection.capabilities.length);
86
- assert.ok(this.connection.capabilities[0] === 'AUTH PLAIN LOGIN CRAM-MD5');
87
+ assert.equal(undefined, rc)
88
+ assert.equal(undefined, msg)
89
+ assert.ok(this.connection.capabilities.length)
90
+ assert.ok(this.connection.capabilities[0] === 'AUTH PLAIN LOGIN CRAM-MD5')
87
91
  // console.log(this.connection.capabilities);
88
- done();
89
- }, this.connection);
92
+ done()
93
+ }, this.connection)
90
94
  })
91
95
  })
92
96
 
@@ -94,16 +98,16 @@ describe('auth_base', () => {
94
98
  beforeEach(_set_up)
95
99
 
96
100
  it('get_plain_passwd, no result', (done) => {
97
- this.plugin.get_plain_passwd('user', pass => {
98
- assert.equal(pass, null);
99
- done();
100
- });
101
+ this.plugin.get_plain_passwd('user', (pass) => {
102
+ assert.equal(pass, null)
103
+ done()
104
+ })
101
105
  })
102
106
  it('get_plain_passwd, test user', (done) => {
103
- this.plugin.get_plain_passwd('test', pass => {
104
- assert.equal(pass, 'testpass');
105
- done();
106
- });
107
+ this.plugin.get_plain_passwd('test', (pass) => {
108
+ assert.equal(pass, 'testpass')
109
+ done()
110
+ })
107
111
  })
108
112
  })
109
113
 
@@ -111,24 +115,24 @@ describe('auth_base', () => {
111
115
  beforeEach(_set_up)
112
116
 
113
117
  it('valid password', (done) => {
114
- this.plugin.check_plain_passwd(this.connection, 'test', 'testpass', pass => {
115
- assert.equal(pass, true);
116
- done();
117
- });
118
+ this.plugin.check_plain_passwd(this.connection, 'test', 'testpass', (pass) => {
119
+ assert.equal(pass, true)
120
+ done()
121
+ })
118
122
  })
119
123
 
120
124
  it('wrong password', (done) => {
121
- this.plugin.check_plain_passwd(this.connection, 'test', 'test1pass', pass => {
122
- assert.equal(pass, false);
123
- done();
124
- });
125
+ this.plugin.check_plain_passwd(this.connection, 'test', 'test1pass', (pass) => {
126
+ assert.equal(pass, false)
127
+ done()
128
+ })
125
129
  })
126
130
 
127
131
  it('null password', (done) => {
128
- this.plugin.check_plain_passwd(this.connection, 'test', null, pass => {
129
- assert.equal(pass, false);
130
- done();
131
- });
132
+ this.plugin.check_plain_passwd(this.connection, 'test', null, (pass) => {
133
+ assert.equal(pass, false)
134
+ done()
135
+ })
132
136
  })
133
137
  })
134
138
 
@@ -136,30 +140,42 @@ describe('auth_base', () => {
136
140
  beforeEach(_set_up)
137
141
 
138
142
  it('no auth methods yield no result', (done) => {
139
- this.plugin.select_auth_method((code) => {
140
- assert.equal(code, null);
141
- assert.equal(false, this.connection.relaying);
142
- done();
143
- }, this.connection, 'AUTH PLAIN');
143
+ this.plugin.select_auth_method(
144
+ (code) => {
145
+ assert.equal(code, null)
146
+ assert.equal(false, this.connection.relaying)
147
+ done()
148
+ },
149
+ this.connection,
150
+ 'AUTH PLAIN',
151
+ )
144
152
  })
145
153
 
146
154
  it('invalid AUTH method, no result', (done) => {
147
- this.connection.notes.allowed_auth_methods = ['PLAIN','LOGIN','CRAM-MD5'];
148
- this.plugin.select_auth_method((code) => {
149
- assert.equal(code, null);
150
- assert.equal(false, this.connection.relaying);
151
- done();
152
- }, this.connection, 'AUTH FOO');
155
+ this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN', 'CRAM-MD5']
156
+ this.plugin.select_auth_method(
157
+ (code) => {
158
+ assert.equal(code, null)
159
+ assert.equal(false, this.connection.relaying)
160
+ done()
161
+ },
162
+ this.connection,
163
+ 'AUTH FOO',
164
+ )
153
165
  })
154
166
 
155
167
  it('valid AUTH method, valid attempt', (done) => {
156
- const method = `PLAIN ${utils.base64('discard\0test\0testpass')}`;
157
- this.connection.notes.allowed_auth_methods = ['PLAIN','LOGIN'];
158
- this.plugin.select_auth_method((code) => {
159
- assert.equal(code, OK);
160
- assert.ok(this.connection.relaying);
161
- done();
162
- }, this.connection, method);
168
+ const method = `PLAIN ${utils.base64('discard\0test\0testpass')}`
169
+ this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
170
+ this.plugin.select_auth_method(
171
+ (code) => {
172
+ assert.equal(code, OK)
173
+ assert.ok(this.connection.relaying)
174
+ done()
175
+ },
176
+ this.connection,
177
+ method,
178
+ )
163
179
  })
164
180
  })
165
181
 
@@ -167,36 +183,52 @@ describe('auth_base', () => {
167
183
  beforeEach(_set_up)
168
184
 
169
185
  it('params type=string returns OK', (done) => {
170
- this.plugin.auth_plain((rc) => {
171
- assert.equal(rc, OK);
172
- assert.equal(false, this.connection.relaying);
173
- done();
174
- }, this.connection, 'AUTH FOO');
186
+ this.plugin.auth_plain(
187
+ (rc) => {
188
+ assert.equal(rc, OK)
189
+ assert.equal(false, this.connection.relaying)
190
+ done()
191
+ },
192
+ this.connection,
193
+ 'AUTH FOO',
194
+ )
175
195
  })
176
196
 
177
197
  it('params type=empty array, returns OK', (done) => {
178
- this.plugin.auth_plain((rc) => {
179
- assert.equal(rc, OK);
180
- assert.equal(false, this.connection.relaying);
181
- done();
182
- }, this.connection, []);
198
+ this.plugin.auth_plain(
199
+ (rc) => {
200
+ assert.equal(rc, OK)
201
+ assert.equal(false, this.connection.relaying)
202
+ done()
203
+ },
204
+ this.connection,
205
+ [],
206
+ )
183
207
  })
184
208
 
185
209
  it('params type=array, successful auth', (done) => {
186
- const method = utils.base64('discard\0test\0testpass');
187
- this.plugin.auth_plain((rc) => {
188
- assert.equal(rc, OK);
189
- assert.ok(this.connection.relaying);
190
- done();
191
- }, this.connection, [method]);
210
+ const method = utils.base64('discard\0test\0testpass')
211
+ this.plugin.auth_plain(
212
+ (rc) => {
213
+ assert.equal(rc, OK)
214
+ assert.ok(this.connection.relaying)
215
+ done()
216
+ },
217
+ this.connection,
218
+ [method],
219
+ )
192
220
  })
193
221
 
194
222
  it('params type=with two line login', (done) => {
195
- this.plugin.auth_plain((rc) => {
196
- assert.equal(this.connection.notes.auth_plain_asked_login, true);
197
- assert.equal(rc, OK);
198
- done();
199
- }, this.connection, '');
223
+ this.plugin.auth_plain(
224
+ (rc) => {
225
+ assert.equal(this.connection.notes.auth_plain_asked_login, true)
226
+ assert.equal(rc, OK)
227
+ done()
228
+ },
229
+ this.connection,
230
+ '',
231
+ )
200
232
  })
201
233
  })
202
234
 
@@ -204,23 +236,33 @@ describe('auth_base', () => {
204
236
  beforeEach(_set_up_2)
205
237
 
206
238
  it('bad auth', (done) => {
207
- const credentials = ['matt','ttam'];
208
- this.plugin.check_user((code) => {
209
- assert.equal(code, OK);
210
- assert.equal(this.connection.relaying, false);
211
- assert.equal(this.connection.notes.auth_custom_note, 'custom_note');
212
- done();
213
- }, this.connection, credentials, 'PLAIN');
239
+ const credentials = ['matt', 'ttam']
240
+ this.plugin.check_user(
241
+ (code) => {
242
+ assert.equal(code, OK)
243
+ assert.equal(this.connection.relaying, false)
244
+ assert.equal(this.connection.notes.auth_custom_note, 'custom_note')
245
+ done()
246
+ },
247
+ this.connection,
248
+ credentials,
249
+ 'PLAIN',
250
+ )
214
251
  })
215
252
 
216
253
  it('good auth', (done) => {
217
- const credentials = ['test','testpass'];
218
- this.plugin.check_user((code) => {
219
- assert.equal(code, OK);
220
- assert.ok(this.connection.relaying);
221
- assert.equal(this.connection.notes.auth_custom_note, 'custom_note');
222
- done();
223
- }, this.connection, credentials, 'PLAIN');
254
+ const credentials = ['test', 'testpass']
255
+ this.plugin.check_user(
256
+ (code) => {
257
+ assert.equal(code, OK)
258
+ assert.ok(this.connection.relaying)
259
+ assert.equal(this.connection.notes.auth_custom_note, 'custom_note')
260
+ done()
261
+ },
262
+ this.connection,
263
+ credentials,
264
+ 'PLAIN',
265
+ )
224
266
  })
225
267
  })
226
268
 
@@ -228,57 +270,87 @@ describe('auth_base', () => {
228
270
  beforeEach(_set_up_custom_pwcb_opts)
229
271
 
230
272
  it('legacyok_nomessage', (done) => {
231
- this.plugin.check_user((code, msg) => {
232
- assert.equal(code, OK);
233
- assert.equal(this.connection.relaying, true);
234
- assert.deepEqual(this.connection.notes.resp_strings, [[ 235, '2.7.0 Authentication successful' ]]);
235
- done();
236
- }, this.connection, ['legacyok_nomessage', 'any'], 'PLAIN');
273
+ this.plugin.check_user(
274
+ (code, msg) => {
275
+ assert.equal(code, OK)
276
+ assert.equal(this.connection.relaying, true)
277
+ assert.deepEqual(this.connection.notes.resp_strings, [[235, '2.7.0 Authentication successful']])
278
+ done()
279
+ },
280
+ this.connection,
281
+ ['legacyok_nomessage', 'any'],
282
+ 'PLAIN',
283
+ )
237
284
  })
238
285
 
239
286
  it('legacyfail_nomessage', (done) => {
240
- this.plugin.check_user((code, msg) => {
241
- assert.equal(code, OK);
242
- assert.equal(this.connection.relaying, false);
243
- assert.deepEqual(this.connection.notes.resp_strings, [ [ 535, '5.7.8 Authentication failed' ] ]);
244
- done();
245
- }, this.connection, ['legacyfail_nomessage', 'any'], 'PLAIN');
287
+ this.plugin.check_user(
288
+ (code, msg) => {
289
+ assert.equal(code, OK)
290
+ assert.equal(this.connection.relaying, false)
291
+ assert.deepEqual(this.connection.notes.resp_strings, [[535, '5.7.8 Authentication failed']])
292
+ done()
293
+ },
294
+ this.connection,
295
+ ['legacyfail_nomessage', 'any'],
296
+ 'PLAIN',
297
+ )
246
298
  })
247
299
 
248
300
  it('legacyok_message', (done) => {
249
- this.plugin.check_user((code, msg) => {
250
- assert.equal(code, OK);
251
- assert.equal(this.connection.relaying, true);
252
- assert.deepEqual(this.connection.notes.resp_strings, [[ 235, 'GREAT SUCCESS' ]]);
253
- done();
254
- }, this.connection, ['legacyok_message', 'any'], 'PLAIN');
301
+ this.plugin.check_user(
302
+ (code, msg) => {
303
+ assert.equal(code, OK)
304
+ assert.equal(this.connection.relaying, true)
305
+ assert.deepEqual(this.connection.notes.resp_strings, [[235, 'GREAT SUCCESS']])
306
+ done()
307
+ },
308
+ this.connection,
309
+ ['legacyok_message', 'any'],
310
+ 'PLAIN',
311
+ )
255
312
  })
256
313
 
257
314
  it('legacyfail_message', (done) => {
258
- this.plugin.check_user((code, msg) => {
259
- assert.equal(code, OK);
260
- assert.equal(this.connection.relaying, false);
261
- assert.deepEqual(this.connection.notes.resp_strings, [[ 535, 'FAIL 123' ]]);
262
- done();
263
- }, this.connection, ['legacyfail_message', 'any'], 'PLAIN');
315
+ this.plugin.check_user(
316
+ (code, msg) => {
317
+ assert.equal(code, OK)
318
+ assert.equal(this.connection.relaying, false)
319
+ assert.deepEqual(this.connection.notes.resp_strings, [[535, 'FAIL 123']])
320
+ done()
321
+ },
322
+ this.connection,
323
+ ['legacyfail_message', 'any'],
324
+ 'PLAIN',
325
+ )
264
326
  })
265
327
 
266
328
  it('newok', (done) => {
267
- this.plugin.check_user((code, msg) => {
268
- assert.equal(code, OK);
269
- assert.equal(this.connection.relaying, true);
270
- assert.deepEqual(this.connection.notes.resp_strings, [[ 215, 'KOKOKO' ]]);
271
- done();
272
- }, this.connection, ['newok', 'any'], 'PLAIN');
329
+ this.plugin.check_user(
330
+ (code, msg) => {
331
+ assert.equal(code, OK)
332
+ assert.equal(this.connection.relaying, true)
333
+ assert.deepEqual(this.connection.notes.resp_strings, [[215, 'KOKOKO']])
334
+ done()
335
+ },
336
+ this.connection,
337
+ ['newok', 'any'],
338
+ 'PLAIN',
339
+ )
273
340
  })
274
341
 
275
342
  it('newfail', (done) => {
276
- this.plugin.check_user((code, msg) => {
277
- assert.equal(code, OK);
278
- assert.equal(this.connection.relaying, false);
279
- assert.deepEqual(this.connection.notes.resp_strings, [[ 555, 'OHOHOH' ]]);
280
- done();
281
- }, this.connection, ['newfail', 'any'], 'PLAIN');
343
+ this.plugin.check_user(
344
+ (code, msg) => {
345
+ assert.equal(code, OK)
346
+ assert.equal(this.connection.relaying, false)
347
+ assert.deepEqual(this.connection.notes.resp_strings, [[555, 'OHOHOH']])
348
+ done()
349
+ },
350
+ this.connection,
351
+ ['newfail', 'any'],
352
+ 'PLAIN',
353
+ )
282
354
  })
283
355
  })
284
356
 
@@ -286,31 +358,46 @@ describe('auth_base', () => {
286
358
  beforeEach(_set_up_2)
287
359
 
288
360
  it('bad auth: no notes should be set', (done) => {
289
- const credentials = ['matt','ttam'];
290
- this.plugin.check_user((code) => {
291
- assert.equal(this.connection.notes.auth_user, undefined);
292
- assert.equal(this.connection.notes.auth_passwd, undefined);
293
- done();
294
- }, this.connection, credentials, 'PLAIN');
361
+ const credentials = ['matt', 'ttam']
362
+ this.plugin.check_user(
363
+ (code) => {
364
+ assert.equal(this.connection.notes.auth_user, undefined)
365
+ assert.equal(this.connection.notes.auth_passwd, undefined)
366
+ done()
367
+ },
368
+ this.connection,
369
+ credentials,
370
+ 'PLAIN',
371
+ )
295
372
  })
296
373
 
297
374
  it('good auth: dont store password', (done) => {
298
- const creds = ['test','testpass'];
299
- this.plugin.blankout_password = true;
300
- this.plugin.check_user((code) => {
301
- assert.equal(this.connection.notes.auth_user, creds[0]);
302
- assert.equal(this.connection.notes.auth_passwd, undefined);
303
- done();
304
- }, this.connection, creds, 'PLAIN');
375
+ const creds = ['test', 'testpass']
376
+ this.plugin.blankout_password = true
377
+ this.plugin.check_user(
378
+ (code) => {
379
+ assert.equal(this.connection.notes.auth_user, creds[0])
380
+ assert.equal(this.connection.notes.auth_passwd, undefined)
381
+ done()
382
+ },
383
+ this.connection,
384
+ creds,
385
+ 'PLAIN',
386
+ )
305
387
  })
306
388
 
307
389
  it('good auth: store password (default)', (done) => {
308
- const creds = ['test','testpass'];
309
- this.plugin.check_user((code) => {
310
- assert.equal(this.connection.notes.auth_user, creds[0]);
311
- assert.equal(this.connection.notes.auth_passwd, creds[1]);
312
- done();
313
- }, this.connection, creds, 'PLAIN');
390
+ const creds = ['test', 'testpass']
391
+ this.plugin.check_user(
392
+ (code) => {
393
+ assert.equal(this.connection.notes.auth_user, creds[0])
394
+ assert.equal(this.connection.notes.auth_passwd, creds[1])
395
+ done()
396
+ },
397
+ this.connection,
398
+ creds,
399
+ 'PLAIN',
400
+ )
314
401
  })
315
402
  })
316
403
 
@@ -318,34 +405,46 @@ describe('auth_base', () => {
318
405
  beforeEach(_set_up)
319
406
 
320
407
  it('AUTH type FOO', (done) => {
321
- const params = ['AUTH','FOO'];
322
- this.connection.notes.allowed_auth_methods = ['PLAIN','LOGIN'];
323
- this.plugin.hook_unrecognized_command((code) => {
324
- assert.equal(code, null);
325
- assert.equal(this.connection.relaying, false);
326
- done();
327
- }, this.connection, params);
408
+ const params = ['AUTH', 'FOO']
409
+ this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
410
+ this.plugin.hook_unrecognized_command(
411
+ (code) => {
412
+ assert.equal(code, null)
413
+ assert.equal(this.connection.relaying, false)
414
+ done()
415
+ },
416
+ this.connection,
417
+ params,
418
+ )
328
419
  })
329
420
 
330
421
  it('AUTH PLAIN', (done) => {
331
- const params = ['AUTH','PLAIN', utils.base64('discard\0test\0testpass')];
332
- this.connection.notes.allowed_auth_methods = ['PLAIN','LOGIN'];
333
- this.plugin.hook_unrecognized_command((code) => {
334
- assert.equal(code, OK);
335
- assert.ok(this.connection.relaying);
336
- done();
337
- }, this.connection, params);
422
+ const params = ['AUTH', 'PLAIN', utils.base64('discard\0test\0testpass')]
423
+ this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
424
+ this.plugin.hook_unrecognized_command(
425
+ (code) => {
426
+ assert.equal(code, OK)
427
+ assert.ok(this.connection.relaying)
428
+ done()
429
+ },
430
+ this.connection,
431
+ params,
432
+ )
338
433
  })
339
434
 
340
435
  it('AUTH PLAIN, authenticating', (done) => {
341
- this.connection.notes.allowed_auth_methods = ['PLAIN','LOGIN'];
342
- this.connection.notes.authenticating=true;
343
- this.connection.notes.auth_method='PLAIN';
344
- this.plugin.hook_unrecognized_command((code) => {
345
- assert.equal(code, OK);
346
- assert.ok(this.connection.relaying);
347
- done();
348
- }, this.connection, [utils.base64('discard\0test\0testpass')]);
436
+ this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
437
+ this.connection.notes.authenticating = true
438
+ this.connection.notes.auth_method = 'PLAIN'
439
+ this.plugin.hook_unrecognized_command(
440
+ (code) => {
441
+ assert.equal(code, OK)
442
+ assert.ok(this.connection.relaying)
443
+ done()
444
+ },
445
+ this.connection,
446
+ [utils.base64('discard\0test\0testpass')],
447
+ )
349
448
  })
350
449
  })
351
450
 
@@ -353,83 +452,122 @@ describe('auth_base', () => {
353
452
  beforeEach(_set_up)
354
453
 
355
454
  it('AUTH LOGIN', (done) => {
356
- const params = ['AUTH','LOGIN'];
357
- this.connection.notes.allowed_auth_methods = ['PLAIN','LOGIN'];
358
- this.plugin.hook_unrecognized_command((code) => {
359
- assert.equal(code, OK);
360
- assert.equal(this.connection.relaying, false);
361
- assert.equal(this.connection.notes.auth_login_asked_login , true);
362
-
363
- this.plugin.hook_unrecognized_command((code) => {
364
- assert.equal(code, OK);
365
- assert.equal(this.connection.notes.auth_login_userlogin, 'test');
366
- assert.equal(this.connection.relaying, false);
367
- this.plugin.hook_unrecognized_command((code) => {
368
- assert.equal(code, OK);
369
- assert.equal(this.connection.relaying, true);
370
- done();
371
- }, this.connection, [utils.base64('testpass')]);
372
- }, this.connection, [utils.base64('test')]);
373
- }, this.connection, params);
455
+ const params = ['AUTH', 'LOGIN']
456
+ this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
457
+ this.plugin.hook_unrecognized_command(
458
+ (code) => {
459
+ assert.equal(code, OK)
460
+ assert.equal(this.connection.relaying, false)
461
+ assert.equal(this.connection.notes.auth_login_asked_login, true)
462
+
463
+ this.plugin.hook_unrecognized_command(
464
+ (code) => {
465
+ assert.equal(code, OK)
466
+ assert.equal(this.connection.notes.auth_login_userlogin, 'test')
467
+ assert.equal(this.connection.relaying, false)
468
+ this.plugin.hook_unrecognized_command(
469
+ (code) => {
470
+ assert.equal(code, OK)
471
+ assert.equal(this.connection.relaying, true)
472
+ done()
473
+ },
474
+ this.connection,
475
+ [utils.base64('testpass')],
476
+ )
477
+ },
478
+ this.connection,
479
+ [utils.base64('test')],
480
+ )
481
+ },
482
+ this.connection,
483
+ params,
484
+ )
374
485
  })
375
486
 
376
487
  it('AUTH LOGIN <username>', (done) => {
377
- const params = ['AUTH','LOGIN', utils.base64('test')];
378
- this.connection.notes.allowed_auth_methods = ['PLAIN','LOGIN'];
379
- this.plugin.hook_unrecognized_command((code) => {
380
- assert.equal(code, OK);
381
- assert.equal(this.connection.relaying, false);
382
- assert.equal(this.connection.notes.auth_login_userlogin, 'test');
383
- assert.equal(this.connection.notes.auth_login_asked_login , true);
384
-
385
- this.plugin.hook_unrecognized_command((code2) => {
386
- assert.equal(code2, OK);
387
- assert.equal(this.connection.relaying, true);
388
- done();
389
- }, this.connection, [utils.base64('testpass')]);
390
- }, this.connection, params);
488
+ const params = ['AUTH', 'LOGIN', utils.base64('test')]
489
+ this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
490
+ this.plugin.hook_unrecognized_command(
491
+ (code) => {
492
+ assert.equal(code, OK)
493
+ assert.equal(this.connection.relaying, false)
494
+ assert.equal(this.connection.notes.auth_login_userlogin, 'test')
495
+ assert.equal(this.connection.notes.auth_login_asked_login, true)
496
+
497
+ this.plugin.hook_unrecognized_command(
498
+ (code2) => {
499
+ assert.equal(code2, OK)
500
+ assert.equal(this.connection.relaying, true)
501
+ done()
502
+ },
503
+ this.connection,
504
+ [utils.base64('testpass')],
505
+ )
506
+ },
507
+ this.connection,
508
+ params,
509
+ )
391
510
  })
392
511
 
393
512
  it('AUTH LOGIN <username>, bad protocol', (done) => {
394
-
395
- const params = ['AUTH','LOGIN', utils.base64('test')];
396
- this.connection.notes.allowed_auth_methods = ['PLAIN','LOGIN'];
397
- this.plugin.hook_unrecognized_command((code) => {
398
- assert.equal(code, OK);
399
- assert.equal(this.connection.relaying, false);
400
- assert.equal(this.connection.notes.auth_login_userlogin, 'test');
401
- assert.equal(this.connection.notes.auth_login_asked_login , true);
402
-
403
- this.plugin.hook_unrecognized_command((code, msg) => {
404
- assert.equal(code, DENYDISCONNECT);
405
- assert.equal(msg, 'bad protocol');
406
- assert.equal(this.connection.relaying, false);
407
- done();
408
- }, this.connection, ['AUTH', 'LOGIN']);
409
- }, this.connection, params);
513
+ const params = ['AUTH', 'LOGIN', utils.base64('test')]
514
+ this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
515
+ this.plugin.hook_unrecognized_command(
516
+ (code) => {
517
+ assert.equal(code, OK)
518
+ assert.equal(this.connection.relaying, false)
519
+ assert.equal(this.connection.notes.auth_login_userlogin, 'test')
520
+ assert.equal(this.connection.notes.auth_login_asked_login, true)
521
+
522
+ this.plugin.hook_unrecognized_command(
523
+ (code, msg) => {
524
+ assert.equal(code, DENYDISCONNECT)
525
+ assert.equal(msg, 'bad protocol')
526
+ assert.equal(this.connection.relaying, false)
527
+ done()
528
+ },
529
+ this.connection,
530
+ ['AUTH', 'LOGIN'],
531
+ )
532
+ },
533
+ this.connection,
534
+ params,
535
+ )
410
536
  })
411
537
 
412
538
  it('AUTH LOGIN, reauthentication', (done) => {
413
- const params = ['AUTH','LOGIN', utils.base64('test')];
414
- this.connection.notes.allowed_auth_methods = ['PLAIN','LOGIN'];
415
- this.plugin.hook_unrecognized_command((code) => {
416
- assert.equal(code, OK);
417
- assert.equal(this.connection.relaying, false);
418
- assert.equal(this.connection.notes.auth_login_userlogin, 'test');
419
- assert.equal(this.connection.notes.auth_login_asked_login , true);
420
-
421
- this.plugin.hook_unrecognized_command((code) => {
422
- assert.equal(code, OK);
423
- assert.equal(this.connection.relaying, true);
424
- assert.equal(this.connection.notes.auth_login_userlogin, null);
425
- assert.equal(this.connection.notes.auth_login_asked_login , false);
426
-
427
- this.plugin.hook_unrecognized_command((code) => {
428
- assert.equal(code, OK);
429
- done();
430
- }, this.connection, ['AUTH','LOGIN']);
431
- }, this.connection, [utils.base64('testpass')]);
432
- }, this.connection, params);
539
+ const params = ['AUTH', 'LOGIN', utils.base64('test')]
540
+ this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
541
+ this.plugin.hook_unrecognized_command(
542
+ (code) => {
543
+ assert.equal(code, OK)
544
+ assert.equal(this.connection.relaying, false)
545
+ assert.equal(this.connection.notes.auth_login_userlogin, 'test')
546
+ assert.equal(this.connection.notes.auth_login_asked_login, true)
547
+
548
+ this.plugin.hook_unrecognized_command(
549
+ (code) => {
550
+ assert.equal(code, OK)
551
+ assert.equal(this.connection.relaying, true)
552
+ assert.equal(this.connection.notes.auth_login_userlogin, null)
553
+ assert.equal(this.connection.notes.auth_login_asked_login, false)
554
+
555
+ this.plugin.hook_unrecognized_command(
556
+ (code) => {
557
+ assert.equal(code, OK)
558
+ done()
559
+ },
560
+ this.connection,
561
+ ['AUTH', 'LOGIN'],
562
+ )
563
+ },
564
+ this.connection,
565
+ [utils.base64('testpass')],
566
+ )
567
+ },
568
+ this.connection,
569
+ params,
570
+ )
433
571
  })
434
572
  })
435
573
 
@@ -437,8 +575,8 @@ describe('auth_base', () => {
437
575
  beforeEach(_set_up)
438
576
 
439
577
  it('hexi', () => {
440
- assert.equal(this.plugin.hexi(512), 200);
441
- assert.equal(this.plugin.hexi(8), 8);
578
+ assert.equal(this.plugin.hexi(512), 200)
579
+ assert.equal(this.plugin.hexi(8), 8)
442
580
  })
443
581
  })
444
582
 
@@ -447,10 +585,11 @@ describe('auth_base', () => {
447
585
 
448
586
  it('constrain_sender, domain match', (done) => {
449
587
  this.mfrom = new Address('user@example.com')
450
- this.connection.results.add({name: 'auth'}, { user: 'user@example.com' })
451
- this.plugin.constrain_sender((resCode) => {
588
+ this.connection.results.add({ name: 'auth' }, { user: 'user@example.com' })
589
+ this.plugin.constrain_sender(
590
+ (resCode) => {
452
591
  assert.equal(resCode, undefined)
453
- done();
592
+ done()
454
593
  },
455
594
  this.connection,
456
595
  [this.mfrom],
@@ -459,11 +598,12 @@ describe('auth_base', () => {
459
598
 
460
599
  it('constrain_sender, domain mismatch', (done) => {
461
600
  this.mfrom = new Address('user@example.net')
462
- this.connection.results.add({name: 'auth'}, { user: 'user@example.com' })
463
- this.plugin.constrain_sender((resCode, denyMsg) => {
601
+ this.connection.results.add({ name: 'auth' }, { user: 'user@example.com' })
602
+ this.plugin.constrain_sender(
603
+ (resCode, denyMsg) => {
464
604
  assert.equal(resCode, DENY)
465
605
  assert.ok(denyMsg)
466
- done();
606
+ done()
467
607
  },
468
608
  this.connection,
469
609
  [this.mfrom],
@@ -471,10 +611,11 @@ describe('auth_base', () => {
471
611
  })
472
612
  it('constrain_sender, no domain', (done) => {
473
613
  this.mfrom = new Address('user@example.com')
474
- this.connection.results.add({name: 'auth'}, { user: 'user' })
475
- this.plugin.constrain_sender((resCode) => {
614
+ this.connection.results.add({ name: 'auth' }, { user: 'user' })
615
+ this.plugin.constrain_sender(
616
+ (resCode) => {
476
617
  assert.equal(resCode, undefined)
477
- done();
618
+ done()
478
619
  },
479
620
  this.connection,
480
621
  [this.mfrom],