// Failing !!! needs fix!!! in UserProfile have one list of recent as string and one as objects causin exception public void NewProfileSaveLoad() { //Arrange //UserProfile userProfile = new UserProfile(); UserProfileOperations userProfileOperations = new UserProfileOperations(new UserProfile()); // string UserProfileFileName = Path.Combine(TestResources.GetTempFile("UserProfile.Ginger.xml")); // UP.FileName = UserProfileFileName; // WorkSpace.Instance.UserProfile = userProfile; string LastSolutionFolder = @"c:\ginger\sol1"; Solution solution = new Solution() { Name = "sol1", Folder = LastSolutionFolder }; // just something to verify it is loaded later doesn't need to exist //Act userProfileOperations.AddSolutionToRecent(solution); userProfileOperations.SaveUserProfile(); // WorkSpace.Instance.UserProfile = new UserProfile UserProfile UP2 = new UserProfile().LoadUserProfile(); //Assert Assert.AreEqual(LastSolutionFolder, UP2.RecentSolutions[0]); }
public async Task GetGivenNameTest() { var actual = await UserProfileOperations.GetGivenName(); actual.Match(s => { Assert.IsFalse(string.IsNullOrWhiteSpace(s)); return(""); }, () => { Assert.Fail("None not expected"); return(""); }); }
public void CreateUserProfileFileName() { // Arrange string UserAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string expected = Path.Combine(UserAppDataFolder, "amdocs", "Ginger", "Ginger.UserProfile.xml"); UserProfileOperations userProfileOperations = new UserProfileOperations(new UserProfile()); //Act string userProfileFilePath = userProfileOperations.UserProfileFilePath; //Assert Assert.AreEqual(expected, userProfileFilePath, "UserProfileFilePath"); }
public static async Task <Result <int> > CheckCompliance([OptionalCommandParameter( Description = "Free disk space requirement in GB", AlternativeName = "fr", ExampleValue = 40, DefaultValue = 40)] decimal requiredFreeDiskSpace, [OptionalCommandParameter( Description = "Subtract current size of Sccm cache. When set to true, disk space is compliant if: ((CurrentTotalFreeDiskSpace + CurrentSizeOfSccmCache) - requiredFreeDiskSpace) > 0. This parameter is ignored on a client without Sccm Client.", AlternativeName = "ssc", ExampleValue = true, DefaultValue = false)] bool subtractSccmCache, [OptionalCommandParameter( Description = "Maximum system uptime in hours before user gets notified about recommended reboot. Default is 168 hours (7 days).", DefaultValue = 168.0, AlternativeName = "mutd", ExampleValue = 168.0)] double maxUptimeHours, [OptionalCommandParameter(Description = "Hours to wait before notifying user about missing ms updates.", AlternativeName = "msuwait", ExampleValue = 48, DefaultValue = 48)] int hoursToWaitBeforeNotifyUserAboutMissingUpdates, [OptionalCommandParameter(Description = "Disable disk space check.", AlternativeName = "ddsc", ExampleValue = false, DefaultValue = false)] bool disableDiskSpaceCheck, [OptionalCommandParameter(Description = "Disable pending reboot check.", AlternativeName = "dprc", ExampleValue = false, DefaultValue = false)] bool disablePendingRebootCheck, [OptionalCommandParameter(Description = "Disable password expiry check.", AlternativeName = "dpec", ExampleValue = false, DefaultValue = false)] bool disablePasswordExpiryCheck, [OptionalCommandParameter(Description = "Disable system uptime check.", AlternativeName = "dsuc", ExampleValue = false, DefaultValue = false)] bool disableSystemUptimeCheck, [OptionalCommandParameter(Description = "Disable desktop data check.", AlternativeName = "dddc", ExampleValue = false, DefaultValue = false)] bool disableDesktopDataCheck, [OptionalCommandParameter(Description = "Disable missing MS updates check.", AlternativeName = "mmsuc", ExampleValue = false, DefaultValue = false)] bool disableMissingMsUpdatesCheck, [OptionalCommandParameter( Description = "Use a specific UI culture. F.example show user interface in Norwegian regardless of operating system display language.", AlternativeName = "uic", ExampleValue = "nb-NO", DefaultValue = "")] string userInterfaceCulture) { var policyUserInterfaceCulture = Profile.GetStringPolicyValue(Context.User, Option <string> .None, "UserInterfaceCulture", userInterfaceCulture); if (!string.IsNullOrEmpty(policyUserInterfaceCulture)) { CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(policyUserInterfaceCulture); } Process.GetCurrentProcess().CloseOtherProcessWithSameCommandLine(); var userProfile = await UserProfileOperations.LoadAndSetUserProfile().ConfigureAwait(false); var diskSpaceResult = new Result <ToastNotificationVisibility>(ToastNotificationVisibility.Hide); var pendingRebootResult = new Result <ToastNotificationVisibility>(ToastNotificationVisibility.Hide); var passwordExpiryResult = new Result <ToastNotificationVisibility>(ToastNotificationVisibility.Hide); var systemUptimeResult = new Result <ToastNotificationVisibility>(ToastNotificationVisibility.Hide); var desktopDataResult = new Result <ToastNotificationVisibility>(ToastNotificationVisibility.Hide); var missingMsUpdatesResult = new Result <ToastNotificationVisibility>(ToastNotificationVisibility.Hide); App.RunApplicationOnStart(async(sender, args) => { Logging.DefaultLogger.Info("Registering all toast groups"); ToastGroups.Groups.ForEach(group => Messenger.Default.Send(new RegisterToastNotificationMessage(group))); Logging.DefaultLogger.Info("Run compliance checks..."); diskSpaceResult = await CheckDiskSpaceCommand.CheckDiskSpace(userProfile, requiredFreeDiskSpace, subtractSccmCache, disableDiskSpaceCheck).ConfigureAwait(false); pendingRebootResult = await CheckPendingRebootCommand.CheckPendingReboot(userProfile, disablePendingRebootCheck).ConfigureAwait(false); passwordExpiryResult = await CheckPasswordExpiryCommand.CheckPasswordExpiry(userProfile, disablePasswordExpiryCheck).ConfigureAwait(false); systemUptimeResult = await CheckSystemUptimeCommand.CheckSystemUptime(userProfile, maxUptimeHours, disableSystemUptimeCheck).ConfigureAwait(false); desktopDataResult = await CheckDesktopDataCommand.CheckDesktopData(userProfile, disableDesktopDataCheck).ConfigureAwait(false); missingMsUpdatesResult = await CheckMissingMsUpdatesCommand.CheckMissingMsUpdates(userProfile, hoursToWaitBeforeNotifyUserAboutMissingUpdates, disableMissingMsUpdatesCheck).ConfigureAwait(false); Logging.DefaultLogger.Info("Waiting for all toast groups to be handled and unregistered..."); }); var result = new List <Result <ToastNotificationVisibility> > { diskSpaceResult, pendingRebootResult, passwordExpiryResult, systemUptimeResult, desktopDataResult, missingMsUpdatesResult } .ToResult().Match(_ => new Result <int>(0), exception => new Result <int>(exception)); return(await Task.FromResult(result).ConfigureAwait(false)); }
private async Task <int> HandleRunOptions(RunOptions runOptions) { WorkSpace.Instance.GingerCLIMode = eGingerCLIMode.run; SetVerboseLevel(runOptions.VerboseLevel); Reporter.ToLog(eLogLevel.INFO, string.Format("######## Starting Automatic {0} Execution Process ########", GingerDicser.GetTermResValue(eTermResKey.RunSet))); Reporter.ToLog(eLogLevel.INFO, string.Format("Parsing {0} execution arguments...", GingerDicser.GetTermResValue(eTermResKey.RunSet))); Reporter.ToLog(eLogLevel.INFO, $"Solution: '{runOptions.Solution}'"); Reporter.ToLog(eLogLevel.INFO, $"Runset: '{runOptions.Runset}'"); Reporter.ToLog(eLogLevel.INFO, $"Environment: '{runOptions.Environment}'"); Reporter.ToLog(eLogLevel.INFO, "Loading Configurations..."); mCLIHandler = new CLIArgs(); mCLIHelper.Solution = runOptions.Solution; mCLIHelper.SetEncryptionKey(runOptions.EncryptionKey); mCLIHelper.Runset = runOptions.Runset; mCLIHelper.Env = runOptions.Environment; mCLIHelper.RunAnalyzer = !runOptions.DoNotAnalyze; mCLIHelper.ShowAutoRunWindow = runOptions.ShowUI; mCLIHelper.TestArtifactsFolder = runOptions.TestArtifactsPath; mCLIHelper.SourceControlURL = runOptions.URL; mCLIHelper.SourcecontrolUser = runOptions.User; mCLIHelper.sourceControlType = runOptions.SCMType; mCLIHelper.sourceControlPass = runOptions.Pass; mCLIHelper.sourceControlPassEncrypted = runOptions.PasswordEncrypted; mCLIHelper.SourceControlProxyServer(runOptions.SourceControlProxyServer); mCLIHelper.SourceControlProxyPort(runOptions.SourceControlProxyPort); mCLIHelper.SelfHealingCheckInConfigured = runOptions.SelfHealingCheckInConfigured; if (!string.IsNullOrEmpty(runOptions.RunSetExecutionId)) { if (!Guid.TryParse(runOptions.RunSetExecutionId, out Guid temp)) { Reporter.ToLog(eLogLevel.ERROR, string.Format("The provided ExecutionID '{0}' is not valid.", runOptions.RunSetExecutionId)); Environment.ExitCode = 1; return(Environment.ExitCode); } else { mCLIHelper.ExecutionId = runOptions.RunSetExecutionId; Reporter.ToLog(eLogLevel.INFO, string.Format("Using provided ExecutionID '{0}'.", mCLIHelper.ExecutionId.ToString())); } } if (WorkSpace.Instance.UserProfile == null) { WorkSpace.Instance.UserProfile = new UserProfile(); UserProfileOperations userProfileOperations = new UserProfileOperations(WorkSpace.Instance.UserProfile); WorkSpace.Instance.UserProfile.UserProfileOperations = userProfileOperations; } WorkSpace.Instance.UserProfile.SourceControlURL = runOptions.URL; WorkSpace.Instance.UserProfile.SourceControlUser = runOptions.User; WorkSpace.Instance.UserProfile.SourceControlType = runOptions.SCMType; WorkSpace.Instance.UserProfile.UserProfileOperations.SourceControlIgnoreCertificate = runOptions.ignoreCertificate; WorkSpace.Instance.UserProfile.UserProfileOperations.SourceControlUseShellClient = runOptions.useScmShell; WorkSpace.Instance.UserProfile.EncryptedSourceControlPass = runOptions.Pass; WorkSpace.Instance.UserProfile.SourceControlPass = runOptions.Pass; if (runOptions.PasswordEncrypted) { mCLIHandler.LoadGeneralConfigurations("", mCLIHelper); } WorkSpace.Instance.RunningInExecutionMode = true; if (!CLILoadAndPrepare()) { Reporter.ToLog(eLogLevel.WARN, "Issue occured while doing CLI Load and Prepare so aborting execution"); Environment.ExitCode = 1; return(Environment.ExitCode); } await ExecuteRunSet(); mCLIHelper.PostExecution(); return(Environment.ExitCode); }