citrusframework/citrus

Citrus 4: MailServer only binds to loopback interface

Closed this issue · 1 comments

Citrus Version
4.x

Expected behavior
Mailserver binds to all interfaces, as in Citrus 3.x, or host is configurable

Actual behavior
Mailserver binds to loopback interface only and the host is not configurable

Test case sample
SMTP interception on a host which has its mail port bound to a non loopback interface. Upgrade from Citrus 3.x to 4.x.

When we upgraded from Citrus 3 to Citrus 4, our mail tests did not work anymore. The problem was due to the default behaviour of subethasmtp vs. GreenMail. In subethasmtp, when no host is given, the mail server binds to all interfaces, whereas GreenMail will bind only to loopback per default.

As the Citrus MailServerBuilder does not have functions to set the host manually, and the MailServer initialises the GreenMail server with a hardcoded host value of null, the Citrus MailServer will only bind to the loopback interface and not receive Mails from another interfaces. This can be fixed by adding a host method to the MailServerBuilder and setting the host value instead of null for the GreenMail initialisation in the MailServer startup() function

On a side note: it also seems that if you use the smtp(GreenMail smtpServer) method from the MailServerBuilder, the given GreenMail server is overwritten in the MailServer startup() function as there is a missing null check before initialising a new GreenMail instance.

thanks for the report! definitely two bugs:

  • binding to other network interfaces, not only loopback
  • use existing mailserver when initialized from builder (null-check)

do you want to work on these and submit a PR or should I try and fix it if I find some time?