public void S1_ConnectionTest_ConnectionInitiation_PositiveTest_RDPNegotiationFailure() { #region Test Steps /* * 1). Trigger SUT to initiate a RDP connection with sending a Client X.224 Connection Request PDU. * 2). Test Suite responds a Server X.224 Connection Confirm PDU and set the failureCode of RDP_NEG_FAILURE field according the requestedProtocols of Client X.224 Connection Request PDU. * 3). Test Suite expects SUT drop the connection. */ #endregion #region Test Implementation //Start RDP listening. this.TestSite.Log.Add(LogEntryKind.Comment, "Starting RDP listening with transport protocol: {0}", transportProtocol.ToString()); this.rdpbcgrAdapter.StartRDPListening(transportProtocol); #region Trigger client to initiate a RDP connection //Trigger client to initiate a RDP connection. this.TestSite.Log.Add(LogEntryKind.Comment, "Triggering SUT to initiate a RDP connection to server."); triggerClientRDPConnect(transportProtocol); #endregion //Expect the transport layer connection request this.TestSite.Log.Add(LogEntryKind.Comment, "Expecting SUT to start a transport layer connection request (TCP)."); this.rdpbcgrAdapter.ExpectTransportConnection(RDPSessionType.Normal); //Expect SUT send a Client X.224 Connection Request PDU. //this.rdpbcgrAdapter.SetNeedStoreReceivePdu(); this.TestSite.Log.Add(LogEntryKind.Comment, "Expecting SUT to send a Client X.224 Connection Request PDU"); this.rdpbcgrAdapter.ExpectPacket <Client_X_224_Connection_Request_Pdu>(waitTime); failureCode_Values failureCode = GetFailureCode_RDP_NEG_FAILURE(this.rdpbcgrAdapter.SessionContext.X224ConnectionReqPdu); if (failureCode == failureCode_Values.NO_FAILURE) { // TODO: Error } //Respond a Server X.224 Negotiate Failure Confirm PDU and set the rdpNegData field to a valid RDP Negotiation Failure structure. this.TestSite.Log.Add(LogEntryKind.Comment, "Sending Server X.224 Connection Confirm PDU to SUT with fail reason {0}", failureCode.ToString()); this.rdpbcgrAdapter.Server_X_224_Negotiate_Failure(failureCode); this.TestSite.Log.Add(LogEntryKind.Comment, "Expect SUT to drop the connection"); bool bDisconnected = this.rdpbcgrAdapter.WaitForDisconnection(waitTime); this.TestSite.Assert.IsTrue(bDisconnected, "SUT should drop the connection when the RDP Negotiation Failure structure is invalid."); #endregion }
/// <summary> /// Return a reasonable failureCode according to the receving Client_X_224_Connection_Request_Pdu. /// </summary> /// <param name="pdu">the Client_X_224_Connection_Request_Pdu</param> /// <returns></returns> private failureCode_Values GetFailureCode_RDP_NEG_FAILURE(Client_X_224_Connection_Request_Pdu pdu) { failureCode_Values result = failureCode_Values.NO_FAILURE; if (pdu == null) { return(result); } bool has_PROTOCOL_RDP_FLAG = pdu.rdpNegData.requestedProtocols.HasFlag(requestedProtocols_Values.PROTOCOL_RDP_FLAG); bool has_PROTOCOL_SSL_FLAG = pdu.rdpNegData.requestedProtocols.HasFlag(requestedProtocols_Values.PROTOCOL_RDP_FLAG); bool has_PROTOCOL_HYBRID_FLAG = pdu.rdpNegData.requestedProtocols.HasFlag(requestedProtocols_Values.PROTOCOL_HYBRID_FLAG); bool has_PROTOCOL_HYBRID_EX = pdu.rdpNegData.requestedProtocols.HasFlag(requestedProtocols_Values.PROTOCOL_HYBRID_EX); if (!has_PROTOCOL_HYBRID_EX && !has_PROTOCOL_HYBRID_FLAG && has_PROTOCOL_SSL_FLAG) { // 0000 | 0001 result = failureCode_Values.SSL_REQUIRED_BY_SERVER; } else if (!has_PROTOCOL_HYBRID_EX && !has_PROTOCOL_HYBRID_FLAG) { // 0010 | 0011 result = failureCode_Values.HYBRID_REQUIRED_BY_SERVER; } else if (!has_PROTOCOL_SSL_FLAG) { // 1000 | 0100 | 1101 | 1100 | 1001 | 0101 | 1100 result = failureCode_Values.SSL_WITH_USER_AUTH_REQUIRED_BY_SERVER; } else if (!has_PROTOCOL_RDP_FLAG) { // 1010 | 0110 | 1110 result = failureCode_Values.SSL_CERT_NOT_ON_SERVER; } else { // 1011 | 0111 | 1111 result = failureCode_Values.INCONSISTENT_FLAGS; } return(result); }