Skip to content

Commit

Permalink
Fixed integration test which broke when TCPIPorts.SetDefault was upda…
Browse files Browse the repository at this point in the history
…ted to include port 587.
  • Loading branch information
martinknafve committed Mar 12, 2023
1 parent cc4f6ca commit 21f4136
Showing 1 changed file with 12 additions and 27 deletions.
39 changes: 12 additions & 27 deletions hmailserver/test/RegressionTests/Infrastructure/TCPIP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public void TestPortOpening()

application.Settings.TCPIPPorts.SetDefault();

var pSMTPSimulator = new TcpConnection();
var pPOP3Simulator = new Pop3ClientSimulator();
var pIMAPSimulator = new ImapClientSimulator();
var tcpConnection = new TcpConnection();

application.Stop();

Expand All @@ -56,19 +54,19 @@ public void TestPortOpening()
TCPIPPort testPort = ports[i];
if (testPort.Protocol == eSessionType.eSTIMAP)
testPort.PortNumber = 14300;
else if (testPort.Protocol == eSessionType.eSTSMTP)
testPort.PortNumber = 11000;
else if (testPort.Protocol == eSessionType.eSTPOP3)
testPort.PortNumber = 11000;
else if (testPort.Protocol == eSessionType.eSTSMTP && testPort.PortNumber == 25)
testPort.PortNumber = 2500;

testPort.Save();
}

application.Start();

Assert.IsTrue(pSMTPSimulator.TestConnect(2500));
Assert.IsTrue(pSMTPSimulator.TestConnect(11000));
Assert.IsTrue(pSMTPSimulator.TestConnect(14300));
Assert.IsTrue(tcpConnection.TestConnect(2500));
Assert.IsTrue(tcpConnection.TestConnect(11000));
Assert.IsTrue(tcpConnection.TestConnect(14300));

application.Stop();

Expand All @@ -80,32 +78,19 @@ public void TestPortOpening()
application.Start();

// Try to connect to the new port
Assert.IsTrue(pSMTPSimulator.TestConnect(25000));
Assert.IsTrue(tcpConnection.TestConnect(25000));

application.Stop();

// Delete the port again
application.Settings.TCPIPPorts.DeleteByDBID(port.ID);

// Change back the ports
for (int i = 0; i < ports.Count; i++)
{
TCPIPPort testPort = ports[i];
if (testPort.Protocol == eSessionType.eSTIMAP)
testPort.PortNumber = 143;
else if (testPort.Protocol == eSessionType.eSTSMTP)
testPort.PortNumber = 25;
else if (testPort.Protocol == eSessionType.eSTPOP3)
testPort.PortNumber = 110;

testPort.Save();
}
application.Settings.TCPIPPorts.SetDefault();

application.Start();

Assert.IsTrue(pSMTPSimulator.TestConnect(25));
Assert.IsTrue(pPOP3Simulator.TestConnect(110));
Assert.IsTrue(pPOP3Simulator.TestConnect(143));
Assert.IsTrue(tcpConnection.TestConnect(25));
Assert.IsTrue(tcpConnection.TestConnect(587));
Assert.IsTrue(tcpConnection.TestConnect(110));
Assert.IsTrue(tcpConnection.TestConnect(143));
}

[Test]
Expand Down

0 comments on commit 21f4136

Please sign in to comment.