Haraka 3.0.0 → 3.0.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.
@@ -4,6 +4,7 @@ const path = require('path');
4
4
 
5
5
  const { Address } = require('address-rfc2821');
6
6
  const fixtures = require('haraka-test-fixtures');
7
+ const Notes = require('haraka-notes')
7
8
 
8
9
  const OK = 906;
9
10
 
@@ -14,6 +15,7 @@ function _setup (done) {
14
15
  this.plugin.config = this.plugin.config.module_config(path.resolve('tests'));
15
16
 
16
17
  this.plugin.register();
18
+ this.hmail = { todo: { notes: new Notes() } };
17
19
 
18
20
  this.connection = new fixtures.connection.createConnection();
19
21
  this.connection.transaction = new fixtures.transaction.createTransaction();
@@ -131,21 +133,29 @@ exports.get_config = {
131
133
  }
132
134
  }
133
135
 
134
- const hmail = { todo: { notes: {} } };
135
136
  exports.get_mx = {
136
137
  setUp : _setup,
137
138
  'returns no outbound route for undefined domains' (test) {
138
139
  test.expect(2);
139
- function cb (code, mx) {
140
+ this.plugin.get_mx((code, mx) => {
140
141
  test.equal(code, undefined);
141
142
  test.deepEqual(mx, undefined);
142
143
  test.done();
143
- }
144
- this.plugin.get_mx(cb, hmail, 'undefined.com');
144
+ }, this.hmail, 'undefined.com');
145
+ },
146
+ 'returns no outbound route when queue.wants !== smtp_forward' (test) {
147
+ test.expect(2);
148
+ this.hmail.todo.notes.set('queue.wants', 'outbound')
149
+ this.hmail.todo.notes.set('queue.next_hop', 'smtp://5.4.3.2:26')
150
+ this.plugin.get_mx((code, mx) => {
151
+ test.equal(code, undefined);
152
+ test.deepEqual(mx, undefined);
153
+ test.done();
154
+ }, this.hmail, 'undefined.com');
145
155
  },
146
156
  'returns an outbound route for defined domains' (test) {
147
157
  test.expect(2);
148
- function cb (code, mx) {
158
+ this.plugin.get_mx((code, mx) => {
149
159
  test.equal(code, OK);
150
160
  test.deepEqual(mx, {
151
161
  priority: 0, exchange: '1.2.3.4', port: 2555,
@@ -153,8 +163,27 @@ exports.get_mx = {
153
163
  auth_pass: 'superDuperSecret'
154
164
  });
155
165
  test.done();
156
- }
157
- this.plugin.get_mx(cb, hmail, 'test.com');
166
+ }, this.hmail, 'test.com');
167
+ },
168
+ 'is enabled when queue.wants is set' (test) {
169
+ test.expect(2);
170
+ this.hmail.todo.notes.set('queue.wants', 'smtp_forward')
171
+ this.hmail.todo.notes.set('queue.next_hop', 'smtp://4.3.2.1:465')
172
+ this.plugin.get_mx((code, mx) => {
173
+ test.equal(code, OK);
174
+ test.deepEqual(mx, { priority: 0, port: 465, exchange: '4.3.2.1' });
175
+ test.done();
176
+ }, this.hmail, 'undefined.com');
177
+ },
178
+ 'sets using_lmtp when next_hop URL is lmtp' (test) {
179
+ test.expect(2);
180
+ this.hmail.todo.notes.set('queue.wants', 'smtp_forward')
181
+ this.hmail.todo.notes.set('queue.next_hop', 'lmtp://4.3.2.1')
182
+ this.plugin.get_mx((code, mx) => {
183
+ test.equal(code, OK);
184
+ test.deepEqual(mx, { priority: 0, port: 24, using_lmtp: true, exchange: '4.3.2.1' });
185
+ test.done();
186
+ }, this.hmail, 'undefined.com');
158
187
  },
159
188
  }
160
189