forked from hmailserver/hmailserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for wildcard routes. It's now possible to set up a rou…
…te such as *.example.com and have it match all example.com sub domains.
- Loading branch information
1 parent
fa6cb42
commit 1066e31
Showing
11 changed files
with
233 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,49 +168,6 @@ public void MailFromShouldNotUpdatedLastLogonTime() | |
Assert.AreEqual(lastLogonTimeBefore, lastLogonTimeAfter); | ||
} | ||
|
||
[Test] | ||
[Description("Issue 284. Sender to Alias to Route not working.")] | ||
public void SendMessageToAliasForwardToRoute() | ||
{ | ||
// Set up a server listening on port 250 which accepts email for [email protected] | ||
var deliveryResults = new Dictionary<string, int>(); | ||
deliveryResults["[email protected]"] = 250; | ||
|
||
int smtpServerPort = TestSetup.GetNextFreePort(); | ||
using (var server = new SMTPServerSimulator(1, smtpServerPort)) | ||
{ | ||
server.AddRecipientResult(deliveryResults); | ||
server.StartListen(); | ||
|
||
// Add a route pointing at localhost | ||
Route route = _settings.Routes.Add(); | ||
route.DomainName = "test.com"; | ||
route.TargetSMTPHost = "localhost"; | ||
route.TargetSMTPPort = smtpServerPort; | ||
route.NumberOfTries = 1; | ||
route.MinutesBetweenTry = 5; | ||
route.TreatRecipientAsLocalDomain = true; | ||
route.TreatSenderAsLocalDomain = true; | ||
route.AllAddresses = false; | ||
route.Save(); | ||
|
||
// Make sure only the specific user is valid. | ||
RouteAddress routeAddress = route.Addresses.Add(); | ||
routeAddress.Address = "user@" + _domain.Name; | ||
routeAddress.Save(); | ||
|
||
SingletonProvider<TestSetup>.Instance.AddAlias(_domain, "[email protected]", "[email protected]"); | ||
|
||
var smtpClient = new SMTPClientSimulator(); | ||
Assert.IsTrue(smtpClient.Send("[email protected]", "[email protected]", "Test", "Test message")); | ||
TestSetup.AssertRecipientsInDeliveryQueue(0); | ||
|
||
server.WaitForCompletion(); | ||
|
||
Assert.IsTrue(server.MessageData.Contains("Test message")); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TestAntiVirusEnabled() | ||
{ | ||
|
@@ -989,103 +946,6 @@ public void TestWelcomeMessage() | |
throw new Exception("ERROR - Wrong welcome message."); | ||
} | ||
|
||
|
||
[Test] | ||
[Description("If both route and SMTP relay is in use, route should have higher priortiy..")] | ||
public void RoutesShouldHaveHigherPrioThanSMTPRelay() | ||
{ | ||
// Set up a server listening on port 250 which accepts email for [email protected] | ||
var deliveryResults = new Dictionary<string, int>(); | ||
deliveryResults["[email protected]"] = 250; | ||
|
||
// We set the SMTP relayer here, but this should be ignored since the recipient's | ||
// address matches a route set up (test.com). | ||
_application.Settings.SMTPRelayer = "example.com"; | ||
|
||
int smtpServerPort = TestSetup.GetNextFreePort(); | ||
using (var server = new SMTPServerSimulator(1, smtpServerPort)) | ||
{ | ||
server.AddRecipientResult(deliveryResults); | ||
server.StartListen(); | ||
|
||
// Add a route pointing at localhost | ||
Route route = _settings.Routes.Add(); | ||
route.DomainName = "test.com"; | ||
route.TargetSMTPHost = "localhost"; | ||
route.TargetSMTPPort = smtpServerPort; | ||
route.NumberOfTries = 1; | ||
route.MinutesBetweenTry = 5; | ||
route.TreatRecipientAsLocalDomain = true; | ||
route.TreatSenderAsLocalDomain = true; | ||
route.AllAddresses = false; | ||
route.Save(); | ||
|
||
// Make sure only the specific user is valid. | ||
RouteAddress routeAddress = route.Addresses.Add(); | ||
routeAddress.Address = "user@" + _domain.Name; | ||
routeAddress.Save(); | ||
|
||
SingletonProvider<TestSetup>.Instance.AddAlias(_domain, "[email protected]", "[email protected]"); | ||
|
||
var smtpClient = new SMTPClientSimulator(); | ||
Assert.IsTrue(smtpClient.Send("[email protected]", "[email protected]", "Test", "Test message")); | ||
TestSetup.AssertRecipientsInDeliveryQueue(0); | ||
|
||
server.WaitForCompletion(); | ||
|
||
Assert.IsTrue(server.MessageData.Contains("Test message")); | ||
} | ||
} | ||
|
||
[Test] | ||
[Description("If a message with 4 recipients on the same domain is is delivered via a route, only one message should be delivered.")] | ||
public void RoutesShouldConsolidateRecipients() | ||
{ | ||
// Set up a server listening on port 250 which accepts email for [email protected] | ||
var deliveryResults = new Dictionary<string, int>(); | ||
deliveryResults["[email protected]"] = 250; | ||
deliveryResults["[email protected]"] = 250; | ||
deliveryResults["[email protected]"] = 250; | ||
deliveryResults["[email protected]"] = 250; | ||
|
||
int smtpServerPort = TestSetup.GetNextFreePort(); | ||
using (var server = new SMTPServerSimulator(1, smtpServerPort)) | ||
{ | ||
server.AddRecipientResult(deliveryResults); | ||
server.StartListen(); | ||
|
||
// Add a route pointing at localhost | ||
Route route = _settings.Routes.Add(); | ||
route.DomainName = "test.com"; | ||
route.TargetSMTPHost = "localhost"; | ||
route.TargetSMTPPort = smtpServerPort; | ||
route.NumberOfTries = 1; | ||
route.MinutesBetweenTry = 5; | ||
route.TreatRecipientAsLocalDomain = true; | ||
route.TreatSenderAsLocalDomain = true; | ||
route.AllAddresses = true; | ||
route.Save(); | ||
|
||
var smtpClient = new SMTPClientSimulator(); | ||
|
||
var recipients = new List<string>() | ||
{ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]" | ||
}; | ||
|
||
Assert.IsTrue(smtpClient.Send("[email protected]", recipients, "Test", "Test message")); | ||
TestSetup.AssertRecipientsInDeliveryQueue(0); | ||
|
||
server.WaitForCompletion(); | ||
|
||
Assert.IsTrue(server.MessageData.Contains("Test message")); | ||
Assert.AreEqual(deliveryResults.Count, server.RcptTosReceived); | ||
} | ||
} | ||
|
||
[Test] | ||
[Description("If a message with 4 recipients on different domains, but all are to be sent through the same SMTP relay, only one message should be sent")] | ||
public void SmtpRelayShouldConsolidateRecipients() | ||
|
Oops, something went wrong.