Exemple #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);
        }
Exemple #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);
        }
        public void ParseMCSettingsTest_InvalidMCSettings_ReturnsNullSettings()
        {
            McConnectionInfo mcConnectionInfo = new McConnectionInfo();

            UFTSettings settings = ParallelRunnerEnvironmentUtil.ParseMCSettings(mcConnectionInfo);

            Assert.IsNull(settings);
        }
        public void GetMCProxySettingsTest_InvalidMCSettings_ReturnsNullProxySettings()
        {
            McConnectionInfo mcConnectionInfo = new McConnectionInfo();

            ProxySettings settings = ParallelRunnerEnvironmentUtil.GetMCProxySettings(mcConnectionInfo);

            Assert.IsNull(settings);
        }
Exemple #5
0
 public ParallelTestRunner(IAssetRunner runner, TimeSpan timeout, McConnectionInfo mcConnectionInfo,
                           string mobileInfo, Dictionary <string, List <string> > environments)
 {
     _runner           = runner;
     _timeout          = timeout;
     _mcConnectionInfo = mcConnectionInfo;
     _mobileInfo       = mobileInfo;
     _environments     = environments;
     _canRun           = TrySetupParallelRunner();
 }
Exemple #6
0
        /// <summary>
        /// Creates the json config file needed by the parallel runner and returns the path.
        /// </summary>
        /// <param name="testInfo"> The test information. </param>
        /// <returns>
        /// the path of the newly generated config file
        /// </returns>
        public static string GetConfigFilePath(TestInfo testInfo, McConnectionInfo mcConnectionInfo, Dictionary <string, List <string> > environments)
        {
            // no environment defined for this test
            if (!environments.ContainsKey(testInfo.TestId))
            {
                throw new ParallelRunnerConfigurationException("No parallel runner environments found for this test!");
            }

            // get the parallel run configuration
            var config = ParseEnvironmentStrings(environments[testInfo.TestId], testInfo);

            // there were no valid environments provided
            if (config.parallelRuns.Length == 0)
            {
                throw new ParallelRunnerConfigurationException("No valid environments found for this test!");
            }

            var mcSettings = ParseMCSettings(mcConnectionInfo);

            // set the mobile center settings if provided
            if (mcSettings != null)
            {
                config.settings = mcSettings;
            }

            var configFilePath = Path.Combine(testInfo.TestPath, testInfo.TestId + ".json");

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            string configJson = null;

            try
            {
                configJson = serializer.Serialize(config);
            }
            catch (InvalidOperationException e)
            {
                throw new ParallelRunnerConfigurationException("Invalid json confguration provided: ", e);
            }
            catch (ArgumentException e)
            {
                throw new ParallelRunnerConfigurationException("Configuration serialization recursion limit exceeded: ", e);
            }

            try
            {
                File.WriteAllText(configFilePath, configJson);
            }
            catch (Exception e)
            {
                throw new ParallelRunnerConfigurationException("Could not write configuration file: ", e);
            }

            return(configFilePath);
        }
        public void ParseMCSettingsTest_ValidMCSettingsNonSSL_ReturnsExpectedSettings()
        {
            McConnectionInfo mcConnectionInfo = new McConnectionInfo();

            mcConnectionInfo.MobileHostAddress = "192.168.1.1";
            mcConnectionInfo.MobileHostPort    = "8080";
            mcConnectionInfo.MobileUserName    = "******";
            mcConnectionInfo.MobilePassword    = "******";

            UFTSettings settings = ParallelRunnerEnvironmentUtil.ParseMCSettings(mcConnectionInfo);

            Assert.IsNotNull(settings);
            Assert.IsNotNull(settings.mc);

            Assert.AreEqual(mcConnectionInfo.MobileHostAddress, settings.mc.hostname);
            Assert.AreEqual(mcConnectionInfo.MobileHostPort, settings.mc.port.ToString());
            Assert.AreEqual(mcConnectionInfo.MobileUserName, settings.mc.username);
            Assert.AreEqual("http", settings.mc.protocol);
        }
        public void GetMCProxySettingsTest_ValidMCSettings_ReturnsExpectedProxySettings()
        {
            McConnectionInfo mcConnectionInfo = new McConnectionInfo();

            mcConnectionInfo.MobileProxySetting_Address        = "192.168.1.1";
            mcConnectionInfo.MobileProxySetting_Port           = 8080;
            mcConnectionInfo.MobileProxySetting_Authentication = 1;
            mcConnectionInfo.MobileProxySetting_UserName       = "******";
            mcConnectionInfo.MobileProxySetting_Password       = "******";

            ProxySettings settings = ParallelRunnerEnvironmentUtil.GetMCProxySettings(mcConnectionInfo);

            Assert.IsNotNull(settings);
            Assert.IsNotNull(settings.authentication);

            Assert.AreEqual(mcConnectionInfo.MobileProxySetting_UserName, settings.authentication.username);
            Assert.AreEqual(mcConnectionInfo.MobileProxySetting_Address, settings.hostname);
            Assert.AreEqual(mcConnectionInfo.MobileProxySetting_Port, settings.port);
        }