コード例 #1
0
        /// <summary>
        /// Sets basic authentication properties such as type, username, password and pre-authenticate in API module
        /// </summary>
        /// <param name="apiTestStep">returns module of apiTeststep</param>
        /// <param name="wseTestStep">returns username, password, preauthenticate information of wseTestStep</param>
        public void Execute(XTestStep apiTestStep, XTestStep wseTestStep)
        {
            try {
                FileLogger.Instance.Info("Inside Basic Auth Credentials Migrator");
                string userName        = GetWseUsernameValue(wseTestStep);
                string password        = GetWsePasswordValue(wseTestStep);
                string preAuthenticate = GetWsePreAuthenticateValue(wseTestStep);
                if (!string.IsNullOrEmpty(userName) || !string.IsNullOrEmpty(password) ||
                    !string.IsNullOrEmpty(preAuthenticate))
                {
                    ApiModule apiModule = (ApiModule)apiTestStep.Module;
                    apiModule.AddXParamToModuleAttribute("AuthenticationType", "Basic", ParamTypeE.TechnicalID);
                    apiModule.AddXParamToModuleAttribute("Username", userName, ParamTypeE.TechnicalID);
                    apiModule.AddXParamToModuleAttribute("Password", password, ParamTypeE.TechnicalID);
                    apiModule.AddXParamToModuleAttribute("PreAuthenticate",
                                                         preAuthenticate == "Yes" ? "true" : "false",
                                                         ParamTypeE.TechnicalID);
                }

                FileLogger.Instance.Info("Complete Basic Auth Credentials Migrator");
            }
            catch (Exception ex) {
                FileLogger.Instance.Error(
                    $"Error occurred while migration of Auth Credentials for WSE TestStep : 'Name: {wseTestStep?.Name}' NodePath:'{wseTestStep?.NodePath}' Exception:'{ex.ToString()}'");
            }
        }