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.
@@ -1,11 +1,12 @@
1
1
  'use strict'
2
2
  const assert = require('node:assert')
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
  const utils = require('haraka-utils')
7
8
 
8
- const _set_up = (done) => {
9
+ const _set_up = () => {
9
10
  this.plugin = new fixtures.plugin('auth/auth_base')
10
11
 
11
12
  this.plugin.get_plain_passwd = (user, cb) => {
@@ -15,11 +16,9 @@ const _set_up = (done) => {
15
16
 
16
17
  this.connection = fixtures.connection.createConnection()
17
18
  this.connection.capabilities = null
18
-
19
- done()
20
19
  }
21
20
 
22
- const _set_up_2 = (done) => {
21
+ const _set_up_2 = () => {
23
22
  this.plugin = new fixtures.plugin('auth/auth_base')
24
23
 
25
24
  this.plugin.get_plain_passwd = (user, connection, cb) => {
@@ -30,11 +29,9 @@ const _set_up_2 = (done) => {
30
29
 
31
30
  this.connection = fixtures.connection.createConnection()
32
31
  this.connection.capabilities = null
33
-
34
- done()
35
32
  }
36
33
 
37
- const _set_up_custom_pwcb_opts = (done) => {
34
+ const _set_up_custom_pwcb_opts = () => {
38
35
  this.plugin = new fixtures.plugin('auth/auth_base')
39
36
 
40
37
  this.plugin.check_plain_passwd = (connection, user, passwd, pwok_cb) => {
@@ -63,15 +60,13 @@ const _set_up_custom_pwcb_opts = (done) => {
63
60
  this.connection.notes.resp_strings.push([code, msg])
64
61
  return cb()
65
62
  }
66
-
67
- done()
68
63
  }
69
64
 
70
65
  describe('auth_base', () => {
71
66
  describe('hook_capabilities', () => {
72
67
  beforeEach(_set_up)
73
68
 
74
- it('no TLS, no auth', (done) => {
69
+ it('no TLS, no auth', (t, done) => {
75
70
  this.plugin.hook_capabilities((rc, msg) => {
76
71
  assert.equal(undefined, rc)
77
72
  assert.equal(undefined, msg)
@@ -80,7 +75,7 @@ describe('auth_base', () => {
80
75
  }, this.connection)
81
76
  })
82
77
 
83
- it('with TLS, auth is offered', (done) => {
78
+ it('with TLS, auth is offered', (t, done) => {
84
79
  this.connection.tls.enabled = true
85
80
  this.connection.capabilities = []
86
81
  this.plugin.hook_capabilities((rc, msg) => {
@@ -97,13 +92,13 @@ describe('auth_base', () => {
97
92
  describe('get_plain_passwd', () => {
98
93
  beforeEach(_set_up)
99
94
 
100
- it('get_plain_passwd, no result', (done) => {
95
+ it('get_plain_passwd, no result', (t, done) => {
101
96
  this.plugin.get_plain_passwd('user', (pass) => {
102
97
  assert.equal(pass, null)
103
98
  done()
104
99
  })
105
100
  })
106
- it('get_plain_passwd, test user', (done) => {
101
+ it('get_plain_passwd, test user', (t, done) => {
107
102
  this.plugin.get_plain_passwd('test', (pass) => {
108
103
  assert.equal(pass, 'testpass')
109
104
  done()
@@ -114,21 +109,21 @@ describe('auth_base', () => {
114
109
  describe('check_plain_passwd', () => {
115
110
  beforeEach(_set_up)
116
111
 
117
- it('valid password', (done) => {
112
+ it('valid password', (t, done) => {
118
113
  this.plugin.check_plain_passwd(this.connection, 'test', 'testpass', (pass) => {
119
114
  assert.equal(pass, true)
120
115
  done()
121
116
  })
122
117
  })
123
118
 
124
- it('wrong password', (done) => {
119
+ it('wrong password', (t, done) => {
125
120
  this.plugin.check_plain_passwd(this.connection, 'test', 'test1pass', (pass) => {
126
121
  assert.equal(pass, false)
127
122
  done()
128
123
  })
129
124
  })
130
125
 
131
- it('null password', (done) => {
126
+ it('null password', (t, done) => {
132
127
  this.plugin.check_plain_passwd(this.connection, 'test', null, (pass) => {
133
128
  assert.equal(pass, false)
134
129
  done()
@@ -139,7 +134,7 @@ describe('auth_base', () => {
139
134
  describe('select_auth_method', () => {
140
135
  beforeEach(_set_up)
141
136
 
142
- it('no auth methods yield no result', (done) => {
137
+ it('no auth methods yield no result', (t, done) => {
143
138
  this.plugin.select_auth_method(
144
139
  (code) => {
145
140
  assert.equal(code, null)
@@ -151,7 +146,7 @@ describe('auth_base', () => {
151
146
  )
152
147
  })
153
148
 
154
- it('invalid AUTH method, no result', (done) => {
149
+ it('invalid AUTH method, no result', (t, done) => {
155
150
  this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN', 'CRAM-MD5']
156
151
  this.plugin.select_auth_method(
157
152
  (code) => {
@@ -164,7 +159,7 @@ describe('auth_base', () => {
164
159
  )
165
160
  })
166
161
 
167
- it('valid AUTH method, valid attempt', (done) => {
162
+ it('valid AUTH method, valid attempt', (t, done) => {
168
163
  const method = `PLAIN ${utils.base64('discard\0test\0testpass')}`
169
164
  this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
170
165
  this.plugin.select_auth_method(
@@ -182,7 +177,7 @@ describe('auth_base', () => {
182
177
  describe('auth_plain', () => {
183
178
  beforeEach(_set_up)
184
179
 
185
- it('params type=string returns OK', (done) => {
180
+ it('params type=string returns OK', (t, done) => {
186
181
  this.plugin.auth_plain(
187
182
  (rc) => {
188
183
  assert.equal(rc, OK)
@@ -194,7 +189,7 @@ describe('auth_base', () => {
194
189
  )
195
190
  })
196
191
 
197
- it('params type=empty array, returns OK', (done) => {
192
+ it('params type=empty array, returns OK', (t, done) => {
198
193
  this.plugin.auth_plain(
199
194
  (rc) => {
200
195
  assert.equal(rc, OK)
@@ -206,7 +201,7 @@ describe('auth_base', () => {
206
201
  )
207
202
  })
208
203
 
209
- it('params type=array, successful auth', (done) => {
204
+ it('params type=array, successful auth', (t, done) => {
210
205
  const method = utils.base64('discard\0test\0testpass')
211
206
  this.plugin.auth_plain(
212
207
  (rc) => {
@@ -219,7 +214,7 @@ describe('auth_base', () => {
219
214
  )
220
215
  })
221
216
 
222
- it('params type=with two line login', (done) => {
217
+ it('params type=with two line login', (t, done) => {
223
218
  this.plugin.auth_plain(
224
219
  (rc) => {
225
220
  assert.equal(this.connection.notes.auth_plain_asked_login, true)
@@ -235,7 +230,7 @@ describe('auth_base', () => {
235
230
  describe('check_user', () => {
236
231
  beforeEach(_set_up_2)
237
232
 
238
- it('bad auth', (done) => {
233
+ it('bad auth', (t, done) => {
239
234
  const credentials = ['matt', 'ttam']
240
235
  this.plugin.check_user(
241
236
  (code) => {
@@ -250,7 +245,7 @@ describe('auth_base', () => {
250
245
  )
251
246
  })
252
247
 
253
- it('good auth', (done) => {
248
+ it('good auth', (t, done) => {
254
249
  const credentials = ['test', 'testpass']
255
250
  this.plugin.check_user(
256
251
  (code) => {
@@ -269,7 +264,7 @@ describe('auth_base', () => {
269
264
  describe('check_user_custom_opts', () => {
270
265
  beforeEach(_set_up_custom_pwcb_opts)
271
266
 
272
- it('legacyok_nomessage', (done) => {
267
+ it('legacyok_nomessage', (t, done) => {
273
268
  this.plugin.check_user(
274
269
  (code, msg) => {
275
270
  assert.equal(code, OK)
@@ -283,7 +278,7 @@ describe('auth_base', () => {
283
278
  )
284
279
  })
285
280
 
286
- it('legacyfail_nomessage', (done) => {
281
+ it('legacyfail_nomessage', (t, done) => {
287
282
  this.plugin.check_user(
288
283
  (code, msg) => {
289
284
  assert.equal(code, OK)
@@ -297,7 +292,7 @@ describe('auth_base', () => {
297
292
  )
298
293
  })
299
294
 
300
- it('legacyok_message', (done) => {
295
+ it('legacyok_message', (t, done) => {
301
296
  this.plugin.check_user(
302
297
  (code, msg) => {
303
298
  assert.equal(code, OK)
@@ -311,7 +306,7 @@ describe('auth_base', () => {
311
306
  )
312
307
  })
313
308
 
314
- it('legacyfail_message', (done) => {
309
+ it('legacyfail_message', (t, done) => {
315
310
  this.plugin.check_user(
316
311
  (code, msg) => {
317
312
  assert.equal(code, OK)
@@ -325,7 +320,7 @@ describe('auth_base', () => {
325
320
  )
326
321
  })
327
322
 
328
- it('newok', (done) => {
323
+ it('newok', (t, done) => {
329
324
  this.plugin.check_user(
330
325
  (code, msg) => {
331
326
  assert.equal(code, OK)
@@ -339,7 +334,7 @@ describe('auth_base', () => {
339
334
  )
340
335
  })
341
336
 
342
- it('newfail', (done) => {
337
+ it('newfail', (t, done) => {
343
338
  this.plugin.check_user(
344
339
  (code, msg) => {
345
340
  assert.equal(code, OK)
@@ -357,7 +352,7 @@ describe('auth_base', () => {
357
352
  describe('auth_notes_are_set', () => {
358
353
  beforeEach(_set_up_2)
359
354
 
360
- it('bad auth: no notes should be set', (done) => {
355
+ it('bad auth: no notes should be set', (t, done) => {
361
356
  const credentials = ['matt', 'ttam']
362
357
  this.plugin.check_user(
363
358
  (code) => {
@@ -371,7 +366,7 @@ describe('auth_base', () => {
371
366
  )
372
367
  })
373
368
 
374
- it('good auth: dont store password', (done) => {
369
+ it('good auth: dont store password', (t, done) => {
375
370
  const creds = ['test', 'testpass']
376
371
  this.plugin.blankout_password = true
377
372
  this.plugin.check_user(
@@ -386,7 +381,7 @@ describe('auth_base', () => {
386
381
  )
387
382
  })
388
383
 
389
- it('good auth: store password (default)', (done) => {
384
+ it('good auth: store password (default)', (t, done) => {
390
385
  const creds = ['test', 'testpass']
391
386
  this.plugin.check_user(
392
387
  (code) => {
@@ -404,7 +399,7 @@ describe('auth_base', () => {
404
399
  describe('hook_unrecognized_command', () => {
405
400
  beforeEach(_set_up)
406
401
 
407
- it('AUTH type FOO', (done) => {
402
+ it('AUTH type FOO', (t, done) => {
408
403
  const params = ['AUTH', 'FOO']
409
404
  this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
410
405
  this.plugin.hook_unrecognized_command(
@@ -418,7 +413,7 @@ describe('auth_base', () => {
418
413
  )
419
414
  })
420
415
 
421
- it('AUTH PLAIN', (done) => {
416
+ it('AUTH PLAIN', (t, done) => {
422
417
  const params = ['AUTH', 'PLAIN', utils.base64('discard\0test\0testpass')]
423
418
  this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
424
419
  this.plugin.hook_unrecognized_command(
@@ -432,7 +427,7 @@ describe('auth_base', () => {
432
427
  )
433
428
  })
434
429
 
435
- it('AUTH PLAIN, authenticating', (done) => {
430
+ it('AUTH PLAIN, authenticating', (t, done) => {
436
431
  this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
437
432
  this.connection.notes.authenticating = true
438
433
  this.connection.notes.auth_method = 'PLAIN'
@@ -451,7 +446,7 @@ describe('auth_base', () => {
451
446
  describe('auth_login', () => {
452
447
  beforeEach(_set_up)
453
448
 
454
- it('AUTH LOGIN', (done) => {
449
+ it('AUTH LOGIN', (t, done) => {
455
450
  const params = ['AUTH', 'LOGIN']
456
451
  this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
457
452
  this.plugin.hook_unrecognized_command(
@@ -484,7 +479,7 @@ describe('auth_base', () => {
484
479
  )
485
480
  })
486
481
 
487
- it('AUTH LOGIN <username>', (done) => {
482
+ it('AUTH LOGIN <username>', (t, done) => {
488
483
  const params = ['AUTH', 'LOGIN', utils.base64('test')]
489
484
  this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
490
485
  this.plugin.hook_unrecognized_command(
@@ -509,7 +504,7 @@ describe('auth_base', () => {
509
504
  )
510
505
  })
511
506
 
512
- it('AUTH LOGIN <username>, bad protocol', (done) => {
507
+ it('AUTH LOGIN <username>, bad protocol', (t, done) => {
513
508
  const params = ['AUTH', 'LOGIN', utils.base64('test')]
514
509
  this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
515
510
  this.plugin.hook_unrecognized_command(
@@ -535,7 +530,7 @@ describe('auth_base', () => {
535
530
  )
536
531
  })
537
532
 
538
- it('AUTH LOGIN, reauthentication', (done) => {
533
+ it('AUTH LOGIN, reauthentication', (t, done) => {
539
534
  const params = ['AUTH', 'LOGIN', utils.base64('test')]
540
535
  this.connection.notes.allowed_auth_methods = ['PLAIN', 'LOGIN']
541
536
  this.plugin.hook_unrecognized_command(
@@ -583,7 +578,7 @@ describe('auth_base', () => {
583
578
  describe('constrain_sender', () => {
584
579
  beforeEach(_set_up)
585
580
 
586
- it('constrain_sender, domain match', (done) => {
581
+ it('constrain_sender, domain match', (t, done) => {
587
582
  this.mfrom = new Address('user@example.com')
588
583
  this.connection.results.add({ name: 'auth' }, { user: 'user@example.com' })
589
584
  this.plugin.constrain_sender(
@@ -596,7 +591,7 @@ describe('auth_base', () => {
596
591
  )
597
592
  })
598
593
 
599
- it('constrain_sender, domain mismatch', (done) => {
594
+ it('constrain_sender, domain mismatch', (t, done) => {
600
595
  this.mfrom = new Address('user@example.net')
601
596
  this.connection.results.add({ name: 'auth' }, { user: 'user@example.com' })
602
597
  this.plugin.constrain_sender(
@@ -609,7 +604,7 @@ describe('auth_base', () => {
609
604
  [this.mfrom],
610
605
  )
611
606
  })
612
- it('constrain_sender, no domain', (done) => {
607
+ it('constrain_sender, no domain', (t, done) => {
613
608
  this.mfrom = new Address('user@example.com')
614
609
  this.connection.results.add({ name: 'auth' }, { user: 'user' })
615
610
  this.plugin.constrain_sender(
@@ -1,11 +1,12 @@
1
1
  'use strict'
2
2
 
3
- const assert = require('node:assert')
3
+ const assert = require('node:assert/strict')
4
4
  const path = require('node:path')
5
+ const { describe, it, beforeEach } = require('node:test')
5
6
 
6
7
  const fixtures = require('haraka-test-fixtures')
7
8
 
8
- const _set_up = (done) => {
9
+ const _set_up = () => {
9
10
  this.backup = {}
10
11
 
11
12
  this.plugin = new fixtures.plugin('auth/auth_vpopmaild')
@@ -17,14 +18,12 @@ const _set_up = (done) => {
17
18
 
18
19
  this.connection = fixtures.connection.createConnection()
19
20
  this.connection.capabilities = null
20
-
21
- done()
22
21
  }
23
22
 
24
23
  describe('hook_capabilities', () => {
25
24
  beforeEach(_set_up)
26
25
 
27
- it('no TLS', (done) => {
26
+ it('no TLS', (t, done) => {
28
27
  this.plugin.hook_capabilities((rc, msg) => {
29
28
  assert.equal(undefined, rc)
30
29
  assert.equal(undefined, msg)
@@ -33,7 +32,7 @@ describe('hook_capabilities', () => {
33
32
  }, this.connection)
34
33
  })
35
34
 
36
- it('with TLS', (done) => {
35
+ it('with TLS', (t, done) => {
37
36
  this.connection.tls.enabled = true
38
37
  this.connection.capabilities = []
39
38
  this.plugin.hook_capabilities((rc, msg) => {
@@ -44,7 +43,7 @@ describe('hook_capabilities', () => {
44
43
  }, this.connection)
45
44
  })
46
45
 
47
- it('with TLS, sysadmin', (done) => {
46
+ it('with TLS, sysadmin', (t, done) => {
48
47
  this.connection.tls.enabled = true
49
48
  this.connection.capabilities = []
50
49
  this.plugin.hook_capabilities((rc, msg) => {
@@ -62,14 +61,14 @@ describe('get_vpopmaild_socket', () => {
62
61
  it('any', () => {
63
62
  const socket = this.plugin.get_vpopmaild_socket('foo@localhost.com')
64
63
  assert.ok(socket)
65
- socket.end()
64
+ socket.destroy()
66
65
  })
67
66
  })
68
67
 
69
68
  describe('get_plain_passwd', () => {
70
69
  beforeEach(_set_up)
71
70
 
72
- it('matt@example.com', (done) => {
71
+ it('matt@example.com', (t, done) => {
73
72
  if (this.plugin.cfg['example.com'].sysadmin) {
74
73
  this.plugin.get_plain_passwd('matt@example.com', (pass) => {
75
74
  assert.ok(pass)