Beispiel #1
0
        /// <summary>
        /// Parses the MC settings and returns the corresponding UFT settings.
        /// </summary>
        /// <param name="mcConnectionInfo"> the mc settings</param>
        /// <returns> the parallel runner uft settings </returns>
        public static UFTSettings ParseMCSettings(McConnectionInfo mcConnectionInfo)
        {
            if (string.IsNullOrEmpty(mcConnectionInfo.MobileHostAddress) ||
                string.IsNullOrEmpty(mcConnectionInfo.MobileUserName) ||
                string.IsNullOrEmpty(mcConnectionInfo.MobilePassword) ||
                string.IsNullOrEmpty(mcConnectionInfo.MobileHostPort))
            {
                return(null);
            }

            MCSettings mcSettings = new MCSettings
            {
                username = mcConnectionInfo.MobileUserName,
                password = WinUserNativeMethods.ProtectBSTRToBase64(mcConnectionInfo.MobilePassword),
                hostname = mcConnectionInfo.MobileHostAddress,
                port     = Convert.ToInt32(mcConnectionInfo.MobileHostPort),
                protocol = mcConnectionInfo.MobileUseSSL > 0 ? "https" : "http",
                tenantId = mcConnectionInfo.MobileTenantId,
            };

            var proxy = GetMCProxySettings(mcConnectionInfo);

            // set the proxy information if we have it
            if (proxy != null)
            {
                mcSettings.proxy = proxy;
            }

            UFTSettings uftSettings = new UFTSettings
            {
                mc = mcSettings
            };

            return(uftSettings);
        }
Beispiel #2
0
        /// <summary>
        /// Return the proxy settings.
        /// </summary>
        /// <param name="mcConnectionInfo">the mc connection info</param>
        /// <returns></returns>
        public static ProxySettings GetMCProxySettings(McConnectionInfo mcConnectionInfo)
        {
            if (String.IsNullOrEmpty(mcConnectionInfo.MobileProxySetting_Address))
            {
                return(null);
            }

            AuthenticationSettings authenticationSettings = null;

            if (!string.IsNullOrEmpty(mcConnectionInfo.MobileProxySetting_UserName) &&
                !string.IsNullOrEmpty(mcConnectionInfo.MobileProxySetting_Password))
            {
                authenticationSettings = new AuthenticationSettings
                {
                    username = mcConnectionInfo.MobileProxySetting_UserName,
                    password = WinUserNativeMethods.
                               ProtectBSTRToBase64(mcConnectionInfo.MobileProxySetting_Password)
                };
            }

            ProxySettings proxySettings = new ProxySettings
            {
                authentication = authenticationSettings,
                hostname       = mcConnectionInfo.MobileProxySetting_Address,
                port           = mcConnectionInfo.MobileProxySetting_Port,
                type           = mcConnectionInfo.MobileProxyType == 1 ? "system" : "http",
            };

            return(proxySettings);
        }