diff --git a/SafeExamBrowser.Client/Operations/ApplicationOperation.cs b/SafeExamBrowser.Client/Operations/ApplicationOperation.cs index f20cbed7..eba09ab2 100644 --- a/SafeExamBrowser.Client/Operations/ApplicationOperation.cs +++ b/SafeExamBrowser.Client/Operations/ApplicationOperation.cs @@ -130,10 +130,13 @@ namespace SafeExamBrowser.Client.Operations var failed = new List(); var result = OperationResult.Success; + logger.Info($"The following applications need to be terminated: {string.Join(", ", runningApplications.Select(a => a.Name))}."); ActionRequired?.Invoke(args); if (args.TerminateProcesses) { + logger.Info($"The user chose to automatically terminate all running applications."); + foreach (var application in runningApplications) { var success = applicationMonitor.TryTerminate(application); @@ -152,6 +155,7 @@ namespace SafeExamBrowser.Client.Operations } else { + logger.Info("The user chose not to automatically terminate all running applications. Aborting..."); result = OperationResult.Aborted; } diff --git a/SafeExamBrowser.Monitoring/Applications/ApplicationMonitor.cs b/SafeExamBrowser.Monitoring/Applications/ApplicationMonitor.cs index 8d70c810..1c7c7de3 100644 --- a/SafeExamBrowser.Monitoring/Applications/ApplicationMonitor.cs +++ b/SafeExamBrowser.Monitoring/Applications/ApplicationMonitor.cs @@ -56,8 +56,8 @@ namespace SafeExamBrowser.Monitoring.Applications whitelist.Add(application); } - logger.Debug($"Initialized blacklist with {blacklist.Count} applications: {string.Join(", ", blacklist.Select(a => a.ExecutableName))}"); - logger.Debug($"Initialized whitelist with {whitelist.Count} applications: {string.Join(", ", whitelist.Select(a => a.ExecutableName))}"); + logger.Debug($"Initialized blacklist with {blacklist.Count} applications{(blacklist.Any() ? $": {string.Join(", ", blacklist.Select(a => a.ExecutableName))}" : ".")}"); + logger.Debug($"Initialized whitelist with {whitelist.Count} applications{(whitelist.Any() ? $": {string.Join(", ", whitelist.Select(a => a.ExecutableName))}" : ".")}"); foreach (var process in processFactory.GetAllRunning()) { diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs index f4889356..f8426b7e 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs @@ -15,11 +15,11 @@ using SafeExamBrowser.Communication.Contracts.Data; using SafeExamBrowser.Communication.Contracts.Hosts; using SafeExamBrowser.Communication.Contracts.Proxies; using SafeExamBrowser.Configuration.Contracts; -using SafeExamBrowser.Settings; using SafeExamBrowser.Core.Contracts.OperationModel; using SafeExamBrowser.Logging.Contracts; -using SafeExamBrowser.WindowsApi.Contracts; using SafeExamBrowser.Runtime.Operations; +using SafeExamBrowser.Settings; +using SafeExamBrowser.WindowsApi.Contracts; namespace SafeExamBrowser.Runtime.UnitTests.Operations { @@ -88,20 +88,6 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations Assert.AreEqual(OperationResult.Success, result); } - [TestMethod] - public void Perform_MustFailStartupIfClientNotStartedWithinTimeout() - { - var result = default(OperationResult); - - processFactory.Setup(f => f.StartNew(It.IsAny(), It.IsAny())).Returns(process.Object); - - result = sut.Perform(); - - Assert.IsNull(sessionContext.ClientProxy); - Assert.AreEqual(process.Object, sessionContext.ClientProcess); - Assert.AreEqual(OperationResult.Failed, result); - } - [TestMethod] public void Perform_MustFailStartupImmediatelyIfClientTerminates() { diff --git a/SafeExamBrowser.Runtime/Operations/ClientOperation.cs b/SafeExamBrowser.Runtime/Operations/ClientOperation.cs index 7c8d0cf2..8696f5fd 100644 --- a/SafeExamBrowser.Runtime/Operations/ClientOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/ClientOperation.cs @@ -119,7 +119,7 @@ namespace SafeExamBrowser.Runtime.Operations ClientProcess.Terminated += clientTerminatedEventHandler; logger.Info("Waiting for client to complete initialization..."); - clientReady = clientReadyEvent.WaitOne(timeout_ms); + clientReady = clientReadyEvent.WaitOne(); runtimeHost.AllowConnection = false; runtimeHost.AuthenticationToken = default(Guid?); @@ -133,7 +133,7 @@ namespace SafeExamBrowser.Runtime.Operations if (!clientReady) { - logger.Error($"Failed to start client within {timeout_ms / 1000} seconds!"); + logger.Error($"Failed to start client!"); } if (clientTerminated) diff --git a/SafeExamBrowser.WindowsApi/ProcessFactory.cs b/SafeExamBrowser.WindowsApi/ProcessFactory.cs index edc6582b..8d5fda46 100644 --- a/SafeExamBrowser.WindowsApi/ProcessFactory.cs +++ b/SafeExamBrowser.WindowsApi/ProcessFactory.cs @@ -93,7 +93,7 @@ namespace SafeExamBrowser.WindowsApi try { - using (var searcher = new ManagementObjectSearcher($"SELECT Name, ProcessId, ExecutablePath FROM Win32_Process")) + using (var searcher = new ManagementObjectSearcher($"SELECT ProcessId, ExecutablePath FROM Win32_Process")) using (var results = searcher.Get()) { var processData = results.Cast().ToList(); @@ -103,7 +103,6 @@ namespace SafeExamBrowser.WindowsApi using (process) { var processId = Convert.ToInt32(process["ProcessId"]); - var processName = Convert.ToString(process["Name"]); var executablePath = Convert.ToString(process["ExecutablePath"]); if (File.Exists(executablePath))