Skip to content

Commit bdb1e0b

Browse files
committed
Renames and rearranges tests for unicode support in the sendmail suite
1 parent ca065d4 commit bdb1e0b

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

ports-py/sendmail-python-emails.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def sendmail_send_message(env, sender:SMTPBackend, message, sender_address, reci
127127
subject="Test",
128128
mail_to=recipient_addresses,
129129
mail_from=sender_address)
130-
return [message.send(smtp=sender)]
130+
return [message.send(smtp=sender,smtp_mail_options=message_options, smtp_rcpt_options=recipients_options)]
131131
except Exception as e:
132132
return [e]
133133

@@ -152,12 +152,13 @@ def sendmail_error(env, result: SMTPResponse):
152152

153153
sendmail_suite.run(
154154
exclude_capabilities=(
155-
"root.connection.lazy-connection", # TODO: pythone-emails does not handle failed auth correctly
155+
"root.connection.lazy-connection", # TODO: python-emails does not handle failed auth correctly
156156
"root.connection.eager-connection",
157157
"root.crlf-injection-detection.detection",
158-
"root.8bitmime",
159-
"root.smtputf8.explicit-options"),
158+
"root.unicode-messages.8bitmime-automatic-detection",
159+
"root.internationalized-email-addresses.smtputf8-explicit-options"),
160160
expected_failures=(
161+
"test_non-ascii_content_in_send-message_with_8BITMIME_option_and_without_8BITMIME_server_support", # 8bitmime or smtputf8 should not be sent when server does not support it
161162
"test_Handle_421_at_start_of_data_command",
162163
"test_Handle_421_during_data_command",
163164
# The library should problably automatically detect whether smtputf8 is required

ports-py/sendmail-redmail.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ def sendmail_error(env, result):
165165
"test_CRLF_mitigation_in_send-message_sender",
166166
"test_Connect_with_invalid_credentials"), # TODO redmail leaks sockets when credentials are invalid
167167
exclude_capabilities=(
168-
"root.8bitmime",
169-
"root.smtputf8.explicit-options"),
168+
"root.unicode-messages.8bitmime-automatic-detection",
169+
"root.unicode-messages.8bitmime-mandatory-options",
170+
"root.internationalized-email-addresses.smtputf8-explicit-options",),
170171
expected_failures=(
171172
"test_Handle_421_during_data_command",
172173
"test_Handle_421_at_start_of_data_command",

suites/sendmail.ports

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@
302302

303303
))
304304

305-
(capability '8bitmime (list
305+
(capability 'unicode-messages (list
306306

307307
(define smtp-connection '())
308308
(define (connect-smtp-server)
@@ -319,54 +319,40 @@
319319
(define (activate-8bitmime server)
320320
(server-set-extensions! server '("8BITMIME")))
321321

322-
(capability 'mandatory-options (list
322+
; The library can handle unicode messages by using the 8BITMIME extension but users have to set the option explicitly.
323+
(capability '8bitmime-mandatory-options (list
323324

324325
; 6152 - Section 3, end of section
325-
(test "non-ascii content in send-message without 8BITMIME support" (lambda ()
326-
326+
(test "non-ascii content in send-message with 8BITMIME option and without 8BITMIME server support" (lambda ()
327327
(let
328328
((send-message-responses (sendmail-send-message-with-options
329329
smtp-connection "¡a test message containing unicode!" "sender@sender.com" '("user@recipient.com") '("BODY=8BITMIME") '())))
330330
(assert (all? send-error? send-message-responses) "Client should not support sending 8BITMIME body when server does not support it"))))
331331

332-
(test "non-ascii content in send-message without 8BITMIME support and no option" (lambda ()
333-
334-
(let
335-
((send-message-responses (sendmail-send-message-with-options
336-
smtp-connection "¡a test message containing unicode!" "sender@sender.com" '("user@recipient.com") '() '())))
337-
(assert (all? send-error? send-message-responses)))))
332+
; TODO: Missing test: use fallback encoding when 8BITMIME options was not set (independent of server support)
338333

339-
(test "non-ascii content in send-message with 8BITMIME support and option" (lambda ()
334+
(test "non-ascii content in send-message with 8BITMIME option and server support" (lambda ()
340335
(activate-8bitmime server)
341-
342336
(let
343337
((send-message-responses (sendmail-send-message-with-options
344338
smtp-connection "¡a test message containing unicode!" "sender@sender.com" '("user@recipient.com") '("BODY=8BITMIME") '())))
345339
(assert (all? send-success? send-message-responses))
346340
(assert-any-request server "MAIL FROM:<sender@sender.com> BODY=8BITMIME"))))
347-
348-
(test "non-ascii content in send-message with 8BITMIME support and no option" (lambda ()
349-
(activate-8bitmime server)
350-
351-
(let
352-
((send-message-responses (sendmail-send-message-with-options
353-
smtp-connection "¡a test message containing unicode!" "sender@sender.com" '("user@recipient.com") '() '())))
354-
(assert (all? send-error? send-message-responses)))))
355341

356342
))
357343

358-
(capability 'automatic-8bitmime-detection (list
344+
; The library can handle unicode messages by using the 8BITMIME extension and detects it automatically.
345+
(capability '8bitmime-automatic-detection (list
359346

347+
; TODO: The following is not useful, as it should also check whether the message body was correctly encoded
360348
(test "non-ascii content in send-message without 8BITMIME support" (lambda ()
361-
362349
(let
363350
((send-message-responses (sendmail-send-message-with-options
364351
smtp-connection "¡a test message containing unicode!" "sender@sender.com" '("user@recipient.com") '() '())))
365-
(assert (all? send-error? send-message-responses)))))
352+
(assert-any-request server "MAIL FROM:<sender@sender.com>"))))
366353

367354
(test "non-ascii content in send-message with 8BITMIME support" (lambda ()
368355
(activate-8bitmime server)
369-
370356
(let
371357
((send-message-responses (sendmail-send-message-with-options
372358
smtp-connection "¡a test message containing unicode!" "sender@sender.com" '("user@recipient.com") '() '())))
@@ -377,7 +363,7 @@
377363

378364
))
379365

380-
(capability 'smtputf8 (list
366+
(capability 'internationalized-email-addresses (list
381367

382368
(define smtp-connection '())
383369
(define (connect-smtp-server)
@@ -397,7 +383,7 @@
397383
(define (activate-smtputf8 server)
398384
(server-set-extensions! server '("SMTPUTF8" "8BITMIME")))
399385

400-
(capability 'explicit-options (list
386+
(capability 'smtputf8-explicit-options (list
401387

402388
; Recipient
403389

@@ -466,7 +452,7 @@
466452
(assert (all? send-error? send-message-responses)))))
467453
))
468454

469-
(capability 'automatic-smtputf8-detection (list
455+
(capability 'smtputf8-automatic-detection (list
470456

471457
; Recipient
472458

0 commit comments

Comments
 (0)