예제 #1
0
파일: CLIArgs.cs 프로젝트: csuffyy/Ginger
        public string CreateContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            string Args = string.Empty;

            Args += string.Format("--solution {0}", solution.Folder);
            Args += string.Format(" --runset {0}", runsetExecutor.RunSetConfig.Name);
            Args += string.Format(" --environment {0}", runsetExecutor.RunsetExecutionEnvironment.Name);
            Args += string.Format(" --runAnalyzer {0}", cliHelper.RunAnalyzer.ToString());
            Args += string.Format(" --showAutoRunWindow {0}", cliHelper.ShowAutoRunWindow.ToString());
            if (cliHelper.DownloadUpgradeSolutionFromSourceControl == true)
            {
                Args += string.Format(" --sourceControlType {0}", solution.SourceControl.GetSourceControlType.ToString());
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.SVN)//added for supporting Jenkins way of config creation- need to improve it
                {
                    string modifiedURI = solution.SourceControl.SourceControlURL.TrimEnd(new char[] { '/' });
                    int    lastSlash   = modifiedURI.LastIndexOf('/');
                    modifiedURI = (lastSlash > -1) ? modifiedURI.Substring(0, lastSlash) : modifiedURI;
                    Args       += string.Format(" --sourceControlUrl {0}", modifiedURI);
                }
                else
                {
                    Args += string.Format(" --sourceControlUrl {0}", solution.SourceControl.SourceControlURL);
                }
                Args += string.Format(" --sourceControlUser {0}", solution.SourceControl.SourceControlUser);
                Args += string.Format(" --sourceControlPassword {0}", EncryptionHandler.EncryptwithKey(solution.SourceControl.SourceControlPass));
                Args += string.Format(" --sourceControlPasswordEncrypted {0}", "Y");
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.GIT && solution.SourceControl.SourceControlProxyAddress.ToLower().ToString() == "true")
                {
                    Args += string.Format(" --sourceControlProxyServer {0}", solution.SourceControl.SourceControlProxyAddress.ToString());
                    Args += string.Format(" --sourceControlProxyPort {0}", solution.SourceControl.SourceControlProxyPort.ToString());
                }
            }
            return(Args);
        }
예제 #2
0
 private void xSMTPPassTextBox_LostFocus(object sender, RoutedEventArgs e)
 {
     if (!EncryptionHandler.IsStringEncrypted(xSMTPPassTextBox.Text))
     {
         xSMTPPassTextBox.Text = EncryptionHandler.EncryptwithKey(xSMTPPassTextBox.Text);
     }
 }
 private void param_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == GeneralParam.Fields.Encrypt)
     {
         GeneralParam param       = (GeneralParam)sender;
         String       intialValue = param.Value;
         bool         res         = false;
         if (!string.IsNullOrEmpty(intialValue) && param.Encrypt)
         {
             if (!EncryptionHandler.IsStringEncrypted(intialValue))
             {
                 param.Value = EncryptionHandler.EncryptwithKey(intialValue);
                 if (string.IsNullOrEmpty(param.Value))
                 {
                     param.Value = string.Empty;
                 }
             }
         }
         else
         {
             if (EncryptionHandler.IsStringEncrypted(intialValue))
             {
                 param.Value = null;
             }
         }
     }
 }
예제 #4
0
 private void txtPasswordValue_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
 {
     if (!EncryptionHandler.IsStringEncrypted(txtPasswordValue.Text))
     {
         txtPasswordValue.Text = EncryptionHandler.EncryptwithKey(txtPasswordValue.Text);
     }
 }
        private async void grdMain_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (e.Column.Header.ToString() == "User Password")
            {
                Database selectedEnvDB = (Database)grdAppDbs.CurrentItem;
                String   intialValue   = selectedEnvDB.Pass;
                //if Pass is stored in the form of variable, encryption not required at this stage
                if (!string.IsNullOrEmpty(intialValue) && !intialValue.Contains("{Var Name"))
                {
                    if (!EncryptionHandler.IsStringEncrypted(intialValue))
                    {
                        selectedEnvDB.Pass = EncryptionHandler.EncryptwithKey(intialValue);
                        if (string.IsNullOrEmpty(selectedEnvDB.Pass))
                        {
                            selectedEnvDB.Pass = null;
                        }
                    }
                }
            }

            if (e.Column.Header.ToString() == nameof(Database.Name))
            {
                Database selectedDB = (Database)grdAppDbs.CurrentItem;
                if (selectedDB.Name != ((DatabaseOperations)selectedDB.DatabaseOperations).NameBeforeEdit)
                {
                    await UpdateDatabaseNameChange(selectedDB);
                }
            }
        }
        private async Task <int> ReEncryptEnvironmentPasswordValues(string oldKey = null)
        {
            ShowStatusMessage("Re-Encrypting Environment paramters and DB Password Values with new Key...");
            return(await Task.Run(() =>
            {
                bool isSaveRequired = false;
                int varReencryptedCount = 0;

                //For project environment variable
                List <ProjEnvironment> projEnvironments = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ProjEnvironment>().ToList();
                projEnvironments.ForEach(pe =>
                {
                    try
                    {
                        isSaveRequired = false;
                        foreach (EnvApplication ea in pe.Applications)
                        {
                            foreach (GeneralParam gp in ea.GeneralParams.Where(f => f.Encrypt))
                            {
                                gp.Value = EncryptionHandler.ReEncryptString(gp.Value, oldKey);
                                isSaveRequired = true;
                                varReencryptedCount++;
                            }
                            foreach (Database db in ea.Dbs)
                            {
                                if (!string.IsNullOrEmpty(db.Pass))
                                {
                                    //if Pass is stored in the form of variable, encryption not required at this stage
                                    if (!db.Pass.Contains("{Var Name") && !db.Pass.Contains("{EnvParam"))
                                    {
                                        string encryptedPassWord = EncryptionHandler.ReEncryptString(db.Pass, oldKey);
                                        if (string.IsNullOrEmpty(encryptedPassWord))
                                        {
                                            encryptedPassWord = EncryptionHandler.EncryptwithKey(db.Pass);
                                        }
                                        db.Pass = encryptedPassWord;
                                    }
                                    isSaveRequired = true;
                                    varReencryptedCount++;
                                }
                            }
                        }
                        if (isSaveRequired)
                        {
                            WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(pe);
                        }
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "ReEncryptVariable- Failed to Re-encrypt password ProjEnvironment variable for " + pe.Name, ex);
                    }
                });

                return varReencryptedCount;
            }));
        }
 public void EncryptGridValues()
 {
     foreach (GingerCore.Variables.VariablePasswordString vp in xSolutionPasswordsParamtersGrid.DataSourceList)
     {
         if (!string.IsNullOrEmpty(vp.Password) && !EncryptionHandler.IsStringEncrypted(vp.Password))
         {
             vp.Password = EncryptionHandler.EncryptwithKey(vp.Password);
         }
     }
 }
예제 #8
0
        public void EncryptString()
        {
            //Arrange
            string encryptedString = string.Empty;
            bool   result          = false;

            //Act
            encryptedString = EncryptionHandler.EncryptwithKey("ginger");

            //Assert
            Assert.AreEqual("mDL33JRKM3Zv1FdtGQMNZg==", encryptedString);
        }
예제 #9
0
        public string CreateConfigurationsContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            string sConfig = null;

            if (cliHelper.DownloadUpgradeSolutionFromSourceControl == true)
            {
                sConfig = "SourceControlType=" + solution.SourceControl.GetSourceControlType.ToString() + Environment.NewLine;
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.SVN)//added for supporting Jenkins way of config creation- need to improve it
                {
                    string modifiedURI = solution.SourceControl.SourceControlURL.TrimEnd(new char[] { '/' });
                    int    lastSlash   = modifiedURI.LastIndexOf('/');
                    modifiedURI = (lastSlash > -1) ? modifiedURI.Substring(0, lastSlash) : modifiedURI;
                    sConfig    += "SourceControlUrl=" + modifiedURI + Environment.NewLine;
                }
                else
                {
                    sConfig += "SourceControlUrl=" + solution.SourceControl.SourceControlURL + Environment.NewLine;
                }
                if (solution.SourceControl.SourceControlUser != null && solution.SourceControl.SourceControlPass != null)
                {
                    sConfig += "SourceControlUser="******"SourceControlPassword="******"PasswordEncrypted=" + "Y" + Environment.NewLine;
                }
                else
                {
                    sConfig += "SourceControlUser=N/A" + Environment.NewLine;
                    sConfig += "SourceControlPassword=N/A" + Environment.NewLine;
                }
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.GIT)
                {
                    if (solution.SourceControl.SourceControlProxyAddress != null && solution.SourceControl.SourceControlProxyAddress.ToLower().ToString() == "true")
                    {
                        sConfig += "SourceControlProxyServer=" + solution.SourceControl.SourceControlProxyAddress.ToString() + Environment.NewLine;
                        sConfig += "SourceControlProxyPort=" + solution.SourceControl.SourceControlProxyPort.ToString() + Environment.NewLine;
                    }
                }
            }
            sConfig += "solution=" + solution.Folder + Environment.NewLine;
            sConfig += "env=" + runsetExecutor.RunsetExecutionEnvironment.Name + Environment.NewLine;
            sConfig += "runset=" + runsetExecutor.RunSetConfig.Name + Environment.NewLine;
            sConfig += "analyze=" + cliHelper.RunAnalyzer.ToString() + Environment.NewLine;
            if (!string.IsNullOrEmpty(cliHelper.TestArtifactsFolder))
            {
                sConfig += "artifacts-path=" + cliHelper.TestArtifactsFolder + Environment.NewLine;
            }

            //OLD sConfig += "ShowAutoRunWindow=" + cliHelper.ShowAutoRunWindow.ToString() + Environment.NewLine;
            sConfig += CLIOptionClassHelper.GetAttrLongName <RunOptions>(nameof(RunOptions.ShowUI)) + "=" + cliHelper.ShowAutoRunWindow.ToString() + Environment.NewLine;

            return(sConfig);
        }
예제 #10
0
 public bool AddValidationString()
 {
     try
     {
         Solution.EncryptedValidationString = EncryptionHandler.EncryptwithKey("valid");
         return(true);
     }
     catch (Exception ex)
     {
         Reporter.ToLog(eLogLevel.DEBUG, ex.Message);
     }
     return(false);
 }
        private void grdMain_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (e.Column.Header.ToString() == GeneralParam.Fields.Name)
            {
                GeneralParam changedParam = (GeneralParam)grdAppParams.CurrentItem;
                if (changedParam.Name != changedParam.NameBeforeEdit)
                {
                    //ask user if want us to update the parameter name in all BF's
                    if (Reporter.ToUser(eUserMsgKey.ChangingEnvironmentParameterValue) == Amdocs.Ginger.Common.eUserMsgSelection.Yes)
                    {
                        UpdateVariableNameChange(changedParam);
                    }
                }
            }
            else if (e.Column.Header.ToString() == GeneralParam.Fields.Value)
            {
                GeneralParam selectedEnvParam = (GeneralParam)grdAppParams.CurrentItem;

                String intialValue = selectedEnvParam.Value;

                if (!string.IsNullOrEmpty(intialValue))
                {
                    if (selectedEnvParam.Encrypt == true)
                    {
                        //UpdateVariableNameChange(selectedEnvParam); // why is that needed here?

                        if (!EncryptionHandler.IsStringEncrypted(intialValue))
                        {
                            selectedEnvParam.Value = EncryptionHandler.EncryptwithKey(intialValue);
                            if (string.IsNullOrEmpty(selectedEnvParam.Value))
                            {
                                selectedEnvParam.Value = string.Empty;
                            }
                        }
                    }
                    else
                    {
                        if (EncryptionHandler.IsStringEncrypted(intialValue))
                        {
                            selectedEnvParam.Value = null;
                        }
                    }
                }
            }
        }
        public static string CreateDynamicRunSetXML(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            runsetExecutor.RunSetConfig.UpdateRunnersBusinessFlowRunsList();

            DynamicGingerExecution dynamicExecution = new DynamicGingerExecution();

            dynamicExecution.SolutionDetails = new SolutionDetails();
            if (cliHelper.DownloadUpgradeSolutionFromSourceControl == true)
            {
                dynamicExecution.SolutionDetails.SourceControlDetails      = new SourceControlDetails();
                dynamicExecution.SolutionDetails.SourceControlDetails.Type = solution.SourceControl.GetSourceControlType.ToString();
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.SVN)//added for supporting Jenkins way of config creation- need to improve it
                {
                    string modifiedURI = solution.SourceControl.SourceControlURL.TrimEnd(new char[] { '/' });
                    int    lastSlash   = modifiedURI.LastIndexOf('/');
                    modifiedURI = (lastSlash > -1) ? modifiedURI.Substring(0, lastSlash) : modifiedURI;
                    dynamicExecution.SolutionDetails.SourceControlDetails.Url = modifiedURI;
                }
                else
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.Url = solution.SourceControl.SourceControlURL.ToString();
                }
                if (solution.SourceControl.SourceControlUser != null && solution.SourceControl.SourceControlPass != null)
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.User              = solution.SourceControl.SourceControlUser;
                    dynamicExecution.SolutionDetails.SourceControlDetails.Password          = EncryptionHandler.EncryptwithKey(solution.SourceControl.SourceControlPass);
                    dynamicExecution.SolutionDetails.SourceControlDetails.PasswordEncrypted = "Y";
                }
                else
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.User     = "******";
                    dynamicExecution.SolutionDetails.SourceControlDetails.Password = "******";
                }
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.GIT && solution.SourceControl.SourceControlProxyAddress.ToLower().ToString() == "true")
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.ProxyServer = solution.SourceControl.SourceControlProxyAddress.ToString();
                    dynamicExecution.SolutionDetails.SourceControlDetails.ProxyPort   = solution.SourceControl.SourceControlProxyPort.ToString();
                }
            }
            dynamicExecution.SolutionDetails.Path = solution.Folder;
            dynamicExecution.ShowAutoRunWindow    = cliHelper.ShowAutoRunWindow;

            AddRunset addRunset = new AddRunset();

            addRunset.Name          = "Dynamic_" + runsetExecutor.RunSetConfig.Name;
            addRunset.Environment   = runsetExecutor.RunsetExecutionEnvironment.Name;
            addRunset.RunAnalyzer   = cliHelper.RunAnalyzer;
            addRunset.RunInParallel = runsetExecutor.RunSetConfig.RunModeParallel;

            foreach (GingerRunner gingerRunner in runsetExecutor.RunSetConfig.GingerRunners)
            {
                AddRunner addRunner = new AddRunner();
                addRunner.Name = gingerRunner.Name;
                if (gingerRunner.UseSpecificEnvironment == true && string.IsNullOrEmpty(gingerRunner.SpecificEnvironmentName))
                {
                    addRunner.Environment = gingerRunner.SpecificEnvironmentName;
                }
                if (gingerRunner.RunOption != GingerRunner.eRunOptions.ContinueToRunall)
                {
                    addRunner.RunMode = gingerRunner.RunOption.ToString();
                }

                foreach (ApplicationAgent applicationAgent in gingerRunner.ApplicationAgents)
                {
                    addRunner.SetAgents.Add(new SetAgent()
                    {
                        AgentName = applicationAgent.AgentName, ApplicationName = applicationAgent.AppName
                    });
                }

                foreach (BusinessFlowRun businessFlowRun in gingerRunner.BusinessFlowsRunList)
                {
                    AddBusinessFlow addBusinessFlow = new AddBusinessFlow();
                    addBusinessFlow.Name = businessFlowRun.BusinessFlowName;
                    if (businessFlowRun.BusinessFlowCustomizedRunVariables.Count > 0)
                    {
                        addBusinessFlow.InputVariables = new System.Collections.Generic.List <InputVariable>();
                        foreach (VariableBase variableBase in businessFlowRun.BusinessFlowCustomizedRunVariables)
                        {
                            InputVariable inputVar = new InputVariable();
                            if (variableBase.ParentType != "Business Flow")
                            {
                                inputVar.VariableParentType = variableBase.ParentType;
                                inputVar.VariableParentName = variableBase.ParentName;
                            }
                            inputVar.VariableName  = variableBase.Name;
                            inputVar.VariableValue = variableBase.Value;

                            addBusinessFlow.InputVariables.Add(inputVar);
                        }
                    }
                    addRunner.AddBusinessFlows.Add(addBusinessFlow);
                }
                addRunset.AddRunners.Add(addRunner);
            }

            foreach (RunSetActionBase runSetOperation in runsetExecutor.RunSetConfig.RunSetActions)
            {
                if (runSetOperation is RunSetActionHTMLReportSendEmail)
                {
                    RunSetActionHTMLReportSendEmail runsetMailReport = (RunSetActionHTMLReportSendEmail)runSetOperation;
                    MailReport dynamicMailReport = new MailReport();
                    dynamicMailReport.Condition = runsetMailReport.Condition.ToString();
                    dynamicMailReport.RunAt     = runsetMailReport.RunAt.ToString();

                    dynamicMailReport.MailFrom = runsetMailReport.MailFrom;
                    dynamicMailReport.MailTo   = runsetMailReport.MailTo;
                    dynamicMailReport.MailCC   = runsetMailReport.MailCC;

                    dynamicMailReport.Subject  = runsetMailReport.Subject;
                    dynamicMailReport.Comments = runsetMailReport.Comments;

                    if (runsetMailReport.Email.EmailMethod == GingerCore.GeneralLib.Email.eEmailMethod.OUTLOOK)
                    {
                        dynamicMailReport.SendViaOutlook = true;
                    }
                    else
                    {
                        dynamicMailReport.SmtpDetails           = new SmtpDetails();
                        dynamicMailReport.SmtpDetails.Server    = runsetMailReport.Email.SMTPMailHost;
                        dynamicMailReport.SmtpDetails.Port      = runsetMailReport.Email.SMTPPort.ToString();
                        dynamicMailReport.SmtpDetails.EnableSSL = runsetMailReport.Email.EnableSSL.ToString();
                        if (runsetMailReport.Email.ConfigureCredential)
                        {
                            dynamicMailReport.SmtpDetails.User     = runsetMailReport.Email.SMTPUser;
                            dynamicMailReport.SmtpDetails.Password = runsetMailReport.Email.SMTPPass;
                        }
                    }

                    if (runsetMailReport.EmailAttachments.Where(x => x.AttachmentType == EmailAttachment.eAttachmentType.Report).FirstOrDefault() != null)
                    {
                        dynamicMailReport.IncludeAttachmentReport = true;
                    }
                    else
                    {
                        dynamicMailReport.IncludeAttachmentReport = false;
                    }

                    addRunset.AddRunsetOperations.Add(dynamicMailReport);
                }
                else if (runSetOperation is RunSetActionJSONSummary)
                {
                    JsonReport dynamicJsonReport = new JsonReport();
                    addRunset.AddRunsetOperations.Add(dynamicJsonReport);
                }
            }
            dynamicExecution.AddRunsets.Add(addRunset);

            string content = ConvertDynamicExecutionToXML(dynamicExecution);

            return(content);
        }
예제 #13
0
        public string CreateConfigurationsContent(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            RunOptions options = new RunOptions();

            options.Solution          = solution.Folder;
            options.Runset            = runsetExecutor.RunSetConfig.Name;
            options.Environment       = runsetExecutor.RunsetExecutionEnvironment.Name;
            options.DoNotAnalyze      = !cliHelper.RunAnalyzer;
            options.ShowUI            = cliHelper.ShowAutoRunWindow;
            options.TestArtifactsPath = cliHelper.TestArtifactsFolder;

            options.EncryptionKey = solution.EncryptionKey;

            options.URL  = cliHelper.SourceControlURL;
            options.User = cliHelper.SourcecontrolUser;
            options.Pass = cliHelper.sourceControlPass;

            options.PasswordEncrypted = cliHelper.sourceControlPassEncrypted;
            options.SCMType           = cliHelper.sourceControlType;

            if (cliHelper.DownloadUpgradeSolutionFromSourceControl)
            {
                options.URL  = solution.SourceControl.SourceControlURL;
                options.User = solution.SourceControl.SourceControlUser;

                options.Pass = EncryptionHandler.EncryptwithKey(solution.SourceControl.SourceControlPass);

                options.PasswordEncrypted = true;
                options.SCMType           = solution.SourceControl.GetSourceControlType;
            }

            if (runsetExecutor.RunSetConfig.SelfHealingConfiguration.SaveChangesInSourceControl)
            {
                options.SelfHealingCheckInConfigured = true;
            }

            var args = CommandLine.Parser.Default.FormatCommandLine <RunOptions>(options);

            args = args.Replace(solution.EncryptionKey, "\"" + solution.EncryptionKey + "\"");
            if (options.PasswordEncrypted && !string.IsNullOrEmpty(options.Pass))
            {
                args = args.Replace(options.Pass, "\"" + options.Pass + "\"");
            }

            // !!!!!!!!!!!!!!!!!!!
            // TODO: we want to move SCM to another verb/action !!!!!

            //if (cliHelper.DownloadUpgradeSolutionFromSourceControl == true)
            //{
            //    Args += string.Format(" --sourceControlType {0}" , solution.SourceControl.GetSourceControlType.ToString());
            //    if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.SVN)//added for supporting Jenkins way of config creation- need to improve it
            //    {
            //        string modifiedURI = solution.SourceControl.SourceControlURL.TrimEnd(new char[] { '/' });
            //        int lastSlash = modifiedURI.LastIndexOf('/');
            //        modifiedURI = (lastSlash > -1) ? modifiedURI.Substring(0, lastSlash) : modifiedURI;
            //        Args += string.Format(" --sourceControlUrl {0}", modifiedURI);
            //    }
            //    else
            //    {
            //        Args += string.Format(" --sourceControlUrl {0}", solution.SourceControl.SourceControlURL);
            //    }
            //    Args += string.Format(" --sourceControlUser {0}" , solution.SourceControl.SourceControlUser);
            //    Args += string.Format(" --sourceControlPassword {0}" , EncryptionHandler.EncryptwithKey(solution.SourceControl.SourceControlPass));
            //    Args += string.Format(" --sourceControlPasswordEncrypted {0}" , "Y");
            //    if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.GIT && solution.SourceControl.SourceControlProxyAddress.ToLower().ToString() == "true")
            //    {
            //        Args += string.Format(" --sourceControlProxyServer {0}" , solution.SourceControl.SourceControlProxyAddress.ToString());
            //        Args += string.Format(" --sourceControlProxyPort {0}" , solution.SourceControl.SourceControlProxyPort.ToString());
            //    }
            //}

            return(args);
        }