本文整理汇总了C#中RegressionTests.Shared.TcpConnection.HandshakeAsClient方法的典型用法代码示例。如果您正苦于以下问题:C# TcpConnection.HandshakeAsClient方法的具体用法?C# TcpConnection.HandshakeAsClient怎么用?C# TcpConnection.HandshakeAsClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RegressionTests.Shared.TcpConnection
的用法示例。
在下文中一共展示了TcpConnection.HandshakeAsClient方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandshakeCompletionShouldBeLoggedWithCipherDetails
public void HandshakeCompletionShouldBeLoggedWithCipherDetails()
{
var smtpClientSimulator = new TcpConnection();
smtpClientSimulator.Connect(25002);
var banner = smtpClientSimulator.Receive();
var capabilities1 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");
Assert.IsTrue(capabilities1.Contains("STARTTLS"));
smtpClientSimulator.SendAndReceive("STARTTLS\r\n");
smtpClientSimulator.HandshakeAsClient();
var capabilities2 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");
var default_log = LogHandler.ReadCurrentDefaultLog();
Assert.IsTrue(default_log.Contains("Version: TLS"));
Assert.IsTrue(default_log.Contains("Cipher: "));
Assert.IsTrue(default_log.Contains("Bits: "));
}
示例2: IfStlsRequiredLogonShouldSucceedIfStls
public void IfStlsRequiredLogonShouldSucceedIfStls()
{
var smtpClientSimulator = new TcpConnection();
smtpClientSimulator.Connect(25003);
var banner = smtpClientSimulator.Receive();
var capabilities1 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");
Assert.IsTrue(capabilities1.Contains("STARTTLS"));
smtpClientSimulator.SendAndReceive("STARTTLS\r\n");
smtpClientSimulator.HandshakeAsClient();
var loginResult = smtpClientSimulator.SendAndReceive("AUTH LOGIN\r\n");
Assert.IsTrue(loginResult.StartsWith("334"));
}
示例3: StartTlsCommandShouldSwithToTls
public void StartTlsCommandShouldSwithToTls()
{
var smtpClientSimulator = new TcpConnection();
smtpClientSimulator.Connect(25002);
var banner = smtpClientSimulator.Receive();
var capabilities1 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");
Assert.IsTrue(capabilities1.Contains("STARTTLS"));
smtpClientSimulator.SendAndReceive("STARTTLS\r\n");
smtpClientSimulator.HandshakeAsClient();
// Send a command over TLS.
var capabilities2 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");
Assert.IsFalse(capabilities2.Contains("STARTTLS"));
// We're now on SSL.
}
示例4: TestPlaintextCommandInjection
public void TestPlaintextCommandInjection()
{
var smtpClientSimulator = new TcpConnection();
smtpClientSimulator.Connect(25002);
var banner = smtpClientSimulator.Receive();
var capabilities1 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");
Assert.IsTrue(capabilities1.Contains("STARTTLS"));
var resp = smtpClientSimulator.SendAndReceive("STARTTLS\r\nRSET\r\n");
Assert.AreEqual("220 Ready to start TLS\r\n", resp);
smtpClientSimulator.HandshakeAsClient();
var quitResponse = smtpClientSimulator.SendAndReceive("QUIT\r\n");
Assert.AreEqual(quitResponse, "221 goodbye\r\n");
var default_log = LogHandler.ReadCurrentDefaultLog();
Assert.IsFalse(default_log.Contains("RSET"));
}