-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: Use swaks
instead of nc
for sending mail
#3732
Conversation
Additional prefix is pretty useless, and I wanted to do this for a long time now.
These are not templates, but files that are "simply" used with nc.
The wrapper is made so custon options can be applied with flags, and common arguments are defaults. The actual invocation is easy to read but requires the e-mail files to be adjusted. This will happen in a latter commit.
Basically remove the `-templates` suffix (because, again, they are not templates) and adjust the contents by removing the first parts (like EHLO:, RCPT TO:, MAIL FROM:).
Documentation preview for this PR is ready! 🎉 Built with commit: 9e29a54 |
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Docs permalink will be invalid. You'll need to defer that as a follow-up PR once this is merged, or split out the relocation of files to a separate PR and get that merged first.
- Some feedback on the reworked helper methods
-
postscreen.bats
feedback. Changes introduced are not obvious why, lacks context.
The final 2 commits where the bulk of changes with diffs exist is yet to be reviewed.
While I prefer keeping Thanks for putting in the time and effort! ❤️
👍 NOTE: You'll want to extract out Commit: use swaks now instead of nc
🎉 🚀 Commit: move e-mails and adjust contents slightly
Renames with modifications to those same files in a single commit 😭 For context, the SMTP commands are removed in favor of retaining only the
The bulk of our "templates" had a fairly consistent set of values, with most using the following command pattern:
There is some drift, and this PR also adds some inconsistencies. I'll touch on that separately. Commit: adjust tests to use new functions I haven't got around to reviewing these two properly yet. I'll tackle them in my next review pass. |
The supervisord config was recently updated for Postgrey to log to it's own file. The test was changed accordingly and passed #3724 Doesn't seem like it'd be related to that 🤔 The test-case has a
Presumably this:
Would not result in I'm note sure why the test fails now though, since all we're doing is using This is reliant upon: While the test-case after that passes has relatively the same configs: It may be affected by prior test-cases, where your changes aren't producing the same interaction anymore? (you could verify by bringing back the removed test helper method from that file) I'd first tail the log to verify that it's actually getting the content we want to check for. It's probably unlikely, but perhaps the blank line you dropped affects the outcome with |
I tried this, many times, with different configurations, but it never worked, so I used the STDIN approach. Might be worth adding a comment.
This was literally it, oh dear... |
We're now seeing this error in $ make clean generate-accounts test/postscreen
postscreen.bats
✓ [Postscreen] should fail send when talking out of turn [195]
✗ [Postscreen] should successfully pass postscreen and get postfix greeting message (respecting postscreen_greet_wait time) [6408]
(from function `assert_success' in file test/test_helper/bats-assert/src/assert_success.bash, line 42,
in test file test/tests/parallel/set1/spam_virus/postscreen.bats, line 55)
`assert_success' failed
-- command failed --
status : 24
output (19 lines):
=== Trying 172.17.0.2:25...
=== Connected to 172.17.0.2.
<- 220-mail.example.test ESMTP
<- 220 mail.example.test ESMTP
-> EHLO mail.external.tld
<- 250-mail.example.test
<- 250-PIPELINING
<- 250-SIZE 10240000
<- 250-ETRN
<- 250-ENHANCEDSTATUSCODES
<- 250-8BITMIME
<- 250 CHUNKING
-> MAIL FROM:<user@external.tld>
<- 250 2.1.0 Ok
-> RCPT TO:<user1@localhost.localdomain>
<** 450 4.1.8 <user@external.tld>: Sender address rejected: Domain not found
-> QUIT
<- 221 2.0.0 Bye
=== Connection closed with remote host.
--
2 tests, 1 failure in 11 seconds
make: *** [Makefile:70: test/postscreen] Error 1 |
Interesting that it doesn't seem relevant to other tests that are using similar files missing the blank line.. Could be that your removed line version was lacking the trailing LF (but then editorconfig rule should have caught it).
https://github.com/docker-mailserver/docker-mailserver/pull/3732/files#r1438741770 The test was previously handled this way: # NOTE: Sometimes fails on first attempt (trying too soon?),
# Instead of a `run` + asserting partial, Using repeat + internal grep match:
_repeat_until_success_or_timeout 10 _should_wait_turn_speaking_smtp \
"${CONTAINER2_NAME}" \
"${CONTAINER1_IP}" \
'/tmp/docker-mailserver-test/email-templates/postscreen.txt' \
'220 mail.example.test ESMTP' While now it is: # Send from mail client container (CONTAINER2_NAME) to DMS server container (CONTAINER1_NAME):
CONTAINER_NAME=${CONTAINER2_NAME} _send_email --server "${CONTAINER1_IP}" 'postscreen'
assert_success The pass condition has changed. Originally we only cared about that first response from DMS as success, now you're expecting the full transaction to be successful. Looks like we were working around the issue 😝
Probably making a DNS lookup, and This failure condition will be due to the sender restriction, specifically We recently had an issue related to the
This highlights a reason for why I want tests that send mail to ideally be handled from a separate container and MTA (HELO/EHLO) + sender domain to better test in conditions that reflect actual deployment :) a) Without throwing CoreDNS into the mix, I think we could use Both are simple to manage with Alternatively, less correct solutions:
|
Reviewing the next two commits now (removal of SMTP commands from email "templates" + test adjustments), this'll take me a while. I'll provide a new checklist summary after that, so we can quickly get this review wrapped up and PR merged 🥳 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry took a bit longer than expected. Not complete but most of it is covered.
No time tonight to summarize unfortunately. Some of the feedback is just contextual notes without any action required in this PR.
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This change is not meant to be permanent, but only to make handling file names uniform for now.
I hope I addressed all of your very valuable feedback now. I have opened an issue to track the follow-up changes to this PR (that ought to be easier to come up with, and review - fingers crossed). From 1a65775 onward, review commit by commit; I grouped the changes. I also resolved the conversations that I addressed, and I left the feedback unresolved that can (and will) be resolved only later. |
Oh, I thought I fixed everything. The last issue in the test about disabled ClamAV/SA could be resolved by adding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks to be in a pretty good state now 👍
Didn't have as much time today, but will return tomorrow. Should be good for @casperklein to weigh in if he wants to review.
@casperklein do you want to review as well or is it okay if we merge with @polarathene's review alone? |
I can't say when I'll have time for this. So if tests are passing and you both think the changes are fine, go ahead and merge 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll apply these changes and merge.
- SMTP Smuggling fix PR will be tested against this first, then merged.
- I'll go over existing PRs open that need to be rebased and adjusted to accommodate changes here.
- Debian Bookworm base image update PR will get same treatment, not sure if I'll merge that before other pending PRs 😅 Whatever is less friction.
- I'll then go back to my notes/feedback on this PR to raise/document future work related to what was discussed here 👍
swaks
instead of nc
swaks
instead of nc
for sending mail
Description
Use
swaks
instead ofnc
. This PR is a blocker for properly implementing #3727. Review commit by commit.Fixes #3728
Type of change
Checklist:
docs/
)CHANGELOG.md