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.
Moved AddRoutePointingAtLocalhost from SMTPClientTests to TestSetup s…
…ince it's shared by many tests (minor)
- Loading branch information
1 parent
2991d91
commit 8707a79
Showing
9 changed files
with
94 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -536,7 +536,7 @@ public void ActionSendUsingRoute() | |
Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test"); | ||
|
||
// Add a route so we can conenct to localhost. | ||
Route route = SMTPClientTests.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
Route route = TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Add a global send-using-route rule | ||
Rule oRule = _application.Rules.Add(); | ||
|
@@ -1336,7 +1336,7 @@ public void TestDeliveryAttempts() | |
smtpServer.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
SMTPClientTests.AddRoutePointingAtLocalhost(2, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(2, smtpServerPort, false); | ||
|
||
var oSMTP = new SmtpClientSimulator(); | ||
|
||
|
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 |
---|---|---|
|
@@ -125,7 +125,7 @@ public void DomainAliasesShouldNotRewriteRecipientList() | |
server.StartListen(); | ||
|
||
|
||
Route route = SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, true, eConnectionSecurity.eCSNone); | ||
Route route = TestSetup.AddRoutePointingAtLocalhost(1, smtpServerPort, true, eConnectionSecurity.eCSNone); | ||
|
||
// Now send a message from [email protected] to [email protected]. | ||
// Error scenario: | ||
|
@@ -485,7 +485,7 @@ public void TestMultipleHostsLimitMXHosts() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
Route route = SMTPClientTests.AddRoutePointingAtLocalhostMultipleHosts(2, smtpServerPort); | ||
Route route = TestSetup.AddRoutePointingAtLocalhostMultipleHosts(2, smtpServerPort); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -689,7 +689,7 @@ public void TestSendExternalToExternalPermitted() | |
server.AddRecipientResult(deliveryResults); | ||
server.StartListen(); | ||
|
||
Route route = SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone); | ||
Route route = TestSetup.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone); | ||
|
||
var oSMTP = new SmtpClientSimulator(); | ||
oSMTP.Send("[email protected]", | ||
|
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 |
---|---|---|
|
@@ -30,44 +30,6 @@ public class SMTPClientTests : TestFixtureBase | |
private Status _status; | ||
private Account _account; | ||
|
||
internal static Route AddRoutePointingAtLocalhost(int numberOfTries, int port, bool treatSecurityAsLocal, eConnectionSecurity connectionSecurity) | ||
{ | ||
// Add a route pointing at localhost | ||
Settings oSettings = SingletonProvider<TestSetup>.Instance.GetApp().Settings; | ||
|
||
Route route = oSettings.Routes.Add(); | ||
route.DomainName = "dummy-example.com"; | ||
route.TargetSMTPHost = "localhost"; | ||
route.TargetSMTPPort = port; | ||
route.NumberOfTries = numberOfTries; | ||
route.MinutesBetweenTry = 5; | ||
route.TreatRecipientAsLocalDomain = treatSecurityAsLocal; | ||
route.TreatSenderAsLocalDomain = treatSecurityAsLocal; | ||
route.ConnectionSecurity = connectionSecurity; | ||
route.Save(); | ||
|
||
return route; | ||
} | ||
|
||
internal static Route AddRoutePointingAtLocalhost(int numberOfTries, int port, bool treatSecurityAsLocal) | ||
{ | ||
return AddRoutePointingAtLocalhost(numberOfTries, port, treatSecurityAsLocal, eConnectionSecurity.eCSNone); | ||
} | ||
|
||
public static Route AddRoutePointingAtLocalhostMultipleHosts(int numberOfTries, int port) | ||
{ | ||
// Add a route pointing at localhost | ||
Route route = AddRoutePointingAtLocalhost(numberOfTries, port, false); | ||
route.DomainName = "dummy-example.com"; | ||
route.TargetSMTPHost = "localhost|localhost"; | ||
route.TargetSMTPPort = port; | ||
route.NumberOfTries = numberOfTries; | ||
route.MinutesBetweenTry = 5; | ||
route.Save(); | ||
|
||
return route; | ||
} | ||
|
||
[Test] | ||
[Description("Make sure that the bounce message doesn't include a SMTP auth password")] | ||
public void TestAuthFailurePasswordInBounce() | ||
|
@@ -86,7 +48,7 @@ public void TestAuthFailurePasswordInBounce() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
Route route = AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
Route route = TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
route.RelayerRequiresAuth = true; | ||
route.RelayerAuthUsername = "[email protected]"; | ||
route.SetRelayerAuthPassword("MySecretPassword"); | ||
|
@@ -118,7 +80,7 @@ public void TestDeliverToMyselfOnLocalPort() | |
Assert.AreEqual(0, _status.UndeliveredMessages.Length); | ||
|
||
// Add a route so we can conenct to localhost. | ||
AddRoutePointingAtLocalhost(1, 25, false); | ||
TestSetup.AddRoutePointingAtLocalhost(1, 25, false); | ||
|
||
// Send message to this route. | ||
SmtpClientSimulator.StaticSend("[email protected]", "[email protected]", "subject", "body"); | ||
|
@@ -171,7 +133,7 @@ public void TestDeliverToMyselfOnLocalPortAfterChangedLocalPort() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var sim = new SmtpClientSimulator(false, 11000); | ||
|
@@ -210,7 +172,7 @@ public void TestDeliverySuccess250Recipients() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -248,7 +210,7 @@ public void TestDeliverySuccess50Recipients() | |
server.StartListen(); | ||
|
||
// Add a route so we can conenct to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -289,7 +251,7 @@ public void TestDeliverySuccessDisconnectAfterMessageAccept() | |
server.SimulatedError = SimulatedErrorType.DisconnectAfterMessageAccept; | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -322,7 +284,7 @@ public void TestDeliverySuccessSingleRecipient() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -357,7 +319,7 @@ public void TestLargeMessageSuccess() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var messageBody = TestSetup.CreateLargeDummyMailBody(); | ||
|
@@ -396,7 +358,7 @@ public void TestDeliverySuccessSingleRecipientMissingQuitResponse() | |
server.SimulatedError = SimulatedErrorType.DisconnectWithoutReplyOnQuit; | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -431,7 +393,7 @@ public void TestErrorOnMailFrom() | |
server.StartListen(); | ||
|
||
// Add a route so we can conenct to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -471,7 +433,7 @@ public void TestFailureAfterConnect() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(1, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(1, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -514,7 +476,7 @@ public void TestFailureAfterDelivery() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -551,7 +513,7 @@ public void TestFailureAfterDeliveryStarted() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(1, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(1, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -593,7 +555,7 @@ public void TestFailureAfterReceivedHelloBanner() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(1, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(1, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -636,7 +598,7 @@ public void TestFatalDeliveryFailure() | |
server.StartListen(); | ||
|
||
// Add a route so we can conenct to localhost. | ||
AddRoutePointingAtLocalhost(0, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(0, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -698,7 +660,7 @@ public void TestMultipleHostsHalfDeliveryOnFirstPermanentOnSecond() | |
|
||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhostMultipleHosts(1, smtpServerPort); | ||
TestSetup.AddRoutePointingAtLocalhostMultipleHosts(1, smtpServerPort); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -744,7 +706,7 @@ public void TestMultipleHostsTemporaryFailure() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
Route route = AddRoutePointingAtLocalhostMultipleHosts(2, smtpServerPort); | ||
Route route = TestSetup.AddRoutePointingAtLocalhostMultipleHosts(2, smtpServerPort); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -814,7 +776,7 @@ public void TestMultipleHostsTemporaryFailureDeliveryOnSecondServer() | |
|
||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhostMultipleHosts(2, smtpServerPort); | ||
TestSetup.AddRoutePointingAtLocalhostMultipleHosts(2, smtpServerPort); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -856,7 +818,7 @@ public void TestPartialTemporaryErrorFailure() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(2, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(2, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -916,7 +878,7 @@ public void TestPermanentFailure() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -957,7 +919,7 @@ public void TestSMTPClientTimeout() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
Route route = AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
Route route = TestSetup.AddRoutePointingAtLocalhost(5, smtpServerPort, false); | ||
route.RelayerRequiresAuth = true; | ||
route.RelayerAuthUsername = "[email protected]"; | ||
route.SetRelayerAuthPassword("MySecretPassword"); | ||
|
@@ -990,7 +952,7 @@ public void TestTemporaryFailure() | |
server.StartListen(); | ||
|
||
// Add a route so we can connect to localhost. | ||
AddRoutePointingAtLocalhost(2, smtpServerPort, false); | ||
TestSetup.AddRoutePointingAtLocalhost(2, smtpServerPort, false); | ||
|
||
// Send message to this route. | ||
var smtp = new SmtpClientSimulator(); | ||
|
@@ -1043,7 +1005,7 @@ public void TestDeliverToServerNotSupportingEHLO() | |
server.StartListen(); | ||
|
||
// Add a route so we can conenct to localhost. | ||
SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone); | ||
TestSetup.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone); | ||
|
||
|
||
SmtpClientSimulator.StaticSend("[email protected]", "[email protected]", "Test", "Test message"); | ||
|
@@ -1075,7 +1037,7 @@ public void TestDeliverToServerNotSupportingHELO() | |
server.StartListen(); | ||
|
||
// Add a route so we can conenct to localhost. | ||
SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone); | ||
TestSetup.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone); | ||
|
||
// Send message to this route. | ||
|
||
|
Oops, something went wrong.