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 Security Approach and Protocol string strRDPSecurityProtocol; bool isNegotiationBased = true; if (!PtfPropUtility.GetBoolPtfProperty(Site, "RDP.Security.Negotiation", out isNegotiationBased)) { assumeFailForInvalidPtfProp("RDP.Security.Negotiation"); } requestProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.Security.Protocol", out strRDPSecurityProtocol)) { assumeFailForInvalidPtfProp("RDP.Security.Protocol"); } else {//TLS, CredSSP, or RDP if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_SSL_FLAG; if (isNegotiationBased) { transportProtocol = EncryptedProtocol.NegotiationTls; } else { transportProtocol = EncryptedProtocol.DirectTls; } } else if (strRDPSecurityProtocol.Equals("CredSSP", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_HYBRID_FLAG; if (isNegotiationBased) { transportProtocol = EncryptedProtocol.NegotiationCredSsp; } else { transportProtocol = EncryptedProtocol.DirectCredSsp; } } else if (strRDPSecurityProtocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; if (!isNegotiationBased) { this.Site.Log.Add(LogEntryKind.Warning, "The property \"RDP.Security.Protocol\" is not valid and will be ingored. (When use RDP as security protocol, the negotiation-based approch MUST be used."); } transportProtocol = EncryptedProtocol.Rdp; } else { assumeFailForInvalidPtfProp("RDP.Security.Protocol"); } } #region WaitTime string strWaitTime = Site.Properties["WaitTime"]; if (strWaitTime != null) { int waitSeconds = Int32.Parse(strWaitTime); timeout = new TimeSpan(0, 0, waitSeconds); } #endregion #endregion }
protected void LoadConfig() { #region Read and convert properties from PTFCONFIG file #region Security Approach and Protocol string strRDPSecurityProtocol; bool isNegotiationBased = true; if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityNegotiation, out isNegotiationBased)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityNegotiation); } selectedProtocol = selectedProtocols_Values.PROTOCOL_RDP_FLAG; if (!PtfPropUtility.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityProtocol, out strRDPSecurityProtocol)) { 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.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityEncryptionLevel, out strRDPSecurityEncryptionLevel)) { 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.GetStringPtfProperty(TestSite, RdpPtfPropNames.RdpSecurityEncryptionMethod, out strRDPSecurityEncryptionMethod)) { 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.GetIntPtfProperty(TestSite, RdpPtfPropNames.Timeout, out waitSeconds)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.Timeout); } else { waitTime = new TimeSpan(0, 0, waitSeconds); } #endregion #region SUT Display Verification if (!PtfPropUtility.GetBoolPtfProperty(TestSite, "VerifySUTDisplay.Enable", out verifySUTDisplay)) { verifySUTDisplay = false; } int shiftX, shiftY; if (!PtfPropUtility.GetIntPtfProperty(TestSite, "VerifySUTDisplay.Shift.X", out shiftX)) { shiftX = 0; } if (!PtfPropUtility.GetIntPtfProperty(TestSite, "VerifySUTDisplay.Shift.Y", out shiftY)) { shiftY = 0; } sutDisplayShift = new Point(shiftX, shiftY); if (!PtfPropUtility.GetStringPtfProperty(TestSite, "VerifySUTDisplay.BitmapSavePath", out bitmapSavePath)) { 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.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportFastPathInput, out isClientSupportFastPathInput)) { isClientSupportFastPathInput = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportAutoReconnect, out isClientSuportAutoReconnect)) { isClientSuportAutoReconnect = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportRDPEFS, out isClientSupportRDPEFS)) { isClientSupportRDPEFS = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportServerRedirection, out isClientSupportServerRedirection)) { isClientSupportServerRedirection = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportSoftSync, out isClientSupportSoftSync)) { isClientSupportSoftSync = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportTunnelingStaticVCTraffic, out isClientSupportTunnelingStaticVCTraffic)) { isClientSupportTunnelingStaticVCTraffic = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.RDPClientSupportRdpNegDataEmpty, out isClientSupportEmptyRdpNegData)) { isClientSupportEmptyRdpNegData = false; //if property not found, set to false as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.IsWindowsImplementation, out isWindowsImplementation)) { isWindowsImplementation = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, RdpPtfPropNames.DropConnectionForInvalidRequest, out DropConnectionForInvalidRequest)) { DropConnectionForInvalidRequest = true; //if property not found, set to true as default value } if (!PtfPropUtility.GetBoolPtfProperty(TestSite, "VerifyRdpbcgrMessage", out bVerifyRdpbcgrMessage)) { bVerifyRdpbcgrMessage = true; //if property not found, set to true as default value } String rdprfxImageFile; if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RDPRFX.Image", out rdprfxImageFile)) { rdprfxImageFile = ""; //if property not found, set to true as default value } String rdprfxVideoModeImageFile; if (!PtfPropUtility.GetStringPtfProperty(TestSite, "RDPRFXVideoMode.Image", out rdprfxVideoModeImageFile)) { rdprfxVideoModeImageFile = ""; //if property not found, set to true as default value } try { //Get image from file image_64X64 = Image.FromFile(rdprfxImageFile); imageForVideoMode = Image.FromFile(rdprfxVideoModeImageFile); } catch (System.IO.FileNotFoundException) { //capture screen if failed to get image from file //Capture 64*64 bitmap for Image Mode image_64X64 = captureScreenImage(0, 0, TileSize, TileSize); //Capture screen bitmap for Vedio Mode imageForVideoMode = captureScreenImage(0, 0, TileSize * VideoMode_TileRowNum, TileSize * VideoMode_TileColNum); } #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 }
protected void LoadConfig() { #region Security Approach and Protocol string strRDPSecurityProtocol; bool isNegotiationBased = true; if (!PtfPropUtility.GetBoolPtfProperty(Site, RdpPtfPropNames.RdpSecurityNegotiation, out isNegotiationBased)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityNegotiation); } requestProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; if (!PtfPropUtility.GetStringPtfProperty(Site, RdpPtfPropNames.RdpSecurityProtocol, out strRDPSecurityProtocol)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } else {//TLS, CredSSP, or RDP if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_SSL_FLAG; this.Site.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)) { requestProtocol = requestedProtocols_Values.PROTOCOL_HYBRID_FLAG; if (isNegotiationBased) { transportProtocol = EncryptedProtocol.NegotiationCredSsp; } else { transportProtocol = EncryptedProtocol.DirectCredSsp; } } else if (strRDPSecurityProtocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; transportProtocol = EncryptedProtocol.Rdp; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } } #region WaitTime string strWaitTime = Site.Properties["WaitTime"]; if (strWaitTime != null) { int waitSeconds = Int32.Parse(strWaitTime); timeout = new TimeSpan(0, 0, waitSeconds); } #endregion #endregion }
/// <summary> /// Load configuration from PTF config file /// </summary> private void LoadConfiguation() { string tempStr; if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.ServerName", out serverName)) { AssumeFailForInvalidPtfProp("RDP.ServerName"); } if (PtfPropUtility.GetStringPtfProperty(Site, "RDP.ServerDomain", out tempStr)) { if (tempStr != null && tempStr.Length > 0) { this.domain = tempStr; } else { this.domain = this.serverName; } } if (!PtfPropUtility.GetIntPtfProperty(Site, "RDP.ServerPort", out serverPort)) { AssumeFailForInvalidPtfProp("RDP.ServerPort"); } if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.ServerUserName", out userName)) { AssumeFailForInvalidPtfProp("RDP.ServerUserName"); } if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.ServerUserPassword", out password)) { AssumeFailForInvalidPtfProp("RDP.ServerUserPassword"); } if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.ClientName", out localAddress)) { AssumeFailForInvalidPtfProp("RDP.ClientName"); } int waitTime; if (!PtfPropUtility.GetIntPtfProperty(Site, "Timeout", out waitTime)) { AssumeFailForInvalidPtfProp("Timeout"); } timeout = new TimeSpan(0, 0, waitTime); if (!PtfPropUtility.GetIntPtfProperty(Site, "MultiTransportTimeout", out waitTime)) { AssumeFailForInvalidPtfProp("MultiTransportTimeout"); } multiTransportTimeout = new TimeSpan(0, 0, waitTime); PtfPropUtility.GetBoolPtfProperty(Site, "IsWindowsImplementation", out isWindowsImplementation); PtfPropUtility.GetBoolPtfProperty(Site, "VerifyRdpbcgrMessages", out verifyPduEnabled); PtfPropUtility.GetBoolPtfProperty(Site, "VerifyShouldBehaviors", out verifyShouldBehaviors); PtfPropUtility.GetBoolPtfProperty(Site, "RDPEDYCSupported", out isEDYCSupported); PtfPropUtility.GetBoolPtfProperty(Site, "RDPELESupported", out isELESupported); PtfPropUtility.GetBoolPtfProperty(Site, "IssueTemporaryLicenseForTheFirstTime", out issueTemporaryLicenseForTheFirstTime); if (PtfPropUtility.GetStringPtfProperty(Site, "RDP.Version", out tempStr)) { rdpVersion = new Version(tempStr); } else { AssumeFailForInvalidPtfProp("RDP.Version"); } #region Security Approach and Protocol string strRDPSecurityProtocol; string strRDPSecurityTlsVersion; bool isNegotiationBased = true; if (!PtfPropUtility.GetBoolPtfProperty(Site, "RDP.Security.Negotiation", out isNegotiationBased)) { AssumeFailForInvalidPtfProp("RDP.Security.Negotiation"); } requestProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; if (!PtfPropUtility.GetStringPtfProperty(Site, "RDP.Security.Protocol", out strRDPSecurityProtocol)) { AssumeFailForInvalidPtfProp("RDP.Security.Protocol"); } //TLS, CredSSP, or RDP if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase)) { if (PtfPropUtility.GetStringPtfProperty(Site, "RDP.Security.TLS.Version", out strRDPSecurityTlsVersion)) { // TLS1.0, TLS1.1, TLS1.2 or None if (strRDPSecurityTlsVersion.Equals("TLS1.0", StringComparison.CurrentCultureIgnoreCase)) { tlsVersion = SslProtocols.Tls; } else if (strRDPSecurityTlsVersion.Equals("TLS1.1", StringComparison.CurrentCultureIgnoreCase)) { tlsVersion = SslProtocols.Tls11; } else if (strRDPSecurityTlsVersion.Equals("TLS1.2", StringComparison.CurrentCultureIgnoreCase)) { tlsVersion = SslProtocols.Tls12; } else if (strRDPSecurityTlsVersion.Equals("None", StringComparison.CurrentCultureIgnoreCase)) { tlsVersion = SslProtocols.None; } else { this.Site.Log.Add(LogEntryKind.Comment, "TLS is used as security protocol and the TLS Version is {0}.", strRDPSecurityTlsVersion); this.Site.Assume.Fail("When TLS is used as the security protocol, {0} must be one of TLS1.0, TLS1.1, or TLS1.2; actually it is set to {1}", "RDP.Security.TLS.Version", tlsVersion); } } else { AssumeFailForInvalidPtfProp("RDP.Security.TLS.Version"); } requestProtocol = requestedProtocols_Values.PROTOCOL_SSL_FLAG; this.Site.Assume.IsTrue( isNegotiationBased, "When TLS is used as the security protocol, {0} is set to 'TLS', {1} must be true.", "RDP.Security.Protocol", "RDP.Security.Negotiation"); transportProtocol = EncryptedProtocol.NegotiationTls; } else if (strRDPSecurityProtocol.Equals("CredSSP", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_SSL_FLAG | requestedProtocols_Values.PROTOCOL_HYBRID_FLAG | requestedProtocols_Values.PROTOCOL_HYBRID_EX; if (isNegotiationBased) { transportProtocol = EncryptedProtocol.NegotiationCredSsp; } else { transportProtocol = EncryptedProtocol.DirectCredSsp; } } else if (strRDPSecurityProtocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; transportProtocol = EncryptedProtocol.Rdp; } else { AssumeFailForInvalidPtfProp("RDP.Security.Protocol"); } #endregion }
protected void LoadConfig() { #region Security Approach and Protocol string strRDPSecurityProtocol; bool isNegotiationBased = true; if (!PtfPropUtility.GetBoolPtfProperty(Site, RdpPtfPropNames.RdpSecurityNegotiation, out isNegotiationBased)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityNegotiation); } requestProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; if (!PtfPropUtility.GetStringPtfProperty(Site, RdpPtfPropNames.RdpSecurityProtocol, out strRDPSecurityProtocol)) { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } else {//TLS, CredSSP, or RDP if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_SSL_FLAG; this.Site.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; string strTlsVersion; if (PtfPropUtility.GetStringPtfProperty(Site, RdpPtfPropNames.RdpSecurityTlsVersion, out strTlsVersion)) { if (!strTlsVersion.Equals("TLS1.0", StringComparison.CurrentCultureIgnoreCase) && !strTlsVersion.Equals("TLS1.1", StringComparison.CurrentCultureIgnoreCase) && !strTlsVersion.Equals("TLS1.2", StringComparison.CurrentCultureIgnoreCase)) { this.Site.Assume.Fail("When TLS is used as the security protocol, {0} must be one of TLS1.0, TLS1.1, or TLS1.2; actually it is set to {1}", RdpPtfPropNames.RdpSecurityTlsVersion, strTlsVersion); } else { this.Site.Log.Add(LogEntryKind.Comment, "TLS is used as security protocol and the TLS Version is {0}.", strTlsVersion); } } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityTlsVersion); } } else if (strRDPSecurityProtocol.Equals("CredSSP", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_HYBRID_FLAG; if (isNegotiationBased) { transportProtocol = EncryptedProtocol.NegotiationCredSsp; } else { transportProtocol = EncryptedProtocol.DirectCredSsp; } } else if (strRDPSecurityProtocol.Equals("RDP", StringComparison.CurrentCultureIgnoreCase)) { requestProtocol = requestedProtocols_Values.PROTOCOL_RDP_FLAG; transportProtocol = EncryptedProtocol.Rdp; } else { assumeFailForInvalidPtfProp(RdpPtfPropNames.RdpSecurityProtocol); } } #region Is Windows Implementation string strIsWindows = Site.Properties["IsWindowsImplementation"]; if (strIsWindows != null) { isWindowsImplementation = Boolean.Parse(strIsWindows); } #endregion #region WaitTime string strWaitTime = Site.Properties["WaitTime"]; if (strWaitTime != null) { int waitSeconds = Int32.Parse(strWaitTime); timeout = new TimeSpan(0, 0, waitSeconds); } #endregion #endregion string rdpVersionProp = this.Site.Properties["RDP.Version"]; if (!string.IsNullOrEmpty(rdpVersionProp)) { rdpVersion = new Version(rdpVersionProp); } else { this.Site.Assume.Fail("The property \"{0}\" is invalid or not present in PTFConfig file!", "RDP.Version"); } }
/// <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); } } }