当前位置: 首页>>代码示例>>C#>>正文


C# TcpConnection.HandshakeAsClient方法代码示例

本文整理汇总了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: "));
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:19,代码来源:SmtpServerTests.cs

示例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"));
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:14,代码来源:SmtpServerTests.cs

示例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.
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:17,代码来源:SmtpServerTests.cs

示例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"));
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:18,代码来源:SmtpServerTests.cs


注:本文中的RegressionTests.Shared.TcpConnection.HandshakeAsClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。