-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
handler_rcptto_test.go
498 lines (403 loc) · 22.5 KB
/
handler_rcptto_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
package smtpmock
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewHandlerRcptto(t *testing.T) {
t.Run("returns new handlerRcptto", func(t *testing.T) {
session, message, configuration := new(session), new(Message), new(configuration)
handler := newHandlerRcptto(session, message, configuration)
assert.Same(t, session, handler.session)
assert.Same(t, message, handler.message)
assert.Same(t, configuration, handler.configuration)
})
}
func TestHandlerRcpttoRun(t *testing.T) {
t.Run("when successful RCPTTO request", func(t *testing.T) {
request := "RCPT TO: [email protected]"
session, message, configuration := new(sessionMock), new(Message), createConfiguration()
receivedMessage := configuration.msgRcpttoReceived
message.helo, message.mailfrom = true, true
handler := newHandlerRcptto(session, message, configuration)
session.On("clearError").Once().Return(nil)
session.On("writeResponse", receivedMessage, configuration.responseDelayRcptto).Once().Return(nil)
handler.run(request)
assert.True(t, message.rcptto)
assert.Equal(t, [][]string{{request, receivedMessage}}, message.rcpttoRequestResponse)
})
t.Run("when failure RCPTTO request, invalid command sequence", func(t *testing.T) {
request := "MAIL FROM: [email protected]"
session, message, configuration := new(sessionMock), new(Message), createConfiguration()
errorMessage := configuration.msgInvalidCmdRcpttoSequence
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("clearError").Once().Return(nil)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
handler.run(request)
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when failure RCPTTO request, invalid command argument", func(t *testing.T) {
request := "RCPT TO: user@example"
session, message, configuration := new(sessionMock), new(Message), createConfiguration()
message.helo, message.mailfrom = true, true
errorMessage := configuration.msgInvalidCmdRcpttoArg
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("clearError").Once().Return(nil)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
handler.run(request)
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when failure RCPTTO request, request includes blacklisted RCPTTO email", func(t *testing.T) {
email := "[email protected]"
request := "RCPT TO: " + email
session, message, configuration := new(sessionMock), new(Message), createConfiguration()
configuration.isCmdFailFast, configuration.blacklistedRcpttoEmails = true, []string{email}
message.helo, message.mailfrom = true, true
errorMessage := configuration.msgRcpttoBlacklistedEmail
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("clearError").Once().Return(nil)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
handler.run(request)
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when failure RCPTTO request, request includes not registered RCPTTO email", func(t *testing.T) {
email := "[email protected]"
request := "RCPT TO: " + email
session, message, configuration := new(sessionMock), new(Message), createConfiguration()
configuration.isCmdFailFast, configuration.notRegisteredEmails = true, []string{email}
message.helo, message.mailfrom = true, true
errorMessage := configuration.msgRcpttoNotRegisteredEmail
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("clearError").Once().Return(nil)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
handler.run(request)
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
}
func TestHandlerRcpttoClearMessage(t *testing.T) {
t.Run("when multiple RCPTTO is disabled erases all handler message data from RCPTTO command", func(t *testing.T) {
notEmptyMessage := createNotEmptyMessage()
handler := newHandlerRcptto(new(session), notEmptyMessage, new(configuration))
clearedMessage := &Message{
heloRequest: notEmptyMessage.heloRequest,
heloResponse: notEmptyMessage.heloResponse,
helo: notEmptyMessage.helo,
mailfromRequest: notEmptyMessage.mailfromRequest,
mailfromResponse: notEmptyMessage.mailfromResponse,
mailfrom: notEmptyMessage.mailfrom,
}
handler.clearMessage()
assert.Same(t, notEmptyMessage, handler.message)
assert.Equal(t, clearedMessage, handler.message)
handler.message.rcpttoRequestResponse = [][]string{{"request", "response"}}
handler.clearMessage()
assert.Equal(t, clearedMessage, handler.message)
})
t.Run("when multiple RCPTTO is enabled not erases all handler message data from RCPTTO command", func(t *testing.T) {
notEmptyMessage, configuration := createNotEmptyMessage(), new(configuration)
configuration.multipleRcptto = true
handler := newHandlerRcptto(new(session), notEmptyMessage, configuration)
handler.clearMessage()
assert.Same(t, notEmptyMessage, handler.message)
})
}
func TestHandlerRcpttoResolveMessageStatus(t *testing.T) {
t.Run("when current RCPTTO status is true", func(t *testing.T) {
handler := newHandlerRcptto(new(session), new(Message), createConfiguration())
assert.True(t, handler.resolveMessageStatus(true))
})
t.Run("when current RCPTTO status is false, multiple RCPTTO is enabled, includes successful RCPTTO responses", func(t *testing.T) {
msgRcpttoReceived := "response"
message := &Message{rcpttoRequestResponse: [][]string{{"request", msgRcpttoReceived}}}
configuration := &configuration{multipleRcptto: true, msgRcpttoReceived: msgRcpttoReceived}
handler := newHandlerRcptto(new(session), message, configuration)
assert.True(t, handler.resolveMessageStatus(false))
})
t.Run("when current RCPTTO status is false, multiple RCPTTO is enabled, not includes successful RCPTTO responses", func(t *testing.T) {
handler := newHandlerRcptto(new(session), new(Message), &configuration{multipleRcptto: true})
assert.False(t, handler.resolveMessageStatus(false))
})
t.Run("when current RCPTTO status is false, multiple RCPTTO is disabled, not includes successful RCPTTO responses", func(t *testing.T) {
handler := newHandlerRcptto(new(session), new(Message), createConfiguration())
assert.False(t, handler.resolveMessageStatus(false))
})
t.Run("when current RCPTTO status is false, multiple RCPTTO is disabled, includes successful RCPTTO responses", func(t *testing.T) {
msgRcpttoReceived := "response"
message := &Message{rcpttoRequestResponse: [][]string{{"request", msgRcpttoReceived}}}
configuration := &configuration{msgRcpttoReceived: msgRcpttoReceived}
handler := newHandlerRcptto(new(session), message, configuration)
assert.False(t, handler.resolveMessageStatus(false))
})
}
func TestHandlerRcpttoWriteResult(t *testing.T) {
request, response, session := "request context", "response context", &sessionMock{}
t.Run("when successful request received, current RCPTTO status is true", func(t *testing.T) {
message, configuration := new(Message), createConfiguration()
handler := newHandlerRcptto(session, message, configuration)
session.On("writeResponse", response, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.writeResult(true, request, response))
assert.True(t, message.rcptto)
assert.Equal(t, [][]string{{request, response}}, message.rcpttoRequestResponse)
})
t.Run("when successful request received, current RCPTTO status is false, multiple RCPTTO is enabled, includes successful RCPTTO responses", func(t *testing.T) {
configuration := &configuration{multipleRcptto: true, msgRcpttoReceived: response}
message, err := new(Message), errors.New(response)
handler := newHandlerRcptto(session, message, configuration)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", response, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.writeResult(false, request, response))
assert.True(t, message.rcptto)
assert.Equal(t, [][]string{{request, response}}, message.rcpttoRequestResponse)
})
t.Run("when failed request received, RCPTTO status is false, multiple RCPTTO is enabled, not includes successful RCPTTO responses", func(t *testing.T) {
message, configuration, err := new(Message), &configuration{multipleRcptto: true}, errors.New(response)
handler := newHandlerRcptto(session, message, configuration)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", response, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.writeResult(false, request, response))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, response}}, message.rcpttoRequestResponse)
})
t.Run("when failed request received, RCPTTO status is false, multiple RCPTTO is disabled, not includes successful RCPTTO responses", func(t *testing.T) {
message, configuration, err := new(Message), createConfiguration(), errors.New(response)
handler := newHandlerRcptto(session, message, configuration)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", response, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.writeResult(false, request, response))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, response}}, message.rcpttoRequestResponse)
})
t.Run("when failed request received, RCPTTO status is false, multiple RCPTTO is disabled, includes successful RCPTTO responses", func(t *testing.T) {
successfulResponse := "successfulResponse"
configuration := &configuration{msgRcpttoReceived: successfulResponse}
message, err := &Message{rcpttoRequestResponse: [][]string{{request, successfulResponse}}}, errors.New(response)
handler := newHandlerRcptto(session, message, configuration)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", response, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.writeResult(false, request, response))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, successfulResponse}, {request, response}}, message.rcpttoRequestResponse)
})
}
func TestHandlerRcpttoIsInvalidCmdSequence(t *testing.T) {
request, configuration, session := "some request", createConfiguration(), &sessionMock{}
t.Run("when none of the previous command was successful", func(t *testing.T) {
message, errorMessage := new(Message), configuration.msgInvalidCmdRcpttoSequence
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.isInvalidCmdSequence(request))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when mailfrom previous command was failure", func(t *testing.T) {
message, errorMessage := new(Message), configuration.msgInvalidCmdRcpttoSequence
message.helo = true
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.isInvalidCmdSequence(request))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when all of the previous commands was successful", func(t *testing.T) {
message := new(Message)
message.helo, message.mailfrom = true, true
handler := newHandlerRcptto(session, message, configuration)
assert.False(t, handler.isInvalidCmdSequence(request))
assert.False(t, message.rcptto)
assert.Empty(t, message.rcpttoRequestResponse)
})
}
func TestHandlerRcpttoIsInvalidCmdArg(t *testing.T) {
configuration, session := createConfiguration(), &sessionMock{}
t.Run("when request includes invalid command RCPTTO argument", func(t *testing.T) {
request, message, errorMessage := "RCPT TO: email@invalid", new(Message), configuration.msgInvalidCmdRcpttoArg
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.isInvalidCmdArg(request))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when request includes valid command RCPTTO argument without <> sign", func(t *testing.T) {
message := new(Message)
handler := newHandlerRcptto(session, message, configuration)
assert.False(t, handler.isInvalidCmdArg("RCPT TO: [email protected]"))
assert.False(t, message.rcptto)
assert.Empty(t, message.rcpttoRequestResponse)
})
t.Run("when request includes valid command RCPTTO argument with localhost domain", func(t *testing.T) {
message := new(Message)
handler := newHandlerRcptto(session, message, configuration)
assert.False(t, handler.isInvalidCmdArg("RCPT TO: user@localhost"))
assert.False(t, message.rcptto)
assert.Empty(t, message.rcpttoRequestResponse)
})
t.Run("when request includes valid command RCPTTO argument without <> sign without space", func(t *testing.T) {
message := new(Message)
handler := newHandlerRcptto(session, message, configuration)
assert.False(t, handler.isInvalidCmdArg("RCPT TO:[email protected]"))
assert.False(t, message.rcptto)
assert.Empty(t, message.rcpttoRequestResponse)
})
t.Run("when request includes valid command RCPTTO argument with <> sign", func(t *testing.T) {
message := new(Message)
handler := newHandlerRcptto(session, message, configuration)
assert.False(t, handler.isInvalidCmdArg("RCPT TO: <[email protected]>"))
assert.False(t, message.rcptto)
assert.Empty(t, message.rcpttoRequestResponse)
})
t.Run("when request includes valid command RCPTTO argument with <> sign withoyt space", func(t *testing.T) {
message := new(Message)
handler := newHandlerRcptto(session, message, configuration)
assert.False(t, handler.isInvalidCmdArg("RCPT TO:<[email protected]>"))
assert.False(t, message.rcptto)
assert.Empty(t, message.rcpttoRequestResponse)
})
}
func TestHandlerRcpttoRcpttoEmail(t *testing.T) {
validEmail, handler := "[email protected]", new(handlerRcptto)
t.Run("when request includes valid email address without <> sign", func(t *testing.T) {
assert.Equal(t, validEmail, handler.rcpttoEmail("RCPT TO: "+validEmail))
})
t.Run("when request includes valid email address with <> sign", func(t *testing.T) {
assert.Equal(t, validEmail, handler.rcpttoEmail("RCPT TO: "+"<"+validEmail+">"))
})
t.Run("when request includes valid email address without <> sign, with name", func(t *testing.T) {
assert.Equal(t, validEmail, handler.rcpttoEmail("RCPT TO: John Doe <"+validEmail+">"))
})
t.Run("when request includes valid email address with <> sign, name with space", func(t *testing.T) {
assert.Equal(t, validEmail, handler.rcpttoEmail("RCPT TO: "+"<John Doe <"+validEmail+">>"))
})
t.Run("when request includes valid email address with <> sign and name without space", func(t *testing.T) {
assert.Equal(t, validEmail, handler.rcpttoEmail("RCPT TO: "+"<JohnDoe<"+validEmail+">>"))
})
t.Run("when request includes invalid email address", func(t *testing.T) {
invalidEmail := "user@invalid"
assert.Equal(t, emptyString, handler.rcpttoEmail("RCPT TO: "+invalidEmail))
})
t.Run("when request includes invalid email address, wrong format", func(t *testing.T) {
invalidEmail := "[email protected]@b.com"
assert.Equal(t, emptyString, handler.rcpttoEmail("RCPT TO: "+invalidEmail))
})
t.Run("when request includes invalid email starting with dot", func(t *testing.T) {
invalidEmail := "[email protected]"
assert.Equal(t, emptyString, handler.rcpttoEmail("RCPT TO: "+invalidEmail))
})
t.Run("when request includes invalid email ending with dot before @", func(t *testing.T) {
invalidEmail := "[email protected]"
assert.Equal(t, emptyString, handler.rcpttoEmail("RCPT TO: "+invalidEmail))
})
}
func TestHandlerRcpttoIsBlacklistedEmail(t *testing.T) {
email := "[email protected]"
request := "RCPT TO: " + email
t.Run("when request includes blacklisted domain name", func(t *testing.T) {
session, message, configuration := new(sessionMock), new(Message), createConfiguration()
configuration.blacklistedRcpttoEmails = []string{email}
errorMessage := configuration.msgRcpttoBlacklistedEmail
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.isBlacklistedEmail(request))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when request not includes blacklisted domain name", func(t *testing.T) {
session, message, configuration := new(sessionMock), new(Message), createConfiguration()
handler := newHandlerRcptto(session, message, configuration)
assert.False(t, handler.isBlacklistedEmail(request))
assert.False(t, message.rcptto)
assert.Empty(t, message.rcpttoRequestResponse)
})
}
func TestHandlerRcpttoIsNotRegisteredEmail(t *testing.T) {
email := "[email protected]"
request := "RCPT TO: " + email
t.Run("when request includes blacklisted domain name", func(t *testing.T) {
session, message, configuration := new(sessionMock), new(Message), createConfiguration()
configuration.notRegisteredEmails = []string{email}
errorMessage := configuration.msgRcpttoNotRegisteredEmail
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.isNotRegisteredEmail(request))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when request not includes blacklisted domain name", func(t *testing.T) {
session, message, configuration := new(sessionMock), new(Message), createConfiguration()
handler := newHandlerRcptto(session, message, configuration)
assert.False(t, handler.isNotRegisteredEmail(request))
assert.False(t, message.rcptto)
assert.Empty(t, message.rcpttoRequestResponse)
})
}
func TestHandlerRcpttoIsInvalidRequest(t *testing.T) {
configuration := createConfiguration()
t.Run("when request includes invalid RCPTTO command sequence", func(t *testing.T) {
request := "MAIL FROM: [email protected]"
session, message, errorMessage := new(sessionMock), new(Message), configuration.msgInvalidCmdRcpttoSequence
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.isInvalidRequest(request))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when request includes invalid RCPTTO command argument", func(t *testing.T) {
request := "RCPT TO: user@example"
session, message, errorMessage := new(sessionMock), new(Message), configuration.msgInvalidCmdRcpttoArg
message.helo, message.mailfrom = true, true
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.isInvalidRequest(request))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when request includes blacklisted RCPTTO email", func(t *testing.T) {
configuration, blacklistedEmail := createConfiguration(), "[email protected]"
request := "RCPT TO: " + blacklistedEmail
session, message, errorMessage := new(sessionMock), new(Message), configuration.msgRcpttoBlacklistedEmail
configuration.blacklistedRcpttoEmails = []string{blacklistedEmail}
message.helo, message.mailfrom = true, true
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.isInvalidRequest(request))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when request includes not registered RCPTTO email", func(t *testing.T) {
configuration, notRegisteredEmail := createConfiguration(), "[email protected]"
request := "RCPT TO: " + notRegisteredEmail
session, message, errorMessage := new(sessionMock), new(Message), configuration.msgRcpttoNotRegisteredEmail
configuration.notRegisteredEmails = []string{notRegisteredEmail}
message.helo, message.mailfrom = true, true
handler, err := newHandlerRcptto(session, message, configuration), errors.New(errorMessage)
session.On("addError", err).Once().Return(nil)
session.On("writeResponse", errorMessage, configuration.responseDelayRcptto).Once().Return(nil)
assert.True(t, handler.isInvalidRequest(request))
assert.False(t, message.rcptto)
assert.Equal(t, [][]string{{request, errorMessage}}, message.rcpttoRequestResponse)
})
t.Run("when valid RCPTTO request", func(t *testing.T) {
request := "RCPT TO: [email protected]"
session, message := new(sessionMock), new(Message)
message.helo, message.mailfrom = true, true
handler := newHandlerRcptto(session, message, configuration)
assert.False(t, handler.isInvalidRequest(request))
assert.False(t, message.rcptto)
assert.Empty(t, message.rcpttoRequestResponse)
})
}