Haraka 3.1.1 → 3.1.3

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 (168) hide show
  1. package/.prettierignore +4 -0
  2. package/CONTRIBUTORS.md +5 -5
  3. package/Changes.md +72 -50
  4. package/Plugins.md +3 -1
  5. package/README.md +1 -1
  6. package/bin/haraka +475 -479
  7. package/config/connection.ini +10 -0
  8. package/config/outbound.ini +3 -0
  9. package/config/smtp.ini +0 -9
  10. package/connection.js +1072 -1108
  11. package/docs/Connection.md +29 -30
  12. package/docs/CoreConfig.md +38 -40
  13. package/docs/CustomReturnCodes.md +0 -1
  14. package/docs/HAProxy.md +2 -2
  15. package/docs/Header.md +1 -1
  16. package/docs/Logging.md +29 -5
  17. package/docs/Outbound.md +93 -78
  18. package/docs/Plugins.md +103 -108
  19. package/docs/Transaction.md +49 -51
  20. package/docs/Tutorial.md +127 -143
  21. package/docs/deprecated/access.md +0 -1
  22. package/docs/deprecated/backscatterer.md +2 -3
  23. package/docs/deprecated/connect.rdns_access.md +18 -27
  24. package/docs/deprecated/data.headers.md +0 -1
  25. package/docs/deprecated/data.nomsgid.md +1 -2
  26. package/docs/deprecated/data.noreceived.md +1 -2
  27. package/docs/deprecated/data.rfc5322_header_checks.md +1 -2
  28. package/docs/deprecated/dkim_sign.md +13 -17
  29. package/docs/deprecated/dkim_verify.md +9 -17
  30. package/docs/deprecated/dnsbl.md +36 -38
  31. package/docs/deprecated/dnswl.md +41 -43
  32. package/docs/deprecated/lookup_rdns.strict.md +21 -34
  33. package/docs/deprecated/mail_from.access.md +17 -25
  34. package/docs/deprecated/mail_from.blocklist.md +9 -12
  35. package/docs/deprecated/mail_from.nobounces.md +1 -2
  36. package/docs/deprecated/rcpt_to.access.md +20 -27
  37. package/docs/deprecated/rcpt_to.blocklist.md +10 -13
  38. package/docs/deprecated/rcpt_to.routes.md +0 -1
  39. package/docs/deprecated/rdns.regexp.md +13 -15
  40. package/docs/plugins/aliases.md +89 -89
  41. package/docs/plugins/auth/auth_bridge.md +5 -7
  42. package/docs/plugins/auth/auth_ldap.md +11 -14
  43. package/docs/plugins/auth/auth_proxy.md +10 -12
  44. package/docs/plugins/auth/auth_vpopmaild.md +5 -6
  45. package/docs/plugins/auth/flat_file.md +4 -4
  46. package/docs/plugins/block_me.md +3 -3
  47. package/docs/plugins/data.signatures.md +1 -2
  48. package/docs/plugins/delay_deny.md +3 -4
  49. package/docs/plugins/max_unrecognized_commands.md +4 -4
  50. package/docs/plugins/prevent_credential_leaks.md +6 -6
  51. package/docs/plugins/process_title.md +18 -18
  52. package/docs/plugins/queue/deliver.md +2 -3
  53. package/docs/plugins/queue/discard.md +4 -4
  54. package/docs/plugins/queue/lmtp.md +1 -3
  55. package/docs/plugins/queue/qmail-queue.md +7 -9
  56. package/docs/plugins/queue/quarantine.md +16 -21
  57. package/docs/plugins/queue/rabbitmq.md +8 -11
  58. package/docs/plugins/queue/rabbitmq_amqplib.md +43 -39
  59. package/docs/plugins/queue/smtp_bridge.md +7 -10
  60. package/docs/plugins/queue/smtp_forward.md +42 -34
  61. package/docs/plugins/queue/smtp_proxy.md +30 -29
  62. package/docs/plugins/queue/test.md +1 -3
  63. package/docs/plugins/rcpt_to.in_host_list.md +6 -6
  64. package/docs/plugins/rcpt_to.max_count.md +1 -1
  65. package/docs/plugins/record_envelope_addresses.md +3 -3
  66. package/docs/plugins/reseed_rng.md +6 -6
  67. package/docs/plugins/status.md +9 -8
  68. package/docs/plugins/tarpit.md +7 -11
  69. package/docs/plugins/tls.md +12 -17
  70. package/docs/plugins/toobusy.md +4 -4
  71. package/docs/plugins/xclient.md +3 -3
  72. package/docs/tutorials/Migrating_from_v1_to_v2.md +19 -41
  73. package/docs/tutorials/SettingUpOutbound.md +6 -9
  74. package/endpoint.js +35 -38
  75. package/eslint.config.mjs +22 -19
  76. package/haraka.js +42 -47
  77. package/host_pool.js +75 -79
  78. package/http/html/404.html +45 -49
  79. package/http/html/index.html +39 -28
  80. package/http/package.json +2 -4
  81. package/line_socket.js +27 -28
  82. package/logger.js +182 -201
  83. package/outbound/client_pool.js +33 -33
  84. package/outbound/config.js +64 -59
  85. package/outbound/fsync_writestream.js +24 -25
  86. package/outbound/hmail.js +888 -835
  87. package/outbound/index.js +194 -187
  88. package/outbound/qfile.js +49 -52
  89. package/outbound/queue.js +197 -190
  90. package/outbound/timer_queue.js +41 -43
  91. package/outbound/tls.js +68 -61
  92. package/outbound/todo.js +11 -11
  93. package/package.json +35 -36
  94. package/plugins/.eslintrc.yaml +0 -1
  95. package/plugins/auth/auth_base.js +123 -127
  96. package/plugins/auth/auth_bridge.js +7 -7
  97. package/plugins/auth/auth_proxy.js +121 -126
  98. package/plugins/auth/auth_vpopmaild.js +84 -85
  99. package/plugins/auth/flat_file.js +18 -17
  100. package/plugins/block_me.js +31 -31
  101. package/plugins/data.signatures.js +13 -13
  102. package/plugins/delay_deny.js +65 -61
  103. package/plugins/prevent_credential_leaks.js +23 -23
  104. package/plugins/process_title.js +125 -128
  105. package/plugins/profile.js +5 -5
  106. package/plugins/queue/deliver.js +3 -3
  107. package/plugins/queue/discard.js +13 -14
  108. package/plugins/queue/lmtp.js +16 -17
  109. package/plugins/queue/qmail-queue.js +54 -55
  110. package/plugins/queue/quarantine.js +68 -70
  111. package/plugins/queue/rabbitmq.js +80 -87
  112. package/plugins/queue/rabbitmq_amqplib.js +75 -54
  113. package/plugins/queue/smtp_bridge.js +16 -16
  114. package/plugins/queue/smtp_forward.js +175 -179
  115. package/plugins/queue/smtp_proxy.js +69 -71
  116. package/plugins/queue/test.js +9 -9
  117. package/plugins/rcpt_to.host_list_base.js +30 -34
  118. package/plugins/rcpt_to.in_host_list.js +19 -19
  119. package/plugins/record_envelope_addresses.js +4 -4
  120. package/plugins/reseed_rng.js +4 -4
  121. package/plugins/status.js +90 -97
  122. package/plugins/tarpit.js +25 -14
  123. package/plugins/tls.js +68 -68
  124. package/plugins/toobusy.js +21 -23
  125. package/plugins/xclient.js +51 -53
  126. package/plugins.js +276 -293
  127. package/rfc1869.js +30 -35
  128. package/server.js +308 -299
  129. package/smtp_client.js +244 -228
  130. package/test/.eslintrc.yaml +0 -1
  131. package/test/connection.js +127 -134
  132. package/test/endpoint.js +53 -47
  133. package/test/fixtures/line_socket.js +12 -12
  134. package/test/fixtures/util_hmailitem.js +89 -85
  135. package/test/host_pool.js +90 -92
  136. package/test/installation/plugins/base_plugin.js +2 -2
  137. package/test/installation/plugins/folder_plugin/index.js +2 -3
  138. package/test/installation/plugins/inherits.js +3 -3
  139. package/test/installation/plugins/load_first.js +2 -3
  140. package/test/installation/plugins/plugin.js +1 -3
  141. package/test/installation/plugins/tls.js +2 -4
  142. package/test/logger.js +135 -116
  143. package/test/outbound/hmail.js +49 -35
  144. package/test/outbound/index.js +118 -101
  145. package/test/outbound/qfile.js +51 -53
  146. package/test/outbound_bounce_net_errors.js +84 -69
  147. package/test/outbound_bounce_rfc3464.js +235 -165
  148. package/test/plugins/auth/auth_base.js +420 -279
  149. package/test/plugins/auth/auth_vpopmaild.js +38 -39
  150. package/test/plugins/queue/smtp_forward.js +126 -104
  151. package/test/plugins/rcpt_to.host_list_base.js +85 -67
  152. package/test/plugins/rcpt_to.in_host_list.js +159 -112
  153. package/test/plugins/status.js +71 -64
  154. package/test/plugins/tls.js +37 -34
  155. package/test/plugins.js +97 -92
  156. package/test/rfc1869.js +19 -26
  157. package/test/server.js +293 -272
  158. package/test/smtp_client.js +180 -176
  159. package/test/tls_socket.js +62 -66
  160. package/test/transaction.js +159 -160
  161. package/tls_socket.js +331 -333
  162. package/transaction.js +129 -137
  163. package/config/me +0 -1
  164. package/config/tls_cert.pem +0 -23
  165. package/config/tls_key.pem +0 -28
  166. package/test/queue/multibyte +0 -0
  167. package/test/queue/plain +0 -0
  168. package/test/test-queue/delete-me +0 -0
@@ -1,60 +1,59 @@
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');
4
+ const { Address } = require('address-rfc2821')
5
+ const fixtures = require('haraka-test-fixtures')
6
6
 
7
7
  const _set_up = (done) => {
8
+ this.plugin = new fixtures.plugin('rcpt_to.in_host_list')
9
+ this.plugin.inherits('rcpt_to.host_list_base')
10
+ this.plugin.cfg = {}
11
+ this.plugin.host_list = {}
8
12
 
9
- this.plugin = new fixtures.plugin('rcpt_to.in_host_list');
10
- this.plugin.inherits('rcpt_to.host_list_base');
11
- this.plugin.cfg = {};
12
- this.plugin.host_list = {};
13
-
14
- this.connection = fixtures.connection.createConnection();
13
+ this.connection = fixtures.connection.createConnection()
15
14
  this.connection.transaction = {
16
15
  results: new fixtures.results(this.connection),
17
16
  notes: {},
18
- };
17
+ }
19
18
 
20
- done();
19
+ done()
21
20
  }
22
21
 
23
22
  describe('in_host_list', () => {
24
23
  beforeEach(_set_up)
25
24
 
26
25
  it('miss', () => {
27
- assert.equal(this.plugin.in_host_list('test.com'), false);
26
+ assert.equal(this.plugin.in_host_list('test.com'), false)
28
27
  })
29
28
 
30
29
  it('hit', () => {
31
- this.plugin.host_list['test.com'] = true;
32
- assert.equal(this.plugin.in_host_list('test.com'), true);
30
+ this.plugin.host_list['test.com'] = true
31
+ assert.equal(this.plugin.in_host_list('test.com'), true)
33
32
  })
34
33
 
35
34
  describe('in_host_regex', () => {
36
35
  beforeEach(_set_up)
37
36
 
38
37
  it('undef', () => {
39
- assert.equal(this.plugin.in_host_regex('test.com'), false);
38
+ assert.equal(this.plugin.in_host_regex('test.com'), false)
40
39
  })
41
40
 
42
41
  it('miss', () => {
43
- this.plugin.host_list_regex=['miss.com'];
44
- this.plugin.hl_re = new RegExp (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
45
- assert.equal(this.plugin.in_host_regex('test.com'), false);
42
+ this.plugin.host_list_regex = ['miss.com']
43
+ this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
44
+ assert.equal(this.plugin.in_host_regex('test.com'), false)
46
45
  })
47
46
 
48
47
  it('exact hit', () => {
49
- this.plugin.host_list_regex=['test.com'];
50
- this.plugin.hl_re = new RegExp (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
51
- assert.equal(this.plugin.in_host_regex('test.com'), true);
48
+ this.plugin.host_list_regex = ['test.com']
49
+ this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
50
+ assert.equal(this.plugin.in_host_regex('test.com'), true)
52
51
  })
53
52
 
54
53
  it('re hit', () => {
55
- this.plugin.host_list_regex=['.*est.com'];
56
- this.plugin.hl_re = new RegExp (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
57
- assert.equal(this.plugin.in_host_regex('test.com'), true);
54
+ this.plugin.host_list_regex = ['.*est.com']
55
+ this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
56
+ assert.equal(this.plugin.in_host_regex('test.com'), true)
58
57
  })
59
58
  })
60
59
 
@@ -62,59 +61,79 @@ describe('in_host_list', () => {
62
61
  beforeEach(_set_up)
63
62
 
64
63
  it('null sender', (done) => {
65
- this.connection.relaying=true;
66
- this.plugin.hook_mail((rc, msg) => {
67
- assert.equal(undefined, rc);
68
- assert.equal(undefined, msg);
69
- done();
70
- }, this.connection, [new Address('<>')]);
64
+ this.connection.relaying = true
65
+ this.plugin.hook_mail(
66
+ (rc, msg) => {
67
+ assert.equal(undefined, rc)
68
+ assert.equal(undefined, msg)
69
+ done()
70
+ },
71
+ this.connection,
72
+ [new Address('<>')],
73
+ )
71
74
  })
72
75
 
73
76
  it('miss', (done) => {
74
- this.plugin.host_list = { 'miss.com': true };
75
- this.plugin.hook_mail((rc, msg) => {
76
- assert.equal(undefined, rc);
77
- assert.equal(undefined, msg);
78
- const res = this.connection.transaction.results.get('rcpt_to.in_host_list');
79
- assert.notEqual(-1, res.msg.indexOf('mail_from!local'));
80
- done();
81
- }, this.connection, [new Address('<user@example.com>')]);
77
+ this.plugin.host_list = { 'miss.com': true }
78
+ this.plugin.hook_mail(
79
+ (rc, msg) => {
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
+ )
82
89
  })
83
90
 
84
91
  it('hit', (done) => {
85
- this.plugin.host_list = { 'example.com': true };
86
- this.plugin.hook_mail((rc, msg) => {
87
- assert.equal(undefined, rc);
88
- assert.equal(undefined, msg);
89
- const res = this.connection.transaction.results.get('rcpt_to.in_host_list');
90
- assert.notEqual(-1, res.pass.indexOf('mail_from'));
91
- done();
92
- }, this.connection, [new Address('<user@example.com>')]);
92
+ this.plugin.host_list = { 'example.com': true }
93
+ this.plugin.hook_mail(
94
+ (rc, msg) => {
95
+ assert.equal(undefined, rc)
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
+ )
93
104
  })
94
105
 
95
106
  it('hit, regex, exact', (done) => {
96
- this.plugin.host_list_regex = ['example.com'];
97
- this.plugin.hl_re = new RegExp (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
98
- this.plugin.hook_mail((rc, msg) => {
99
- assert.equal(undefined, rc);
100
- assert.equal(undefined, msg);
101
- const res = this.connection.transaction.results.get('rcpt_to.in_host_list');
102
- assert.notEqual(-1, res.pass.indexOf('mail_from'));
103
- done();
104
- }, this.connection, [new Address('<user@example.com>')]);
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
+ )
105
120
  })
106
121
 
107
122
  it('hit, regex, pattern', (done) => {
108
- this.plugin.host_list_regex = ['.*mple.com'];
109
- this.plugin.hl_re = new RegExp (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
110
- this.plugin.hook_mail((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
- // console.log(res);
115
- assert.notEqual(-1, res.pass.indexOf('mail_from'));
116
- done();
117
- }, this.connection, [new Address('<user@example.com>')]);
123
+ this.plugin.host_list_regex = ['.*mple.com']
124
+ this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
125
+ this.plugin.hook_mail(
126
+ (rc, msg) => {
127
+ assert.equal(undefined, rc)
128
+ assert.equal(undefined, msg)
129
+ const res = this.connection.transaction.results.get('rcpt_to.in_host_list')
130
+ // console.log(res);
131
+ assert.notEqual(-1, res.pass.indexOf('mail_from'))
132
+ done()
133
+ },
134
+ this.connection,
135
+ [new Address('<user@example.com>')],
136
+ )
118
137
  })
119
138
  })
120
139
 
@@ -123,71 +142,99 @@ describe('in_host_list', () => {
123
142
 
124
143
  it('missing txn', (done) => {
125
144
  // sometimes txn goes away, make sure it's handled
126
- delete this.connection.transaction;
127
- this.plugin.hook_rcpt((rc, msg) => {
128
- assert.equal(undefined, rc);
129
- assert.equal(undefined, msg);
130
- }, this.connection, [new Address('test@test.com')]);
131
- assert.ok(true);
132
- done();
145
+ delete this.connection.transaction
146
+ this.plugin.hook_rcpt(
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()
133
156
  })
134
157
 
135
158
  it('hit list', (done) => {
136
- this.plugin.host_list = { 'test.com': true };
137
- this.plugin.hook_rcpt((rc, msg) => {
138
- assert.equal(OK, rc);
139
- assert.equal(undefined, msg);
140
- done();
141
- }, this.connection, [new Address('test@test.com')]);
159
+ this.plugin.host_list = { 'test.com': true }
160
+ this.plugin.hook_rcpt(
161
+ (rc, msg) => {
162
+ assert.equal(OK, rc)
163
+ assert.equal(undefined, msg)
164
+ done()
165
+ },
166
+ this.connection,
167
+ [new Address('test@test.com')],
168
+ )
142
169
  })
143
170
 
144
171
  it('miss list', (done) => {
145
- this.plugin.host_list = { 'miss.com': true };
146
- this.plugin.hook_rcpt((rc, msg) => {
147
- assert.equal(undefined, rc);
148
- assert.equal(undefined, msg);
149
- done();
150
- }, this.connection, [new Address('test@test.com')]);
172
+ this.plugin.host_list = { 'miss.com': true }
173
+ this.plugin.hook_rcpt(
174
+ (rc, msg) => {
175
+ assert.equal(undefined, rc)
176
+ assert.equal(undefined, msg)
177
+ done()
178
+ },
179
+ this.connection,
180
+ [new Address('test@test.com')],
181
+ )
151
182
  })
152
183
 
153
184
  it('hit regex, exact', (done) => {
154
- this.plugin.host_list_regex=['test.com'];
155
- this.plugin.hl_re = new RegExp (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
156
- this.plugin.hook_rcpt((rc, msg) => {
157
- assert.equal(OK, rc);
158
- assert.equal(undefined, msg);
159
- done();
160
- }, this.connection, [new Address('test@test.com')]);
185
+ this.plugin.host_list_regex = ['test.com']
186
+ this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
187
+ this.plugin.hook_rcpt(
188
+ (rc, msg) => {
189
+ assert.equal(OK, rc)
190
+ assert.equal(undefined, msg)
191
+ done()
192
+ },
193
+ this.connection,
194
+ [new Address('test@test.com')],
195
+ )
161
196
  })
162
197
 
163
198
  it('hit regex, pattern', (done) => {
164
- this.plugin.host_list_regex=['.est.com'];
165
- this.plugin.hl_re = new RegExp (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
166
- this.plugin.hook_rcpt((rc, msg) => {
167
- assert.equal(OK, rc);
168
- assert.equal(undefined, msg);
169
- done();
170
- }, this.connection, [new Address('test@test.com')]);
199
+ this.plugin.host_list_regex = ['.est.com']
200
+ this.plugin.hl_re = new RegExp(`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i')
201
+ this.plugin.hook_rcpt(
202
+ (rc, msg) => {
203
+ assert.equal(OK, rc)
204
+ assert.equal(undefined, msg)
205
+ done()
206
+ },
207
+ this.connection,
208
+ [new Address('test@test.com')],
209
+ )
171
210
  })
172
211
 
173
212
  it('miss regex, pattern', (done) => {
174
- this.plugin.host_list_regex=['a.est.com'];
175
- this.plugin.hl_re = new RegExp (`^(?:${this.plugin.host_list_regex.join('|')})$`, 'i');
176
- this.plugin.hook_rcpt((rc, msg) => {
177
- assert.equal(undefined, rc);
178
- assert.equal(undefined, msg);
179
- done();
180
- }, this.connection, [new Address('test@test.com')]);
213
+ this.plugin.host_list_regex = ['a.est.com']
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()
220
+ },
221
+ this.connection,
222
+ [new Address('test@test.com')],
223
+ )
181
224
  })
182
225
 
183
226
  it('rcpt miss, relaying to local sender', (done) => {
184
- this.connection.relaying=true;
185
- this.connection.transaction.notes = { local_sender: true };
186
- this.plugin.hook_rcpt((rc, msg) => {
187
- assert.equal(OK, rc);
188
- assert.equal(undefined, msg);
189
- done();
190
- }, this.connection, [new Address('test@test.com')]);
227
+ this.connection.relaying = true
228
+ this.connection.transaction.notes = { local_sender: true }
229
+ this.plugin.hook_rcpt(
230
+ (rc, msg) => {
231
+ assert.equal(OK, rc)
232
+ assert.equal(undefined, msg)
233
+ done()
234
+ },
235
+ this.connection,
236
+ [new Address('test@test.com')],
237
+ )
191
238
  })
192
239
  })
193
240
  })
@@ -1,29 +1,28 @@
1
- 'use strict';
1
+ 'use strict'
2
2
 
3
3
  const assert = require('node:assert')
4
4
 
5
- const fixtures = require('haraka-test-fixtures');
6
- const outbound = require('../../outbound');
7
- const TimerQueue = require('../../outbound/timer_queue');
5
+ const fixtures = require('haraka-test-fixtures')
6
+ const outbound = require('../../outbound')
7
+ const TimerQueue = require('../../outbound/timer_queue')
8
8
 
9
- const Connection = fixtures.connection;
9
+ const Connection = fixtures.connection
10
10
 
11
11
  const _set_up = (done) => {
12
- this.plugin = new fixtures.plugin('status');
13
- this.plugin.outbound = outbound;
12
+ this.plugin = new fixtures.plugin('status')
13
+ this.plugin.outbound = outbound
14
14
 
15
- this.connection = Connection.createConnection();
16
- this.connection.remote.is_local = true;
17
- done();
15
+ this.connection = Connection.createConnection()
16
+ this.connection.remote.is_local = true
17
+ done()
18
18
  }
19
19
 
20
20
  describe('status', () => {
21
-
22
21
  describe('register', () => {
23
22
  beforeEach(_set_up)
24
23
 
25
24
  it('loads the status plugin', () => {
26
- assert.equal('status', this.plugin.name);
25
+ assert.equal('status', this.plugin.name)
27
26
  })
28
27
  })
29
28
 
@@ -31,11 +30,15 @@ describe('status', () => {
31
30
  beforeEach(_set_up)
32
31
 
33
32
  it('remote', (done) => {
34
- this.connection.remote.is_local = false;
35
- this.plugin.hook_unrecognized_command((code) => {
36
- assert.equal(DENY, code);
37
- done();
38
- }, this.connection, ['STATUS', 'POOL LIST']);
33
+ this.connection.remote.is_local = false
34
+ this.plugin.hook_unrecognized_command(
35
+ (code) => {
36
+ assert.equal(DENY, code)
37
+ done()
38
+ },
39
+ this.connection,
40
+ ['STATUS', 'POOL LIST'],
41
+ )
39
42
  })
40
43
  })
41
44
 
@@ -44,11 +47,11 @@ describe('status', () => {
44
47
 
45
48
  it('list_pools', (done) => {
46
49
  this.connection.respond = (code, message) => {
47
- const data = JSON.parse(message);
48
- assert.equal('object', typeof data); // there should be one pools array for noncluster and more for cluster
49
- done();
50
- };
51
- this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'POOL LIST']);
50
+ const data = JSON.parse(message)
51
+ assert.equal('object', typeof data) // there should be one pools array for noncluster and more for cluster
52
+ done()
53
+ }
54
+ this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'POOL LIST'])
52
55
  })
53
56
  })
54
57
 
@@ -57,74 +60,78 @@ describe('status', () => {
57
60
 
58
61
  it('inspect_queue', (done) => {
59
62
  // should list delivery_queue and temp_fail_queue per cluster children
60
- outbound.temp_fail_queue = new TimerQueue(10);
61
- outbound.temp_fail_queue.add('file1', 100, () => {});
62
- outbound.temp_fail_queue.add('file2', 100, () => {});
63
+ outbound.temp_fail_queue = new TimerQueue(10)
64
+ outbound.temp_fail_queue.add('file1', 100, () => {})
65
+ outbound.temp_fail_queue.add('file2', 100, () => {})
63
66
 
64
67
  this.connection.respond = (code, message) => {
65
- const data = JSON.parse(message);
66
- assert.equal(0, data.delivery_queue.length);
67
- assert.equal(2, data.temp_fail_queue.length);
68
- done();
69
- };
70
- this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE INSPECT']);
68
+ const data = JSON.parse(message)
69
+ assert.equal(0, data.delivery_queue.length)
70
+ assert.equal(2, data.temp_fail_queue.length)
71
+ done()
72
+ }
73
+ this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE INSPECT'])
71
74
  })
72
75
 
73
76
  it('stat_queue', (done) => {
74
77
  // should list files only
75
78
  this.connection.respond = (code, message) => {
76
- const data = JSON.parse(message);
77
- assert.ok(/^\d+\/\d+\/\d+$/.test(data));
78
- done();
79
- };
80
- this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE STATS']);
79
+ const data = JSON.parse(message)
80
+ assert.ok(/^\d+\/\d+\/\d+$/.test(data))
81
+ done()
82
+ }
83
+ this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE STATS'])
81
84
  })
82
85
 
83
86
  it('list_queue', (done) => {
84
87
  // should list files only
85
88
  this.connection.respond = (code, message) => {
86
- const data = JSON.parse(message);
87
- assert.equal(0, data.length);
88
- done();
89
- };
90
- this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE LIST']);
89
+ const data = JSON.parse(message)
90
+ assert.equal(0, data.length)
91
+ done()
92
+ }
93
+ this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE LIST'])
91
94
  })
92
95
 
93
96
  it('discard_from_queue', (done) => {
94
- const self = this;
97
+ const self = this
95
98
 
96
- outbound.temp_fail_queue = new TimerQueue(10);
99
+ outbound.temp_fail_queue = new TimerQueue(10)
97
100
  outbound.temp_fail_queue.add('file1', 10, () => {
98
- assert.ok(false, 'This callback should not be called');
99
- done();
101
+ assert.ok(false, 'This callback should not be called')
102
+ done()
100
103
  })
101
104
 
102
- outbound.temp_fail_queue.add('file2', 2000, () => {});
103
-
104
- this.plugin.hook_unrecognized_command(() => {
105
- self.connection.respond = (code, message) => {
106
- const data = JSON.parse(message);
107
- assert.equal(1, data.temp_fail_queue.length);
108
- done();
109
- }
110
- self.plugin.hook_unrecognized_command(() => {}, self.connection, ['STATUS', 'QUEUE INSPECT']);
111
- }, this.connection, ['STATUS', 'QUEUE DISCARD file1']);
105
+ outbound.temp_fail_queue.add('file2', 2000, () => {})
106
+
107
+ this.plugin.hook_unrecognized_command(
108
+ () => {
109
+ self.connection.respond = (code, message) => {
110
+ const data = JSON.parse(message)
111
+ assert.equal(1, data.temp_fail_queue.length)
112
+ done()
113
+ }
114
+ self.plugin.hook_unrecognized_command(() => {}, self.connection, ['STATUS', 'QUEUE INSPECT'])
115
+ },
116
+ this.connection,
117
+ ['STATUS', 'QUEUE DISCARD file1'],
118
+ )
112
119
  })
113
120
 
114
121
  it('push_email_at_queue', (done) => {
115
122
  const timeout = setTimeout(() => {
116
- assert.ok(false, 'Timeout');
117
- done();
118
- }, 1000);
123
+ assert.ok(false, 'Timeout')
124
+ done()
125
+ }, 1000)
119
126
 
120
127
  outbound.temp_fail_queue.add('file', 1500, () => {
121
- clearTimeout(timeout);
128
+ clearTimeout(timeout)
122
129
 
123
- assert.ok(true);
124
- done();
125
- });
130
+ assert.ok(true)
131
+ done()
132
+ })
126
133
 
127
- this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE PUSH file']);
134
+ this.plugin.hook_unrecognized_command(() => {}, this.connection, ['STATUS', 'QUEUE PUSH file'])
128
135
  })
129
136
  })
130
- })
137
+ })