Microsoft.Protocols.TestSuites.Rdp.RdpTestClassBase.LoadConfig C# (CSharp) Method

LoadConfig() protected method

protected LoadConfig ( ) : void
return void
        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);
            }
            else
            {//TLS, CredSSP, or RDP
                if (strRDPSecurityProtocol.Equals("TLS", StringComparison.CurrentCultureIgnoreCase))
                {
                    selectedProtocol = selectedProtocols_Values.PROTOCOL_SSL_FLAG;
                    if (isNegotiationBased)
                    {
                        transportProtocol = EncryptedProtocol.NegotiationTls;
                    }
                    else
                    {
                        transportProtocol = EncryptedProtocol.DirectTls;
                    }
                }
                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;
                    if (!isNegotiationBased)
                    {
                        this.TestSite.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.");
                    }
                }
                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, "IsWindowsImplementation", out isWindowsImplementation))
            {
                isWindowsImplementation  = 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
        }