public void SetupSSLCertificateWithPassword() { string originalPath = Environment.CurrentDirectory; Environment.CurrentDirectory = Environment.CurrentDirectory + "\\..\\..\\..\\SSL examples\\WithPassword"; string sslPath = Environment.CurrentDirectory; Environment.CurrentDirectory = originalPath; SSLCertificate sslCertificate = _application.Settings.SSLCertificates.Add(); sslCertificate.Name = "Example"; sslCertificate.CertificateFile = sslPath + "\\server.crt"; sslCertificate.PrivateKeyFile = sslPath + "\\server.key"; sslCertificate.Save(); TCPIPPort port = _application.Settings.TCPIPPorts.Add(); port.Address = "0.0.0.0"; port.PortNumber = 251; port.UseSSL = true; port.SSLCertificateID = sslCertificate.ID; port.Protocol = eSessionType.eSTSMTP; port.Save(); _application.Stop(); _application.Start(); TestSetup.AssertReportedError(); SingletonProvider <TestSetup> .Instance.DoBasicSetup(); }
public void SetupSSLCertificateWithPassword() { string sslPath = Path.Combine(SslSetup.GetSslCertPath(), "WithPassword"); SSLCertificate sslCertificate = _application.Settings.SSLCertificates.Add(); sslCertificate.Name = "Example"; sslCertificate.CertificateFile = sslPath + "\\server.crt"; sslCertificate.PrivateKeyFile = sslPath + "\\server.key"; sslCertificate.Save(); TCPIPPort port = _application.Settings.TCPIPPorts.Add(); port.Address = "0.0.0.0"; port.PortNumber = 251; port.UseSSL = true; port.SSLCertificateID = sslCertificate.ID; port.Protocol = eSessionType.eSTSMTP; port.Save(); _application.Stop(); _application.Start(); CustomAsserts.AssertReportedError("The private key file has a password. hMailServer does not support this.", "Failed to load private key file."); SingletonProvider <TestSetup> .Instance.PerformBasicSetup(); }
public void TestDeliverToMyselfOnLocalPortAfterChangedLocalPort() { TCPIPPorts oPorts = _application.Settings.TCPIPPorts; for (int i = 0; i < oPorts.Count; i++) { TCPIPPort oTestPort = oPorts[i]; if (oTestPort.Protocol == eSessionType.eSTIMAP) { oTestPort.PortNumber = 14300; } else if (oTestPort.Protocol == eSessionType.eSTSMTP) { oTestPort.PortNumber = 11000; } else if (oTestPort.Protocol == eSessionType.eSTPOP3) { oTestPort.PortNumber = 2500; } oTestPort.Save(); } _application.Stop(); _application.Start(); // Set up a server and start listening. var deliveryResults = new Dictionary <string, int>(); deliveryResults["*****@*****.**"] = 250; int smtpServerPort = TestSetup.GetNextFreePort(); using (var server = new SMTPServerSimulator(1, smtpServerPort)) { server.AddRecipientResult(deliveryResults); server.StartListen(); // Add a route so we can connect to localhost. AddRoutePointingAtLocalhost(5, smtpServerPort, false); // Send message to this route. var sim = new SMTPClientSimulator(false, 11000); sim.Send("*****@*****.**", "*****@*****.**", "Test", "Test message"); // Wait for the client to disconnect. server.WaitForCompletion(); TestSetup.AssertRecipientsInDeliveryQueue(0, false); CustomAssert.IsTrue(server.MessageData.Contains("Test message")); } oPorts.SetDefault(); _application.Stop(); _application.Start(); }
public void TestPortOpening() { Application oApp = SingletonProvider <TestSetup> .Instance.GetApp(); oApp.Settings.TCPIPPorts.SetDefault(); var pSMTPSimulator = new TcpConnection(); var pPOP3Simulator = new Pop3ClientSimulator(); var pIMAPSimulator = new ImapClientSimulator(); oApp.Stop(); TCPIPPorts oPorts = oApp.Settings.TCPIPPorts; for (int i = 0; i < oPorts.Count; i++) { TCPIPPort oTestPort = oPorts[i]; if (oTestPort.Protocol == eSessionType.eSTIMAP) { oTestPort.PortNumber = 14300; } else if (oTestPort.Protocol == eSessionType.eSTSMTP) { oTestPort.PortNumber = 11000; } else if (oTestPort.Protocol == eSessionType.eSTPOP3) { oTestPort.PortNumber = 2500; } oTestPort.Save(); } oApp.Start(); Assert.IsTrue(pSMTPSimulator.TestConnect(2500)); Assert.IsTrue(pSMTPSimulator.TestConnect(11000)); Assert.IsTrue(pSMTPSimulator.TestConnect(14300)); oApp.Stop(); TCPIPPort oPort = oApp.Settings.TCPIPPorts.Add(); oPort.Protocol = eSessionType.eSTSMTP; oPort.PortNumber = 25000; oPort.Save(); oApp.Start(); // Try to connect to the new port Assert.IsTrue(pSMTPSimulator.TestConnect(25000)); oApp.Stop(); // Delete the port again oApp.Settings.TCPIPPorts.DeleteByDBID(oPort.ID); // Change back the ports for (int i = 0; i < oPorts.Count; i++) { TCPIPPort oTestPort = oPorts[i]; if (oTestPort.Protocol == eSessionType.eSTIMAP) { oTestPort.PortNumber = 143; } else if (oTestPort.Protocol == eSessionType.eSTSMTP) { oTestPort.PortNumber = 25; } else if (oTestPort.Protocol == eSessionType.eSTPOP3) { oTestPort.PortNumber = 110; } oTestPort.Save(); } oApp.Start(); Assert.IsTrue(pSMTPSimulator.TestConnect(25)); Assert.IsTrue(pPOP3Simulator.TestConnect(110)); Assert.IsTrue(pPOP3Simulator.TestConnect(143)); }