protected override void TestInitialize() { // Verify RDP version string testName = this.TestContext.TestName; MethodInfo method = GetType().GetMethod(testName); Attribute[] attrs = Attribute.GetCustomAttributes(method); string rdpVersion = GetSupportedRDPVersion(attrs); VerifyRDPVersion(testName, rdpVersion); this.rdpbcgrAdapter = this.TestSite.GetAdapter <IRdpbcgrAdapter>(); this.sutControlAdapter = this.TestSite.GetAdapter <IRdpSutControlAdapter>(); this.rdpbcgrAdapter.Reset(); LoadConfig(); this.rdpbcgrAdapter.ConfirmActiveRequest += new ConfirmActiveRequestHandler(this.testClassBase_getConfirmActivePduInfo); if (isWindowsImplementation) { string RDPClientVersion; PtfPropUtility.GetPtfPropertyValue(Site, "Version", out RDPClientVersion); if (string.CompareOrdinal(RDPClientVersion, "10.3") == 0) // Windows client will not interrupt the connection for RDPClient 10.3. { DropConnectionForInvalidRequest = true; //A switch to avoid waiting till timeout. } else { DropConnectionForInvalidRequest = false; //A switch to avoid waiting till timeout. } } CheckPlatformCompatibility(); }
public static void BaseInitialize(TestContext context) { TestClassBase.Initialize(context); string defaultProtocolDocShortName; PtfPropUtility.GetPtfPropertyValue(BaseTestSite, "ProtocolName", out defaultProtocolDocShortName); BaseTestSite.DefaultProtocolDocShortName = defaultProtocolDocShortName; }
/// <summary> /// Initialize this adapter /// </summary> /// <param name="testSite"></param> public override void Initialize(ITestSite testSite) { base.Initialize(testSite); controlHandler = SUTControlProtocolHandler.GetInstance(testSite); // Initiate local IP string proxyIP; PtfPropUtility.GetPtfPropertyValue(testSite, "ProxyIP", out proxyIP); if (string.IsNullOrEmpty(proxyIP)) { rdpServerIP = GetLocalIP(); } else { rdpServerIP = proxyIP; } // Initiate local port try { string localPortString; PtfPropUtility.GetPtfPropertyValue(testSite, "ServerPort", out localPortString); localPort = ushort.Parse(localPortString); } catch { localPort = 0; } // Initiate Connect payload type bool clientSupportRDPFile; PtfPropUtility.GetPtfPropertyValue(testSite, "ClientSupportRDPFile", out clientSupportRDPFile, new string[] { RdpPtfGroupNames.SUTControl }); if (clientSupportRDPFile) { connectPayloadType = RDP_Connect_Payload_Type.RDP_FILE; } else { connectPayloadType = RDP_Connect_Payload_Type.PARAMETERS_STRUCT; } PtfPropUtility.GetPtfPropertyValue(testSite, "SupportCompression", out isClientSupportCompression); }
/// <summary> /// Verify the version of operation system or MSTSC /// </summary> /// <param name="testCaseName">Test case name</param> /// <param name="version">RDP version</param> private void VerifyRDPVersion(String testCaseName, String version) { try { string currentRDPVersion; PtfPropUtility.GetPtfPropertyValue(Site, "Version", out currentRDPVersion); //Validate the format of version in ptfconfig. The format of the version is required to be x.x Version currentRDPVer = null; if (!Version.TryParse(currentRDPVersion, out currentRDPVer)) { this.Site.Assert.Fail("Invalid format of Version {0} in config file. The valid format is required to be x.x. Please check the ptf config file.", currentRDPVersion); } //Validate the RDP version required by the test case against the version in ptfconfig Version testcaseRdpVer = null; if (Version.TryParse(version, out testcaseRdpVer)) { if (testcaseRdpVer > currentRDPVer) { this.Site.Assume.Inconclusive("Test case {0} is only supported by RDP {1} or above. But current RDP version is set to {2}", testCaseName, version, currentRDPVersion); } } else { this.Site.Assert.Fail("Invalid format of test case category RDP version {0}. The valid format is required to be RDPx.x.", version, testCaseName); } } catch (Exception ex) { if (ex is ArgumentNullException || ex is FormatException || ex is OverflowException) { this.Site.Log.Add(LogEntryKind.Comment, ex.Message); this.Site.Assert.Fail("Version in PTF config, or the RDP version in TestCategory attribute is not configured correctly."); } else { throw; } } }
protected void LoadConfig() { #region Read and convert properties from PTFCONFIG file #region Security Approach and Protocol string strRDPSecurityProtocol; bool isNegotiationBased = true; if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RdpSecurityNegotiation, out isNegotiationBased, new string[] { RdpPtfGroupNames.Security })) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityNegotiation); } selectedProtocol = selectedProtocols_Values.PROTOCOL_RDP_FLAG; if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RdpSecurityProtocol, out strRDPSecurityProtocol, new string[] { RdpPtfGroupNames.Security })) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } // Check the combination of RdpSecurityNegotiation and RdpSecurityProtocol if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase)) { selectedProtocol = selectedProtocols_Values.PROTOCOL_SSL_FLAG; this.TestSite.Assume.IsTrue( isNegotiationBased, "When TLS is used as the security protocol, {0} is set to 'TLS', {1} must be true.", RdpPtfPropNames.RdpSecurityProtocol, RdpPtfPropNames.RdpSecurityNegotiation); transportProtocol = EncryptedProtocol.NegotiationTls; } else if (strRDPSecurityProtocol.Equals("CredSSP", StringComparison.CurrentCultureIgnoreCase)) { selectedProtocol = selectedProtocols_Values.PROTOCOL_HYBRID_FLAG; if (isNegotiationBased) { transportProtocol = EncryptedProtocol.NegotiationCredSsp; } else { transportProtocol = EncryptedProtocol.DirectCredSsp; } } else if (strRDPSecurityProtocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase)) { selectedProtocol = selectedProtocols_Values.PROTOCOL_RDP_FLAG; transportProtocol = EncryptedProtocol.Rdp; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } #endregion #region Encryption Level string strRDPSecurityEncryptionLevel; enLevel = EncryptionLevel.ENCRYPTION_LEVEL_LOW; if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RdpSecurityEncryptionLevel, out strRDPSecurityEncryptionLevel, new string[] { RdpPtfGroupNames.Security, RdpPtfGroupNames.Encryption })) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionLevel); } else {//None, Low, Client, High, FIPS if (strRDPSecurityEncryptionLevel.Equals("None", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_NONE; } else if (strRDPSecurityEncryptionLevel.Equals("Low", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_LOW; } else if (strRDPSecurityEncryptionLevel.Equals("Client", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_CLIENT_COMPATIBLE; } else if (strRDPSecurityEncryptionLevel.Equals("High", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_HIGH; } else if (strRDPSecurityEncryptionLevel.Equals("FIPS", StringComparison.CurrentCultureIgnoreCase)) { enLevel = EncryptionLevel.ENCRYPTION_LEVEL_FIPS; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionLevel); } } if (transportProtocol == EncryptedProtocol.Rdp && enLevel == EncryptionLevel.ENCRYPTION_LEVEL_NONE) { this.TestSite.Assert.Fail("When use Standard RDP Security, the encryption level must be greater than None."); } if (transportProtocol != EncryptedProtocol.Rdp && enLevel != EncryptionLevel.ENCRYPTION_LEVEL_NONE) { this.TestSite.Assert.Fail("When use enhanced security protocls (TLS or CredSSP), the encryption level MUST be None."); } #endregion #region Encryption Method string strRDPSecurityEncryptionMethod; enMethod = EncryptionMethods.ENCRYPTION_METHOD_128BIT; if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RdpSecurityEncryptionMethod, out strRDPSecurityEncryptionMethod, new string[] { RdpPtfGroupNames.Security, RdpPtfGroupNames.Encryption })) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionMethod); } else {//None, 40bit, 56bit, 128bit, FIPS if (strRDPSecurityEncryptionMethod.Equals("None", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_NONE; } else if (strRDPSecurityEncryptionMethod.Equals("40bit", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_40BIT; } else if (strRDPSecurityEncryptionMethod.Equals("56bit", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_56BIT; } else if (strRDPSecurityEncryptionMethod.Equals("128bit", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_128BIT; } else if (strRDPSecurityEncryptionMethod.Equals("FIPS", StringComparison.CurrentCultureIgnoreCase)) { enMethod = EncryptionMethods.ENCRYPTION_METHOD_FIPS; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityEncryptionMethod); } } if (enLevel == EncryptionLevel.ENCRYPTION_LEVEL_NONE && enMethod != EncryptionMethods.ENCRYPTION_METHOD_NONE) { this.TestSite.Assume.Fail("When Encryption Level is set to None, the Encryption Method should also set to None."); } if (enLevel == EncryptionLevel.ENCRYPTION_LEVEL_FIPS && enMethod != EncryptionMethods.ENCRYPTION_METHOD_FIPS) { this.TestSite.Assume.Fail("When Encryption Level is set to FIPS, the Encryption Method should also set to FIPS."); } #endregion #region RDP Version rdpServerVersion = TS_UD_SC_CORE_version_Values.V2; #endregion #region WaitTime int waitSeconds; if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.Timeout, out waitSeconds)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.Timeout); } else { waitTime = new TimeSpan(0, 0, waitSeconds); } #endregion #region SUT Display Verification if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "Enable", out verifySUTDisplay, new string[] { RdpPtfGroupNames.VerifySUTDisplay })) { verifySUTDisplay = false; } int shiftX, shiftY; if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "ShiftX", out shiftX, new string[] { RdpPtfGroupNames.VerifySUTDisplay })) { shiftX = 0; } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "ShiftY", out shiftY, new string[] { RdpPtfGroupNames.VerifySUTDisplay })) { shiftY = 0; } sutDisplayShift = new Point(shiftX, shiftY); if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "BitmapSavePath", out bitmapSavePath, new string[] { RdpPtfGroupNames.VerifySUTDisplay })) { bitmapSavePath = @".\"; } // If the bitmap save path is not existed, create it. if (!Directory.Exists(bitmapSavePath)) { Directory.CreateDirectory(bitmapSavePath); } #endregion SUT Display Verification #region Other configrations if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RDPClientSupportFastPathInput, out isClientSupportFastPathInput)) { isClientSupportFastPathInput = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RDPClientSupportAutoReconnect, out isClientSuportAutoReconnect)) { isClientSuportAutoReconnect = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RDPClientSupportRDPEFS, out isClientSupportRDPEFS)) { isClientSupportRDPEFS = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RDPClientSupportServerRedirection, out isClientSupportServerRedirection)) { isClientSupportServerRedirection = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RDPClientSupportSoftSync, out isClientSupportSoftSync)) { isClientSupportSoftSync = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RDPClientSupportTunnelingStaticVCTraffic, out isClientSupportTunnelingStaticVCTraffic)) { isClientSupportTunnelingStaticVCTraffic = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.SupportCompression, out supportCompression)) { supportCompression = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.RDPClientSupportRdpNegDataEmpty, out isClientSupportEmptyRdpNegData)) { isClientSupportEmptyRdpNegData = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.IsWindowsImplementation, out isWindowsImplementation)) { isWindowsImplementation = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.DropConnectionForInvalidRequest, out DropConnectionForInvalidRequest)) { DropConnectionForInvalidRequest = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "VerifyRdpbcgrMessage", out bVerifyRdpbcgrMessage)) { bVerifyRdpbcgrMessage = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "TurnOffRDPBCGRVerification", out TurnOffRDPBCGRVerification)) { TurnOffRDPBCGRVerification = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "TurnOffRDPEGFXVerification", out TurnOffRDPEGFXVerification)) { TurnOffRDPEGFXVerification = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "TurnOffRDPEIVerification", out TurnOffRDPEIVerification)) { TurnOffRDPEIVerification = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "TurnOffRDPEUSBVerification", out TurnOffRDPEUSBVerification)) { TurnOffRDPEUSBVerification = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetPtfPropertyValue(TestSite, "TurnOffRDPRFXVerification", out TurnOffRDPRFXVerification)) { TurnOffRDPRFXVerification = true; //if property not found, set to true as default value } if (image_64X64 == null) { String rdprfxImageFile; if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.MSRDPRFX_Image, out rdprfxImageFile)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.MSRDPRFX_Image); } image_64X64 = Image.FromFile(rdprfxImageFile); } if (imageForVideoMode == null) { String rdprfxVideoModeImageFile; if (!PtfPropUtility.GetPtfPropertyValue(TestSite, RdpPtfPropNames.MSRDPRFX_VideoModeImage, out rdprfxVideoModeImageFile)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.MSRDPRFX_VideoModeImage); } imageForVideoMode = Image.FromFile(rdprfxVideoModeImageFile); } #endregion #endregion #region Logging this.TestSite.Log.Add(LogEntryKind.Debug, @"isClientSupportFastPathInput = {0}; isClientSuportAutoReconnect = {1}; isClientSupportRDPEFS = {2}; isClientSupportServerRedirection = {3}; isClientSupportEmptyRdpNegData = {4}; isClientSupportSoftSync = {5} isClientSupportTunnelingStaticVCTraffic = {6}", isClientSupportFastPathInput, isClientSuportAutoReconnect, isClientSupportRDPEFS, isClientSupportServerRedirection, isClientSupportEmptyRdpNegData, isClientSupportSoftSync, isClientSupportTunnelingStaticVCTraffic); #endregion }
/// <summary> /// private Constructor /// </summary> /// <param name="testSite"></param> private SUTControlProtocolHandler(ITestSite testSite) { this.Site = testSite; // Initiate request id requestId = 1; // Initiate transport string transportType; PtfPropUtility.GetPtfPropertyValue(testSite, "TransportType", out transportType, new string[] { RdpPtfGroupNames.SUTControl }); if (transportType == null) { transportType = "TCP"; } if (transportType.Equals("TCP")) { transport = new TCPSUTControlTransport(); } else { transport = new UDPSUTControlTransport(); } // Initiate timeout time span timeout = new TimeSpan(0, 0, 20); // Initiate Connect payload type bool clientSupportRDPFile = false; PtfPropUtility.GetPtfPropertyValue(testSite, "ClientSupportRDPFile", out clientSupportRDPFile, new string[] { RdpPtfGroupNames.SUTControl }); // Initiate alwaysNeedResponse PtfPropUtility.GetPtfPropertyValue(testSite, "AlwaysNeedResponse", out alwaysNeedResponse, new string[] { RdpPtfGroupNames.SUTControl }); // Get Agent addresses string addresses; PtfPropUtility.GetPtfPropertyValue(testSite, "AgentAddress", out addresses, new string[] { RdpPtfGroupNames.SUTControl }); string[] addressList = addresses.Split(';'); AgentList = new List <IPEndPoint>(); foreach (string address in addressList) { try { if (address != null && address.Trim().Length > 0) { int separator = address.IndexOf(':'); //Consider AgentAddress may be SUT hostname, or IP addresses List <IPAddress> addList = CommonUtility.GetHostIPs(this.Site, address.Substring(0, separator)); string port = address.Substring(separator + 1).Trim(); foreach (IPAddress add in addList) { IPEndPoint endpoint = new IPEndPoint(add, int.Parse(port)); AgentList.Add(endpoint); } } } catch (Exception e) { this.Site.Log.Add(LogEntryKind.Comment, "RDP SUT Control Protocol Adapter: Invalid Agent IP address/host name string or port number:" + e.Message); } } }