コード例 #1
0
 /// <summary>
 /// Used to verify whether a RDP connection is still exist.
 /// This function can only be used after RDP connection established and user logon.
 ///  Send a Shutdown Request PDU to the server.
 ///  Expect a Shutdown Request Denied PDU from server.
 /// </summary>
 /// <param name="timeout">Timeout when expect Shutdown Request Denied PDU</param>
 /// <returns></returns>
 public bool VerifyRDPConnection(TimeSpan timeout)
 {
     Site.Assume.IsTrue(isLogon, "VerifyRDPConnection can only used after user logon.");
     try
     {
         System.Threading.Thread.Sleep(sendInterval); // Wait some time before the verification, so the server can react to previous behaviors.
         this.SendClientShutdownRequestPDU();
         Server_Shutdown_Request_Denied_Pdu requestDenied = this.ExpectPacket <Server_Shutdown_Request_Denied_Pdu>(timeout);
         if (requestDenied != null)
         {
             return(true);
         }
         Site.Log.Add(LogEntryKind.Comment, "Timeout when receiving Server_Shutdown_Request_Denied_Pdu.");
     }
     catch (InvalidOperationException invalidE)
     {
         Site.Log.Add(LogEntryKind.Comment, "Underlayer transport throw exception indicates the connection has been terminated: " + invalidE.Message);
     }
     catch (System.IO.IOException ioE)
     {
         Site.Log.Add(LogEntryKind.Comment, "IO exception encountered: " + ioE.Message);
     }
     catch (TimeoutException)
     {
         Site.Log.Add(LogEntryKind.Comment, "Timeout when receiving Server_Shutdown_Request_Denied_Pdu.");
     }
     return(false);
 }
コード例 #2
0
        public void S1_Connection_Disconnection_PositiveTest_ClientInitiated_UserLogon()
        {
            #region Test Steps
            //1. Initiate and complete an RDP connection with RDP server (SUT).
            //2. Test suite expects a Server Save Session Info PDU to notify user logon, and verify it.
            //3. Test suite sends a Shutdown Request PDU to initiate a disconnection sequence.
            //4. Test Suite expects a Shutdown Request Denied PDU.
            #endregion Test Steps

            #region Test Code

            this.Site.Log.Add(LogEntryKind.Comment, "Establish transport connection with RDP Server, encrypted protocol is {0}.", transportProtocol.ToString());
            rdpbcgrAdapter.ConnectToServer(this.transportProtocol);

            string[] SVCNames = new string[] { RdpConstValue.SVCNAME_RDPEDYC };
            rdpbcgrAdapter.EstablishRDPConnection(requestProtocol,
                                                  SVCNames,
                                                  CompressionType.PACKET_COMPR_TYPE_RDP61,
                                                  false, // Is reconnect
                                                  true   // Is Auto logon
                                                  );

            this.Site.Log.Add(LogEntryKind.Comment, "Wait RDP server to notify user logon.");
            rdpbcgrAdapter.WaitForLogon(timeout);

            this.Site.Log.Add(LogEntryKind.Comment, "Send a Client Shutdown Request PDU.");
            rdpbcgrAdapter.SendClientShutdownRequestPDU();

            this.Site.Log.Add(LogEntryKind.Comment, "Expect a Server Shutdown Request Denied PDU from SUT.");
            Server_Shutdown_Request_Denied_Pdu requestDenied = rdpbcgrAdapter.ExpectPacket <Server_Shutdown_Request_Denied_Pdu>(timeout);
            this.Site.Assert.IsNotNull(requestDenied, "Timeout when receiving Server Shutdown Request Denied PDU, RDP Server should response a Server Shutdown Request Denied PDU if receiving a Client Shutdown Request PDU after user logon.");

            #endregion Test Code
        }
コード例 #3
0
        public void S1_Connection_Disconnection_PositiveTest_ClientInitiated_UserLogon()
        {
            #region Test Steps
            //1. Initiate and complete an RDP connection with RDP server (SUT).
            //2. Test suite expects a Server Save Session Info PDU to notify user logon, and verify it.
            //3. Test suite sends a Shutdown Request PDU to initiate a disconnection sequence.
            //4. Test Suite expects a Shutdown Request Denied PDU.
            #endregion Test Steps

            #region Test Code
            if ((this.transportProtocol == EncryptedProtocol.NegotiationCredSsp ||
                 this.transportProtocol == EncryptedProtocol.DirectCredSsp) &&
                this.rdpVersion > new Version("10.5") &&
                this.isWindowsImplementation)
            {
                Site.Assume.Fail("The case is not applicable when the SUT is Microsoft RDP, RDP version is larger than 10.5 and security protocol is CredSSP.");
            }

            this.Site.Log.Add(LogEntryKind.Comment, "Establish transport connection with RDP Server, encrypted protocol is {0}.", transportProtocol.ToString());
            rdpbcgrAdapter.ConnectToServer(this.transportProtocol);

            string[] SVCNames = new string[] { RdpConstValue.SVCNAME_RDPEDYC };
            rdpbcgrAdapter.EstablishRDPConnection(requestProtocol,
                                                  SVCNames,
                                                  CompressionType.PACKET_COMPR_TYPE_RDP61,
                                                  false, // Is reconnect
                                                  true   // Is Auto logon
                                                  );

            this.Site.Log.Add(LogEntryKind.Comment, "Wait RDP server to notify user logon.");
            rdpbcgrAdapter.WaitForLogon(timeout);

            this.Site.Log.Add(LogEntryKind.Comment, "Send a Client Shutdown Request PDU.");
            rdpbcgrAdapter.SendClientShutdownRequestPDU();

            this.Site.Log.Add(LogEntryKind.Comment, "Expect a Server Shutdown Request Denied PDU from SUT.");
            Server_Shutdown_Request_Denied_Pdu requestDenied = rdpbcgrAdapter.ExpectPacket <Server_Shutdown_Request_Denied_Pdu>(timeout);
            this.Site.Assert.IsNotNull(requestDenied, "Timeout when receiving Server Shutdown Request Denied PDU, RDP Server should response a Server Shutdown Request Denied PDU if receiving a Client Shutdown Request PDU after user logon.");

            #endregion Test Code
        }