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
package/test/logger.js CHANGED
@@ -1,9 +1,9 @@
1
1
  const assert = require('node:assert')
2
- const util = require('node:util');
2
+ const util = require('node:util')
3
3
 
4
4
  const _set_up = (done) => {
5
- this.logger = require('../logger');
6
- done();
5
+ this.logger = require('../logger')
6
+ done()
7
7
  }
8
8
 
9
9
  describe('logger', () => {
@@ -11,248 +11,267 @@ describe('logger', () => {
11
11
 
12
12
  describe('init', () => {
13
13
  it('logger', () => {
14
- assert.ok(this.logger);
14
+ assert.ok(this.logger)
15
15
  })
16
16
  })
17
17
 
18
18
  describe('log', () => {
19
19
  it('log', () => {
20
- this.logger.deferred_logs = [];
21
- assert.equal(0, this.logger.deferred_logs.length);
22
- assert.ok(this.logger.log('WARN','test warning'));
23
- assert.equal(1, this.logger.deferred_logs.length);
20
+ this.logger.deferred_logs = []
21
+ assert.equal(0, this.logger.deferred_logs.length)
22
+ assert.ok(this.logger.log('WARN', 'test warning'))
23
+ assert.equal(1, this.logger.deferred_logs.length)
24
24
  })
25
25
 
26
26
  it('log, w/deferred', () => {
27
- this.logger.plugins = { plugin_list: true };
28
- this.logger.deferred_logs.push( { level: 'INFO', data: 'log test info'} );
29
- assert.ok(this.logger.log('INFO', 'another test info'));
27
+ this.logger.plugins = { plugin_list: true }
28
+ this.logger.deferred_logs.push({
29
+ level: 'INFO',
30
+ data: 'log test info',
31
+ })
32
+ assert.ok(this.logger.log('INFO', 'another test info'))
30
33
  })
31
34
 
32
35
  it('log in logfmt', () => {
33
- this.logger.deferred_logs = [];
34
- this.logger.format = this.logger.formats.LOGFMT;
35
- assert.equal(0, this.logger.deferred_logs.length);
36
- assert.ok(this.logger.log('WARN','test warning'));
37
- assert.equal(1, this.logger.deferred_logs.length);
36
+ this.logger.deferred_logs = []
37
+ this.logger.format = this.logger.formats.LOGFMT
38
+ assert.equal(0, this.logger.deferred_logs.length)
39
+ assert.ok(this.logger.log('WARN', 'test warning'))
40
+ assert.equal(1, this.logger.deferred_logs.length)
38
41
  })
39
42
 
40
43
  it('log in logfmt w/deferred', () => {
41
- this.logger.plugins = { plugin_list: true };
42
- this.logger.deferred_logs.push( { level: 'INFO', data: 'log test info'} );
43
- assert.ok(this.logger.log('INFO', 'another test info'));
44
+ this.logger.plugins = { plugin_list: true }
45
+ this.logger.deferred_logs.push({
46
+ level: 'INFO',
47
+ data: 'log test info',
48
+ })
49
+ assert.ok(this.logger.log('INFO', 'another test info'))
44
50
  })
45
51
 
46
52
  it('log in json', () => {
47
- this.logger.deferred_logs = [];
48
- this.logger.format = this.logger.formats.JSON;
49
- assert.equal(0, this.logger.deferred_logs.length);
50
- assert.ok(this.logger.log('WARN','test warning'));
51
- assert.equal(1, this.logger.deferred_logs.length);
53
+ this.logger.deferred_logs = []
54
+ this.logger.format = this.logger.formats.JSON
55
+ assert.equal(0, this.logger.deferred_logs.length)
56
+ assert.ok(this.logger.log('WARN', 'test warning'))
57
+ assert.equal(1, this.logger.deferred_logs.length)
52
58
  })
53
59
 
54
60
  it('log in json w/deferred', () => {
55
- this.logger.plugins = { plugin_list: true };
56
- this.logger.deferred_logs.push( { level: 'INFO', data: 'log test info'} );
57
- assert.ok(this.logger.log('INFO', 'another test info'));
61
+ this.logger.plugins = { plugin_list: true }
62
+ this.logger.deferred_logs.push({
63
+ level: 'INFO',
64
+ data: 'log test info',
65
+ })
66
+ assert.ok(this.logger.log('INFO', 'another test info'))
58
67
  })
59
68
  })
60
69
 
61
70
  describe('level', () => {
62
71
  it('both INFO and LOGINFO are log levels', () => {
63
- assert.equal(this.logger.levels.INFO, 6);
64
- assert.equal(this.logger.levels.LOGINFO, 6);
72
+ assert.equal(this.logger.levels.INFO, 6)
73
+ assert.equal(this.logger.levels.LOGINFO, 6)
65
74
  })
66
-
67
75
  })
68
76
 
69
77
  describe('set_format', () => {
70
78
  it('set format to DEFAULT', () => {
71
- this.logger.format = '';
72
- this.logger.set_format('DEFAULT');
73
- assert.equal(this.logger.format, this.logger.formats.DEFAULT);
79
+ this.logger.format = ''
80
+ this.logger.set_format('DEFAULT')
81
+ assert.equal(this.logger.format, this.logger.formats.DEFAULT)
74
82
  })
75
83
 
76
84
  it('set format to LOGFMT', () => {
77
- this.logger.format = '';
78
- this.logger.set_format('LOGFMT');
79
- assert.equal(this.logger.format, this.logger.formats.LOGFMT);
85
+ this.logger.format = ''
86
+ this.logger.set_format('LOGFMT')
87
+ assert.equal(this.logger.format, this.logger.formats.LOGFMT)
80
88
  })
81
89
 
82
90
  it('set format to JSON', () => {
83
- this.logger.format = '';
84
- this.logger.set_format('JSON');
85
- assert.equal(this.logger.format, this.logger.formats.JSON);
91
+ this.logger.format = ''
92
+ this.logger.set_format('JSON')
93
+ assert.equal(this.logger.format, this.logger.formats.JSON)
86
94
  })
87
95
 
88
96
  it('set format to DEFAULT if empty', () => {
89
- this.logger.format = '';
90
- this.logger.set_format('');
91
- assert.equal(this.logger.format, this.logger.formats.DEFAULT);
97
+ this.logger.format = ''
98
+ this.logger.set_format('')
99
+ assert.equal(this.logger.format, this.logger.formats.DEFAULT)
92
100
  })
93
101
 
94
102
  it('set format to DEFAULT if lowercase', () => {
95
- this.logger.format = '';
96
- this.logger.set_format('default');
97
- assert.equal(this.logger.format, this.logger.formats.DEFAULT);
103
+ this.logger.format = ''
104
+ this.logger.set_format('default')
105
+ assert.equal(this.logger.format, this.logger.formats.DEFAULT)
98
106
  })
99
107
 
100
108
  it('set format to DEFAULT if invalid', () => {
101
- this.logger.format = '';
102
- this.logger.set_format('invalid');
103
- assert.equal(this.logger.format, this.logger.formats.DEFAULT);
109
+ this.logger.format = ''
110
+ this.logger.set_format('invalid')
111
+ assert.equal(this.logger.format, this.logger.formats.DEFAULT)
104
112
  })
105
-
106
113
  })
107
114
 
108
115
  describe('set_loglevel', () => {
109
116
  it('set loglevel to LOGINFO', () => {
110
- this.logger.set_loglevel('LOGINFO');
111
- assert.equal(this.logger.loglevel, this.logger.levels.LOGINFO);
117
+ this.logger.set_loglevel('LOGINFO')
118
+ assert.equal(this.logger.loglevel, this.logger.levels.LOGINFO)
112
119
  })
113
120
 
114
121
  it('set loglevel to INFO', () => {
115
- this.logger.set_loglevel('INFO');
116
- assert.equal(this.logger.loglevel, this.logger.levels.INFO);
122
+ this.logger.set_loglevel('INFO')
123
+ assert.equal(this.logger.loglevel, this.logger.levels.INFO)
117
124
  })
118
125
 
119
126
  it('set loglevel to EMERG', () => {
120
- this.logger.set_loglevel('emerg');
121
- assert.equal(this.logger.loglevel, this.logger.levels.EMERG);
127
+ this.logger.set_loglevel('emerg')
128
+ assert.equal(this.logger.loglevel, this.logger.levels.EMERG)
122
129
  })
123
130
 
124
131
  it('set loglevel to 6', () => {
125
- this.logger.set_loglevel(6);
126
- assert.equal(this.logger.loglevel, 6);
132
+ this.logger.set_loglevel(6)
133
+ assert.equal(this.logger.loglevel, 6)
127
134
  })
128
135
 
129
136
  it('set loglevel to WARN if invalid', () => {
130
- this.logger.set_loglevel('invalid');
131
- assert.equal(this.logger.loglevel, this.logger.levels.WARN);
137
+ this.logger.set_loglevel('invalid')
138
+ assert.equal(this.logger.loglevel, this.logger.levels.WARN)
132
139
  })
133
140
  })
134
141
 
135
142
  describe('set_timestamps', () => {
136
143
  it('set timestamps to false', () => {
137
- this.logger.timestamps = undefined;
138
- this.logger.set_timestamps(false);
139
- assert.equal(this.logger.timestamps, false);
144
+ this.logger.timestamps = undefined
145
+ this.logger.set_timestamps(false)
146
+ assert.equal(this.logger.timestamps, false)
140
147
  })
141
148
 
142
149
  it('set timestamps to true', () => {
143
- this.logger.timestamps = undefined;
144
- this.logger.set_timestamps(true);
145
- assert.equal(this.logger.timestamps, true);
150
+ this.logger.timestamps = undefined
151
+ this.logger.set_timestamps(true)
152
+ assert.equal(this.logger.timestamps, true)
146
153
  })
147
154
  })
148
155
 
149
156
  describe('would_log', () => {
150
157
  it('should', () => {
151
- this.logger.loglevel = 4;
152
- assert.equal(false, this.logger.would_log(7));
153
- assert.equal(false, this.logger.would_log(6));
154
- assert.equal(false, this.logger.would_log(5));
158
+ this.logger.loglevel = 4
159
+ assert.equal(false, this.logger.would_log(7))
160
+ assert.equal(false, this.logger.would_log(6))
161
+ assert.equal(false, this.logger.would_log(5))
155
162
  })
156
163
 
157
164
  it('should not', () => {
158
- this.logger.loglevel = 4;
159
- assert.equal(true, this.logger.would_log(4));
160
- assert.equal(true, this.logger.would_log(3));
161
- assert.equal(true, this.logger.would_log(2));
162
- assert.equal(true, this.logger.would_log(1));
165
+ this.logger.loglevel = 4
166
+ assert.equal(true, this.logger.would_log(4))
167
+ assert.equal(true, this.logger.would_log(3))
168
+ assert.equal(true, this.logger.would_log(2))
169
+ assert.equal(true, this.logger.would_log(1))
163
170
  })
164
171
  })
165
172
 
166
173
  describe('log_respond', () => {
167
174
  it('invalid retval', () => {
168
- assert.equal(false, this.logger.log_respond(901));
175
+ assert.equal(false, this.logger.log_respond(901))
169
176
  })
170
177
 
171
178
  it('valid retval', () => {
172
- const data = { level: 'INFO', data: "test data" };
173
- assert.equal(true, this.logger.log_respond(900, 'test msg', data));
179
+ const data = { level: 'INFO', data: 'test data' }
180
+ assert.equal(true, this.logger.log_respond(900, 'test msg', data))
174
181
  })
175
182
  })
176
183
 
177
184
  describe('dump_logs', () => {
178
185
  it('empty', () => {
179
- assert.ok(this.logger.dump_logs(0));
186
+ assert.ok(this.logger.dump_logs(0))
180
187
  })
181
188
 
182
189
  it('with deferred', () => {
183
- this.logger.deferred_logs.push( { level: 'info', data: 'test info'} );
184
- this.logger.deferred_logs.push( { level: 'INFO', data: 'test info, color'} );
185
- this.logger.deferred_logs.push( { level: 'WARN', data: 'test warn, color'} );
186
- assert.ok(this.logger.dump_logs(0));
187
- assert.ok(this.logger.deferred_logs.length === 0);
190
+ this.logger.deferred_logs.push({
191
+ level: 'info',
192
+ data: 'test info',
193
+ })
194
+ this.logger.deferred_logs.push({
195
+ level: 'INFO',
196
+ data: 'test info, color',
197
+ })
198
+ this.logger.deferred_logs.push({
199
+ level: 'WARN',
200
+ data: 'test warn, color',
201
+ })
202
+ assert.ok(this.logger.dump_logs(0))
203
+ assert.ok(this.logger.deferred_logs.length === 0)
188
204
  })
189
205
  })
190
206
 
191
207
  describe('colors', () => {
192
208
  it('colors', () => {
193
- assert.ok(this.logger.colors);
209
+ assert.ok(this.logger.colors)
194
210
  })
195
211
 
196
212
  it('colorize', () => {
197
- assert.ok(this.logger.colorize);
198
- assert.equal('function', typeof this.logger.colorize);
199
- assert.equal('error', this.logger.colorize('bad-color', 'error'));
200
- const expected = util.inspect.colors ? '\u001b[34mgood\u001b[39m' : 'good';
201
- assert.equal(expected, this.logger.colorize('blue', 'good'));
213
+ assert.ok(this.logger.colorize)
214
+ assert.equal('function', typeof this.logger.colorize)
215
+ assert.equal('error', this.logger.colorize('bad-color', 'error'))
216
+ const expected = util.inspect.colors ? '\u001b[34mgood\u001b[39m' : 'good'
217
+ assert.equal(expected, this.logger.colorize('blue', 'good'))
202
218
  })
203
219
  })
204
220
 
205
221
  describe('log_if_level', () => {
206
222
  it('log_if_level is a function', () => {
207
- assert.ok('function' === typeof this.logger.log_if_level);
223
+ assert.ok('function' === typeof this.logger.log_if_level)
208
224
  })
209
225
 
210
226
  it('log_if_level test log entry', () => {
211
- this.logger.loglevel = 9;
212
- const f = this.logger.log_if_level('INFO', 'LOGINFO');
213
- assert.ok(f);
214
- assert.ok('function' === typeof f);
215
- assert.ok(f('test info message'));
216
- assert.equal(1, this.logger.deferred_logs.length);
227
+ this.logger.loglevel = 9
228
+ const f = this.logger.log_if_level('INFO', 'LOGINFO')
229
+ assert.ok(f)
230
+ assert.ok('function' === typeof f)
231
+ assert.ok(f('test info message'))
232
+ assert.equal(1, this.logger.deferred_logs.length)
217
233
  // console.log(this.logger.deferred_logs[0]);
218
- assert.equal('INFO', this.logger.deferred_logs[0].level);
234
+ assert.equal('INFO', this.logger.deferred_logs[0].level)
219
235
  })
220
236
 
221
237
  it('log_if_level null case', () => {
222
- this.logger.loglevel = 9;
223
- const f = this.logger.log_if_level('INFO', 'LOGINFO');
224
- assert.ok(f(null));
225
- assert.equal(2, this.logger.deferred_logs.length);
238
+ this.logger.loglevel = 9
239
+ const f = this.logger.log_if_level('INFO', 'LOGINFO')
240
+ assert.ok(f(null))
241
+ assert.equal(2, this.logger.deferred_logs.length)
226
242
  })
227
243
 
228
244
  it('log_if_level false', () => {
229
- this.logger.loglevel = 9;
230
- const f = this.logger.log_if_level('INFO', 'LOGINFO');
231
- assert.ok(f(false));
232
- assert.equal(3, this.logger.deferred_logs.length);
245
+ this.logger.loglevel = 9
246
+ const f = this.logger.log_if_level('INFO', 'LOGINFO')
247
+ assert.ok(f(false))
248
+ assert.equal(3, this.logger.deferred_logs.length)
233
249
  })
234
250
 
235
251
  it('log_if_level 0', () => {
236
- this.logger.loglevel = 9;
237
- const f = this.logger.log_if_level('INFO', 'LOGINFO');
238
- assert.ok(f(0));
239
- assert.equal(4, this.logger.deferred_logs.length);
252
+ this.logger.loglevel = 9
253
+ const f = this.logger.log_if_level('INFO', 'LOGINFO')
254
+ assert.ok(f(0))
255
+ assert.equal(4, this.logger.deferred_logs.length)
240
256
  })
241
257
  })
242
258
 
243
259
  describe('add_log_methods', () => {
244
260
  it('ignores non-objects', () => {
245
- assert.equal(undefined, this.logger.add_log_methods(''));
246
- assert.equal(undefined, this.logger.add_log_methods(function foo (){}));
261
+ assert.equal(undefined, this.logger.add_log_methods(''))
262
+ assert.equal(
263
+ undefined,
264
+ this.logger.add_log_methods(function foo() {}),
265
+ )
247
266
  })
248
267
 
249
268
  it('adds functions to an object', () => {
250
- const testObj = {};
251
- this.logger.add_log_methods(testObj);
252
- const levels = ['DATA','PROTOCOL','DEBUG','INFO','NOTICE','WARN','ERROR','CRIT','ALERT','EMERG'];
269
+ const testObj = {}
270
+ this.logger.add_log_methods(testObj)
271
+ const levels = ['DATA', 'PROTOCOL', 'DEBUG', 'INFO', 'NOTICE', 'WARN', 'ERROR', 'CRIT', 'ALERT', 'EMERG']
253
272
  for (const level of levels) {
254
- assert.ok('function' === typeof(testObj[`log${level.toLowerCase()}`]));
273
+ assert.ok('function' === typeof testObj[`log${level.toLowerCase()}`])
255
274
  }
256
275
  })
257
276
  })
258
- })
277
+ })
@@ -1,15 +1,17 @@
1
-
2
1
  const assert = require('node:assert')
3
- const fs = require('node:fs')
2
+ const fs = require('node:fs')
4
3
  const path = require('node:path')
5
4
 
6
- const Hmail = require('../../outbound/hmail');
7
- const outbound = require('../../outbound/index');
8
-
5
+ const Hmail = require('../../outbound/hmail')
6
+ const outbound = require('../../outbound/index')
9
7
 
10
8
  describe('outbound/hmail', () => {
11
9
  beforeEach((done) => {
12
- this.hmail = new Hmail('1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka', 'test/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka', {});
10
+ this.hmail = new Hmail(
11
+ '1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka',
12
+ 'test/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka',
13
+ {},
14
+ )
13
15
  done()
14
16
  })
15
17
 
@@ -33,7 +35,9 @@ describe('outbound/hmail', () => {
33
35
  })
34
36
  it('force_tls', (done) => {
35
37
  this.hmail.todo = { domain: 'miss.example.com' }
36
- this.hmail.obtls.cfg = { force_tls_hosts: ['1.2.3.4', 'hit.example.com'] }
38
+ this.hmail.obtls.cfg = {
39
+ force_tls_hosts: ['1.2.3.4', 'hit.example.com'],
40
+ }
37
41
  assert.equal(this.hmail.get_force_tls({ exchange: '1.2.3.4' }), true)
38
42
  assert.equal(this.hmail.get_force_tls({ exchange: '1.2.3.5' }), false)
39
43
  this.hmail.todo = { domain: 'hit.example.com' }
@@ -44,82 +48,92 @@ describe('outbound/hmail', () => {
44
48
 
45
49
  describe('outbound/hmail.HMailItem', () => {
46
50
  it('normal queue file', (done) => {
47
- this.hmail = new Hmail('1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka', 'test/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka', {});
51
+ this.hmail = new Hmail(
52
+ '1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka',
53
+ 'test/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka',
54
+ {},
55
+ )
48
56
  this.hmail.on('ready', () => {
49
57
  // console.log(this.hmail);
50
58
  assert.ok(this.hmail)
51
59
  done()
52
60
  })
53
- this.hmail.on('error', err => {
61
+ this.hmail.on('error', (err) => {
54
62
  console.log(err)
55
63
  assert.equal(err, undefined)
56
64
  done()
57
65
  })
58
66
  })
59
67
  it('normal TODO w/multibyte chars loads w/o error', (done) => {
60
- this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_1_qfile', 'test/fixtures/todo_qfile.txt', {});
68
+ this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_1_qfile', 'test/fixtures/todo_qfile.txt', {})
61
69
  this.hmail.on('ready', () => {
62
70
  // console.log(this.hmail);
63
71
  assert.ok(this.hmail)
64
72
  done()
65
73
  })
66
- this.hmail.on('error', err => {
74
+ this.hmail.on('error', (err) => {
67
75
  console.log(err)
68
76
  assert.equal(err, undefined)
69
77
  done()
70
78
  })
71
79
  })
72
80
  it('too short TODO length declared', (done) => {
73
- this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka', 'test/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka', {});
81
+ this.hmail = new Hmail(
82
+ '1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka',
83
+ 'test/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka',
84
+ {},
85
+ )
74
86
  this.hmail.on('ready', () => {
75
87
  // console.log(this.hmail);
76
88
  assert.ok(this.hmail)
77
- done();
89
+ done()
78
90
  })
79
91
  this.hmail.on('error', (err) => {
80
- console.log(err);
81
- assert.ok(err);
82
- done();
92
+ console.log(err)
93
+ assert.ok(err)
94
+ done()
83
95
  })
84
96
  })
85
97
  it('too long TODO length declared', (done) => {
86
- this.hmail = new Hmail('1508269674999_1508269674999_0_34002_socVUF_1_haraka', 'test/queue/1508269674999_1508269674999_0_34002_socVUF_1_haraka', {});
98
+ this.hmail = new Hmail(
99
+ '1508269674999_1508269674999_0_34002_socVUF_1_haraka',
100
+ 'test/queue/1508269674999_1508269674999_0_34002_socVUF_1_haraka',
101
+ {},
102
+ )
87
103
  this.hmail.on('ready', () => {
88
104
  // console.log(this.hmail);
89
105
  assert.ok(this.hmail)
90
- done();
106
+ done()
91
107
  })
92
108
  this.hmail.on('error', (err) => {
93
- console.log(err);
94
- assert.ok(err);
95
- done();
109
+ console.log(err)
110
+ assert.ok(err)
111
+ done()
96
112
  })
97
113
  })
98
114
  it('zero-length file load skip w/o crash', (done) => {
99
- this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_2_zero', 'test/queue/zero-length', {});
115
+ this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_2_zero', 'test/queue/zero-length', {})
100
116
  this.hmail.on('ready', () => {
101
117
  assert.ok(this.hmail)
102
- done();
118
+ done()
103
119
  })
104
120
  this.hmail.on('error', (err) => {
105
- console.error(err);
106
- assert.ok(err);
107
- done();
121
+ console.error(err)
122
+ assert.ok(err)
123
+ done()
108
124
  })
109
125
  })
110
126
  it('lifecycle, reads and writes a haraka queue file', (done) => {
111
-
112
- this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_2_qfile', 'test/fixtures/todo_qfile.txt', {});
127
+ this.hmail = new Hmail('1507509981169_1507509981169_0_61403_e0Y0Ym_2_qfile', 'test/fixtures/todo_qfile.txt', {})
113
128
 
114
129
  this.hmail.on('error', (err) => {
115
130
  // console.log(err);
116
- assert.equals(err, undefined);
117
- done();
131
+ assert.equals(err, undefined)
132
+ done()
118
133
  })
119
134
 
120
135
  this.hmail.on('ready', () => {
121
-
122
- const tmpfile = path.resolve('test', 'test-queue', 'delete-me');
136
+ const tmpfile = path.resolve('test', 'test-queue', 'delete-me')
123
137
  const ws = new fs.createWriteStream(tmpfile)
124
138
 
125
139
  outbound.build_todo(this.hmail.todo, ws, () => {
@@ -128,12 +142,12 @@ describe('outbound/hmail.HMailItem', () => {
128
142
  // assert.equals(this.hmail.todo.message_stream.headers.length, 22);
129
143
 
130
144
  const ds = this.hmail.data_stream()
131
- ds.pipe(ws, { dot_stuffing: true });
145
+ ds.pipe(ws)
132
146
 
133
147
  ws.on('close', () => {
134
148
  // console.log(this.hmail.todo)
135
- assert.equal(fs.statSync(tmpfile).size, 4204);
136
- done();
149
+ assert.equal(fs.statSync(tmpfile).size, 4204)
150
+ done()
137
151
  })
138
152
  })
139
153
  })