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.
hMailServer should be able to deliver to servers not supporting EHLO. h…
- Loading branch information
1 parent
48ef3d1
commit f76a9d6
Showing
5 changed files
with
221 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,17 @@ namespace RegressionTests.SMTP | |
[TestFixture] | ||
public class SMTPClientStartTLSTests : TestFixtureBase | ||
{ | ||
private Status _status; | ||
private Account _account; | ||
|
||
[SetUp] | ||
public new void SetUp() | ||
{ | ||
_status = _application.Status; | ||
|
||
_account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test"); | ||
} | ||
|
||
[Test] | ||
public void UseStartTlsIfEnabledAndAvailable() | ||
{ | ||
|
@@ -131,5 +142,76 @@ public void DoNotUseStartTlsIfNotEnabledAndNotAvailable() | |
CustomAssert.IsFalse(TestSetup.DefaultLogContains("220 Ready to start TLS")); | ||
} | ||
} | ||
|
||
|
||
|
||
[Test] | ||
public void TestDelivertoServerNotSupportingEHLOOptionalConnectionSecurity() | ||
{ | ||
CustomAssert.AreEqual(0, _status.UndeliveredMessages.Length); | ||
|
||
var deliveryResults = new Dictionary<string, int>() | ||
{ | ||
{"[email protected]", 250} | ||
}; | ||
|
||
int smtpServerPort = TestSetup.GetNextFreePort(); | ||
using (var server = new SMTPServerSimulator(1, smtpServerPort)) | ||
{ | ||
server.ServerSupportsEhlo = false; | ||
server.AddRecipientResult(deliveryResults); | ||
server.StartListen(); | ||
|
||
// Add a route so we can conenct to localhost. | ||
SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSSTARTTLSOptional); | ||
|
||
// Send message to this route. | ||
|
||
if (!SMTPClientSimulator.StaticSend("[email protected]", "[email protected]", "Test", "Test message")) | ||
CustomAssert.Fail("Delivery failed"); | ||
|
||
// Wait for the client to disconnect. | ||
server.WaitForCompletion(); | ||
|
||
TestSetup.AssertRecipientsInDeliveryQueue(0, false); | ||
|
||
CustomAssert.IsTrue(server.MessageData.Contains("Test message")); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TestDeliverToServerNotSupportingEHLORequiredConnectionSecurity() | ||
{ | ||
CustomAssert.AreEqual(0, _status.UndeliveredMessages.Length); | ||
|
||
var deliveryResults = new Dictionary<string, int>() | ||
{ | ||
{"[email protected]", 250} | ||
}; | ||
|
||
int smtpServerPort = TestSetup.GetNextFreePort(); | ||
using (var server = new SMTPServerSimulator(1, smtpServerPort)) | ||
{ | ||
server.ServerSupportsEhlo = false; | ||
server.AddRecipientResult(deliveryResults); | ||
server.StartListen(); | ||
|
||
// Add a route so we can conenct to localhost. | ||
SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSSTARTTLSRequired); | ||
|
||
// Send message to this route. | ||
|
||
if (!SMTPClientSimulator.StaticSend("[email protected]", "[email protected]", "Test", "Test message")) | ||
CustomAssert.Fail("Delivery failed"); | ||
|
||
// Wait for the client to disconnect. | ||
server.WaitForCompletion(); | ||
|
||
TestSetup.AssertRecipientsInDeliveryQueue(0, true); | ||
|
||
var msg = POP3ClientSimulator.AssertGetFirstMessageText("[email protected]", "test"); | ||
CustomAssert.IsTrue(msg.Contains("Server does not support EHLO command.")); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -268,7 +268,6 @@ public void TestDeliverySuccess50Recipients() | |
} | ||
} | ||
|
||
|
||
|
||
[Test] | ||
[Description( | ||
|
@@ -1025,5 +1024,74 @@ public void TestTemporaryFailure() | |
CustomAssert.IsTrue(message.Contains("452 [email protected]")); | ||
CustomAssert.IsTrue(message.Contains("Tried 2 time(s)")); | ||
} | ||
|
||
[Test] | ||
public void TestDeliverToServerNotSupportingEHLO() | ||
{ | ||
CustomAssert.AreEqual(0, _status.UndeliveredMessages.Length); | ||
|
||
var deliveryResults = new Dictionary<string, int>() | ||
{ | ||
{"[email protected]", 250} | ||
}; | ||
|
||
int smtpServerPort = TestSetup.GetNextFreePort(); | ||
using (var server = new SMTPServerSimulator(1, smtpServerPort)) | ||
{ | ||
server.ServerSupportsEhlo = false; | ||
server.AddRecipientResult(deliveryResults); | ||
server.StartListen(); | ||
|
||
// Add a route so we can conenct to localhost. | ||
SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone); | ||
|
||
// Send message to this route. | ||
|
||
if (!SMTPClientSimulator.StaticSend("[email protected]", "[email protected]", "Test", "Test message")) | ||
CustomAssert.Fail("Delivery failed"); | ||
|
||
// Wait for the client to disconnect. | ||
server.WaitForCompletion(); | ||
|
||
TestSetup.AssertRecipientsInDeliveryQueue(0, false); | ||
|
||
CustomAssert.IsTrue(server.MessageData.Contains("Test message")); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TestDeliverToServerNotSupportingHELO() | ||
{ | ||
CustomAssert.AreEqual(0, _status.UndeliveredMessages.Length); | ||
|
||
var deliveryResults = new Dictionary<string, int>() | ||
{ | ||
{"[email protected]", 250} | ||
}; | ||
|
||
int smtpServerPort = TestSetup.GetNextFreePort(); | ||
using (var server = new SMTPServerSimulator(1, smtpServerPort)) | ||
{ | ||
server.ServerSupportsHelo = false; | ||
server.AddRecipientResult(deliveryResults); | ||
server.StartListen(); | ||
|
||
// Add a route so we can conenct to localhost. | ||
SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone); | ||
|
||
// Send message to this route. | ||
|
||
if (!SMTPClientSimulator.StaticSend("[email protected]", "[email protected]", "Test", "Test message")) | ||
CustomAssert.Fail("Delivery failed"); | ||
|
||
// Wait for the client to disconnect. | ||
server.WaitForCompletion(); | ||
|
||
TestSetup.AssertRecipientsInDeliveryQueue(0, true); | ||
|
||
var msg = POP3ClientSimulator.AssertGetFirstMessageText("[email protected]", "test"); | ||
CustomAssert.IsTrue(msg.Contains("Remote server replied: 550 Command HELO not recognized.")); | ||
} | ||
} | ||
} | ||
} |
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