public static void ClassInitialize(TestContext TestContext) { mTestHelper.ClassInitialize(TestContext); string path = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "OutputVariableOldSolution")); WorkSpace.Instance.OpenSolution(path, EncryptionHandler.GetDefaultKey()); }
public static void ClassInitialize(TestContext TC) { WorkspaceHelper.CreateWorkspace2(); mTestHelper.ClassInitialize(TC); string path = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "RepositoryItemTest")); WorkSpace.Instance.OpenSolution(path, EncryptionHandler.GetDefaultKey()); }
public static void ClassInitialize(TestContext TC) { mTestHelper.ClassInitialize(TC); string path = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "GlobalCrossSolution")); SR = WorkspaceHelper.CreateWorkspaceAndOpenSolution(path); GlobalSolutionUtils.Instance.SolutionFolder = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "GlobalCrossSolution")); GlobalSolutionUtils.Instance.EncryptionKey = EncryptionHandler.GetDefaultKey(); }
/// <summary> /// For encrypting password variables /// </summary> public bool ValidateKey(string encryptionKey = null) { try { bool isDecrypted = EncryptionHandler.DecryptwithKey(Solution.EncryptedValidationString, encryptionKey ?? Solution.EncryptionKey).Equals("valid"); if (isDecrypted) { Solution.EncryptionKey = encryptionKey ?? (Solution.EncryptionKey ?? EncryptionHandler.GetDefaultKey()); } return(isDecrypted); } catch (Exception ex) { Reporter.ToLog(eLogLevel.DEBUG, ex.Message); } return(false); }
public void GetDependaciesForGlobalVariableUsingRegex() { //Arrange string filePath = TestResources.GetTestResourcesFile(@"Solutions" + Path.DirectorySeparatorChar + "GlobalCrossSolution" + Path.DirectorySeparatorChar + "BusinessFlows" + Path.DirectorySeparatorChar + "Flow 1.Ginger.BusinessFlow.xml"); //Act GlobalSolutionUtils.Instance.AddDependaciesForGlobalVariable(filePath, ref SelectedItemsListToImport, ref VariableListToImport); //Assert Assert.AreEqual(VariableListToImport.Count, 2); Assert.IsNotNull(VariableListToImport.Where(x => x.Name == "NewVarString")); Assert.IsNotNull(VariableListToImport.Where(x => x.Name == "NewVarPasswordString")); string strValuetoPass = EncryptionHandler.DecryptwithKey(VariableListToImport.Where(x => x.Name == "NewVarPasswordString").FirstOrDefault().Value, EncryptionHandler.GetDefaultKey()); Assert.AreEqual(strValuetoPass, "ABCD"); }
public void GetBusinessFlowDependacies() { //Arrange string filePath = TestResources.GetTestResourcesFile(@"Solutions" + Path.DirectorySeparatorChar + "GlobalCrossSolution" + Path.DirectorySeparatorChar + "BusinessFlows" + Path.DirectorySeparatorChar + "Flow 1.Ginger.BusinessFlow.xml"); //Act GlobalSolutionItem item = new GlobalSolutionItem(GlobalSolution.eImportItemType.Environments, filePath, GlobalSolutionUtils.Instance.ConvertToRelativePath(filePath), true, GlobalSolutionUtils.Instance.GetRepositoryItemName(filePath), ""); GlobalSolutionUtils.Instance.AddDependaciesForBusinessFlows(item, ref SelectedItemsListToImport, ref VariableListToImport, ref EnvAppListToImport); //Assert Assert.AreEqual(SelectedItemsListToImport.Count, 12); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\Applications Models\\POM Models\\SeleniumDemoValid.Ginger.ApplicationPOMModel.xml")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\SharedRepository\\Actions\\Browser Action.Ginger.Action.xml")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\SharedRepository\\Actions\\UIElement Action.Ginger.Action.xml")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\SharedRepository\\Activities\\Activity 2.Ginger.Activity.xml")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\DataSources\\AccessDS.Ginger.DataSource.xml")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\Documents\\bankCode3.xml")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\Documents\\Multiple Values.xlsx")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\Environments\\Test.Ginger.Environment.xml")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "NewVarString")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "MyWebApp")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "MyWebServicesApp")); Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "MyWindowsApp")); Assert.AreEqual(VariableListToImport.Count, 2); Assert.IsNotNull(VariableListToImport.Where(x => x.Name == "NewVarString")); Assert.IsNotNull(VariableListToImport.Where(x => x.Name == "NewVarPasswordString")); string strValuetoPass = EncryptionHandler.DecryptwithKey(VariableListToImport.Where(x => x.Name == "NewVarPasswordString").FirstOrDefault().Value, EncryptionHandler.GetDefaultKey()); Assert.AreEqual(strValuetoPass, "ABCD"); Assert.AreEqual(EnvAppListToImport.Count, 1); Assert.IsNotNull(EnvAppListToImport.Where(x => x.Name == "MyWebApp")); }
public bool OpenSolution(string solutionFolder, string encryptionKey = null) { try { Reporter.ToLog(eLogLevel.INFO, string.Format("Loading the Solution '{0}'", solutionFolder)); LoadingSolution = true; //Cleaning previous Solution load Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Cleaning previous Solution items"); CloseSolution(); //Load Solution file //Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Opening Solution located at: " + solutionFolder); string solutionFile = System.IO.Path.Combine(solutionFolder, @"Ginger.Solution.xml"); Reporter.ToLog(eLogLevel.INFO, string.Format("Loading Solution- Loading Solution File: '{0}'", solutionFile)); if (System.IO.File.Exists(solutionFile)) { Reporter.ToLog(eLogLevel.DEBUG, "Loading Solution- Solution File exist"); } else { if (!File.Exists(Amdocs.Ginger.IO.PathHelper.GetLongPath(solutionFile))) { //Reporter.ToUser(eUserMsgKey.BeginWithNoSelectSolution); Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Solution File Not Found"); return(false); } } //Checking if Ginger upgrade is needed Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Checking if Ginger Solution items upgrade is needed"); IEnumerable <string> solutionFiles = Solution.SolutionFiles(solutionFolder); SolutionUpgrade.ClearPreviousScans(); if (SolutionUpgrade.IsGingerUpgradeNeeded(solutionFolder, solutionFiles)) { Reporter.ToLog(eLogLevel.WARN, "Loading Solution- Error: Current Ginger version can't load the Solution because it includes items from higher Ginger version"); return(false); } Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Loading Solution file xml into object"); Solution solution = SolutionOperations.LoadSolution(solutionFile, true, encryptionKey); SolutionOperations solutionOperations = new SolutionOperations(solution); solution.SolutionOperations = solutionOperations; if (solution == null) { Reporter.ToUser(eUserMsgKey.SolutionLoadError, "Failed to load the Solution file"); Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Failed to load the Solution file"); return(false); } EncryptionHandler.SetCustomKey(solution.EncryptionKey); if (!solution.SolutionOperations.ValidateKey()) { if (WorkSpace.Instance.RunningInExecutionMode == false && WorkSpace.Instance.RunningFromUnitTest == false) { if (string.IsNullOrEmpty(solution.EncryptedValidationString)) { // To support existing solutions, solution.EncryptionKey = EncryptionHandler.GetDefaultKey(); solution.NeedVariablesReEncryption = true; solution.SolutionOperations.SaveEncryptionKey(); solution.SolutionOperations.SaveSolution(false); } else if (!Instance.EventHandler.OpenEncryptionKeyHandler(solution)) { return(false); } } else { Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Encryption key validation failed"); return(false); } } Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Creating Items Repository"); SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository(); SolutionRepository.Open(solutionFolder); Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Loading needed Plugins"); mPluginsManager = new PluginsManager(); mPluginsManager.SolutionChanged(SolutionRepository); Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Doing Source Control Configurations"); try { HandleSolutionLoadSourceControl(solution); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "exception occured while doing Solution Source Control Configurations", ex); } Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Updating Application Functionalities to Work with Loaded Solution"); ValueExpression.SolutionFolder = solutionFolder; BusinessFlow.SolutionVariables = solution.Variables; solution.SolutionOperations.SetReportsConfigurations(); Solution = solution; UserProfile.UserProfileOperations.LoadRecentAppAgentMapping(); if (!RunningInExecutionMode) { AppSolutionRecover.DoSolutionAutoSaveAndRecover(); } //Solution items upgrade SolutionUpgrade.CheckSolutionItemsUpgrade(solutionFolder, solution.Name, solutionFiles.ToList()); if (!RunningInExecutionMode && mSolution.NeedVariablesReEncryption) { string msg = "Going forward each solution needs to have its own key for encrypting password values\n" + "Please make a note of Default key updated on Solution details page. This key is mandatory for accessing solution"; Reporter.ToUser(eUserMsgKey.SolutionEncryptionKeyUpgrade, msg); Instance.EventHandler.OpenEncryptionKeyHandler(null); } // No need to add solution to recent if running from CLI if (!RunningInExecutionMode) { ((UserProfileOperations)UserProfile.UserProfileOperations).AddSolutionToRecent(solution); } // PlugInsManager = new PluginsManager(); // mPluginsManager.Init(SolutionRepository); Reporter.ToLog(eLogLevel.INFO, string.Format("Finished Loading successfully the Solution '{0}'", solutionFolder)); return(true); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Unexpected Error occurred while loading the solution", ex); CloseSolution(); throw ex; } finally { LoadingSolution = false; } }
public void RunsetRunnersLazyLoadTest_Loaded() { //Arrange WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey()); SolutionRepository SR = WorkSpace.Instance.SolutionRepository; //Act ObservableList <RunSetConfig> runSetConfigs = SR.GetAllRepositoryItems <RunSetConfig>(); ObservableList <GingerRunner> runners = runSetConfigs[0].GingerRunners; //Assert Assert.AreEqual(runSetConfigs.Count, 1, "Validating run sets were loaded"); Assert.AreEqual(runSetConfigs[0].GingerRunnersLazyLoad, false, "Validating run set runners were loaded 1"); Assert.AreEqual(runners.Count, 1, "Validating run set runners were loaded 2"); }
public void ActivityVariablesLazyLoadTest_Loaded() { //Arrange WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey()); SolutionRepository SR = WorkSpace.Instance.SolutionRepository; //Act ObservableList <BusinessFlow> bfs = SR.GetAllRepositoryItems <BusinessFlow>(); ObservableList <Activity> activities = bfs[0].Activities; ObservableList <VariableBase> variables = activities[0].Variables; //Assert Assert.AreEqual(bfs.Count, 1, "Validating Bfs were loaded"); Assert.AreEqual(bfs[0].ActivitiesLazyLoad, false, "Validating Bf Activities were loaded 1"); Assert.AreEqual(activities.Count, 1, "Validating Bf Activities were loaded 2"); Assert.AreEqual(activities[0].VariablesLazyLoad, false, "Validating Activity variables were loaded 1"); Assert.AreEqual(variables.Count, 1, "Validating Activity variables were loaded 2 "); }
public void BFVariablesLazyLoadTest_NotLoaded() { //Arrange WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey()); SolutionRepository SR = WorkSpace.Instance.SolutionRepository; //Act ObservableList <BusinessFlow> bfs = SR.GetAllRepositoryItems <BusinessFlow>(); //Assert Assert.AreEqual(bfs.Count, 1, "Validating Bfs were loaded"); Assert.AreEqual(bfs[0].VariablesLazyLoad, true, "Validating Bf Variables were not loaded"); }
public void SolutionPomElementsLazyLoadTest_Loaded() { //Arrange WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey()); SolutionRepository SR = WorkSpace.Instance.SolutionRepository; //Act ObservableList <ApplicationPOMModel> poms = SR.GetAllRepositoryItems <ApplicationPOMModel>(); ObservableList <ElementInfo> unMapped = poms[0].UnMappedUIElements; ObservableList <ElementInfo> mapped = poms[0].MappedUIElements; //Assert Assert.AreEqual(poms.Count, 1, "Validating POMs were loaded"); Assert.AreEqual(poms[0].UnMappedUIElementsLazyLoad, false, "Validating POM Un Mappped Elements were loaded 1"); //Assert.AreEqual(unMapped.Count, 1, "Validating POM Un Mappped Elements were loaded 2"); //TODO: move HtmlElementInfo to .NET core project for enabeling this Assert Assert.AreEqual(poms[0].MappedUIElementsLazyLoad, false, "Validating POM Mappped Elements were not loaded 1"); //Assert.AreEqual(mapped.Count, 15, "Validating POM Mappped Elements were not loaded 2 "); //TODO: move HtmlElementInfo to .NET core project for enabeling this Assert }
public void SolutionPomElementsLazyLoadTest_NotLoaded() { //Arrange WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey()); SolutionRepository SR = WorkSpace.Instance.SolutionRepository; //Act ObservableList <ApplicationPOMModel> poms = SR.GetAllRepositoryItems <ApplicationPOMModel>(); //Assert Assert.AreEqual(poms.Count, 1, "Validating POMs were loaded"); Assert.AreEqual(poms[0].UnMappedUIElementsLazyLoad, true, "Validating POM Un Mappped Elements were not loaded"); Assert.AreEqual(poms[0].MappedUIElementsLazyLoad, true, "Validating POM Mappped Elements were not loaded"); }