From a350949b1bbfdf82e85c40e255c1610f6212967a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Thu, 25 Jul 2024 15:30:56 +0200 Subject: [PATCH] SEBWIN-917: Consolidated detectors in monitoring assembly. --- .../IRemoteSessionDetector.cs | 2 +- .../IVirtualMachineDetector.cs | 2 +- .../SafeExamBrowser.Monitoring.Contracts.csproj | 2 ++ .../RemoteSessionDetector.cs | 4 ++-- .../SafeExamBrowser.Monitoring.csproj | 2 ++ .../VirtualMachineDetector.cs | 6 ++++-- .../Operations/RemoteSessionOperationTests.cs | 2 +- .../Operations/VirtualMachineOperationTests.cs | 2 +- SafeExamBrowser.Runtime/CompositionRoot.cs | 1 + .../Operations/RemoteSessionOperation.cs | 2 +- .../Operations/VirtualMachineOperation.cs | 6 +++--- .../SafeExamBrowser.SystemComponents.Contracts.csproj | 2 -- .../SafeExamBrowser.SystemComponents.csproj | 2 -- 13 files changed, 19 insertions(+), 16 deletions(-) rename {SafeExamBrowser.SystemComponents.Contracts => SafeExamBrowser.Monitoring.Contracts}/IRemoteSessionDetector.cs (91%) rename {SafeExamBrowser.SystemComponents.Contracts => SafeExamBrowser.Monitoring.Contracts}/IVirtualMachineDetector.cs (91%) rename {SafeExamBrowser.SystemComponents => SafeExamBrowser.Monitoring}/RemoteSessionDetector.cs (89%) rename {SafeExamBrowser.SystemComponents => SafeExamBrowser.Monitoring}/VirtualMachineDetector.cs (96%) diff --git a/SafeExamBrowser.SystemComponents.Contracts/IRemoteSessionDetector.cs b/SafeExamBrowser.Monitoring.Contracts/IRemoteSessionDetector.cs similarity index 91% rename from SafeExamBrowser.SystemComponents.Contracts/IRemoteSessionDetector.cs rename to SafeExamBrowser.Monitoring.Contracts/IRemoteSessionDetector.cs index f887be8a..0db0c4e0 100644 --- a/SafeExamBrowser.SystemComponents.Contracts/IRemoteSessionDetector.cs +++ b/SafeExamBrowser.Monitoring.Contracts/IRemoteSessionDetector.cs @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -namespace SafeExamBrowser.SystemComponents.Contracts +namespace SafeExamBrowser.Monitoring.Contracts { /// /// Provides functionality related to remote session detection. diff --git a/SafeExamBrowser.SystemComponents.Contracts/IVirtualMachineDetector.cs b/SafeExamBrowser.Monitoring.Contracts/IVirtualMachineDetector.cs similarity index 91% rename from SafeExamBrowser.SystemComponents.Contracts/IVirtualMachineDetector.cs rename to SafeExamBrowser.Monitoring.Contracts/IVirtualMachineDetector.cs index aeffd8e9..6a102519 100644 --- a/SafeExamBrowser.SystemComponents.Contracts/IVirtualMachineDetector.cs +++ b/SafeExamBrowser.Monitoring.Contracts/IVirtualMachineDetector.cs @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -namespace SafeExamBrowser.SystemComponents.Contracts +namespace SafeExamBrowser.Monitoring.Contracts { /// /// Provides functionality related to virtual machine detection. diff --git a/SafeExamBrowser.Monitoring.Contracts/SafeExamBrowser.Monitoring.Contracts.csproj b/SafeExamBrowser.Monitoring.Contracts/SafeExamBrowser.Monitoring.Contracts.csproj index 7987f8f0..4afbdd10 100644 --- a/SafeExamBrowser.Monitoring.Contracts/SafeExamBrowser.Monitoring.Contracts.csproj +++ b/SafeExamBrowser.Monitoring.Contracts/SafeExamBrowser.Monitoring.Contracts.csproj @@ -65,6 +65,8 @@ + + diff --git a/SafeExamBrowser.SystemComponents/RemoteSessionDetector.cs b/SafeExamBrowser.Monitoring/RemoteSessionDetector.cs similarity index 89% rename from SafeExamBrowser.SystemComponents/RemoteSessionDetector.cs rename to SafeExamBrowser.Monitoring/RemoteSessionDetector.cs index 4182ea1b..1ed75648 100644 --- a/SafeExamBrowser.SystemComponents/RemoteSessionDetector.cs +++ b/SafeExamBrowser.Monitoring/RemoteSessionDetector.cs @@ -8,9 +8,9 @@ using System.Windows.Forms; using SafeExamBrowser.Logging.Contracts; -using SafeExamBrowser.SystemComponents.Contracts; +using SafeExamBrowser.Monitoring.Contracts; -namespace SafeExamBrowser.SystemComponents +namespace SafeExamBrowser.Monitoring { public class RemoteSessionDetector : IRemoteSessionDetector { diff --git a/SafeExamBrowser.Monitoring/SafeExamBrowser.Monitoring.csproj b/SafeExamBrowser.Monitoring/SafeExamBrowser.Monitoring.csproj index 39913247..a9eaf79f 100644 --- a/SafeExamBrowser.Monitoring/SafeExamBrowser.Monitoring.csproj +++ b/SafeExamBrowser.Monitoring/SafeExamBrowser.Monitoring.csproj @@ -67,11 +67,13 @@ + + diff --git a/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs b/SafeExamBrowser.Monitoring/VirtualMachineDetector.cs similarity index 96% rename from SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs rename to SafeExamBrowser.Monitoring/VirtualMachineDetector.cs index cec40df6..94bc6b7d 100644 --- a/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs +++ b/SafeExamBrowser.Monitoring/VirtualMachineDetector.cs @@ -6,12 +6,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; using System.Linq; using SafeExamBrowser.Logging.Contracts; +using SafeExamBrowser.Monitoring.Contracts; using SafeExamBrowser.SystemComponents.Contracts; using SafeExamBrowser.SystemComponents.Contracts.Registry; -namespace SafeExamBrowser.SystemComponents +namespace SafeExamBrowser.Monitoring { public class VirtualMachineDetector : IVirtualMachineDetector { @@ -135,7 +137,7 @@ namespace SafeExamBrowser.SystemComponents private bool HasLocalVirtualMachineDeviceCache() { - var deviceName = System.Environment.GetEnvironmentVariable("COMPUTERNAME"); + var deviceName = Environment.GetEnvironmentVariable("COMPUTERNAME"); var hasDeviceCache = false; var hasDeviceCacheKeys = registry.TryGetSubKeys(RegistryValue.UserHive.DeviceCache_Key, out var deviceCacheKeys); diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/RemoteSessionOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/RemoteSessionOperationTests.cs index d34da71a..31992792 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/RemoteSessionOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/RemoteSessionOperationTests.cs @@ -11,10 +11,10 @@ using Moq; using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.Core.Contracts.OperationModel; using SafeExamBrowser.Logging.Contracts; +using SafeExamBrowser.Monitoring.Contracts; using SafeExamBrowser.Runtime.Operations; using SafeExamBrowser.Runtime.Operations.Events; using SafeExamBrowser.Settings; -using SafeExamBrowser.SystemComponents.Contracts; namespace SafeExamBrowser.Runtime.UnitTests.Operations { diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/VirtualMachineOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/VirtualMachineOperationTests.cs index 65587008..236dfe49 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/VirtualMachineOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/VirtualMachineOperationTests.cs @@ -11,10 +11,10 @@ using Moq; using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.Core.Contracts.OperationModel; using SafeExamBrowser.Logging.Contracts; +using SafeExamBrowser.Monitoring.Contracts; using SafeExamBrowser.Runtime.Operations; using SafeExamBrowser.Settings; using SafeExamBrowser.Settings.Security; -using SafeExamBrowser.SystemComponents.Contracts; namespace SafeExamBrowser.Runtime.UnitTests.Operations { diff --git a/SafeExamBrowser.Runtime/CompositionRoot.cs b/SafeExamBrowser.Runtime/CompositionRoot.cs index 0b464351..09788e43 100644 --- a/SafeExamBrowser.Runtime/CompositionRoot.cs +++ b/SafeExamBrowser.Runtime/CompositionRoot.cs @@ -25,6 +25,7 @@ using SafeExamBrowser.I18n; using SafeExamBrowser.I18n.Contracts; using SafeExamBrowser.Logging; using SafeExamBrowser.Logging.Contracts; +using SafeExamBrowser.Monitoring; using SafeExamBrowser.Monitoring.Display; using SafeExamBrowser.Monitoring.System; using SafeExamBrowser.Runtime.Communication; diff --git a/SafeExamBrowser.Runtime/Operations/RemoteSessionOperation.cs b/SafeExamBrowser.Runtime/Operations/RemoteSessionOperation.cs index 1862d2b8..10200fa2 100644 --- a/SafeExamBrowser.Runtime/Operations/RemoteSessionOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/RemoteSessionOperation.cs @@ -10,8 +10,8 @@ using SafeExamBrowser.Core.Contracts.OperationModel; using SafeExamBrowser.Core.Contracts.OperationModel.Events; using SafeExamBrowser.I18n.Contracts; using SafeExamBrowser.Logging.Contracts; +using SafeExamBrowser.Monitoring.Contracts; using SafeExamBrowser.Runtime.Operations.Events; -using SafeExamBrowser.SystemComponents.Contracts; using SafeExamBrowser.UserInterface.Contracts.MessageBox; namespace SafeExamBrowser.Runtime.Operations diff --git a/SafeExamBrowser.Runtime/Operations/VirtualMachineOperation.cs b/SafeExamBrowser.Runtime/Operations/VirtualMachineOperation.cs index 05f12f39..68b5caaa 100644 --- a/SafeExamBrowser.Runtime/Operations/VirtualMachineOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/VirtualMachineOperation.cs @@ -10,17 +10,17 @@ using SafeExamBrowser.Core.Contracts.OperationModel; using SafeExamBrowser.Core.Contracts.OperationModel.Events; using SafeExamBrowser.I18n.Contracts; using SafeExamBrowser.Logging.Contracts; +using SafeExamBrowser.Monitoring.Contracts; using SafeExamBrowser.Runtime.Operations.Events; using SafeExamBrowser.Settings.Security; -using SafeExamBrowser.SystemComponents.Contracts; using SafeExamBrowser.UserInterface.Contracts.MessageBox; namespace SafeExamBrowser.Runtime.Operations { internal class VirtualMachineOperation : SessionOperation { - private IVirtualMachineDetector detector; - private ILogger logger; + private readonly IVirtualMachineDetector detector; + private readonly ILogger logger; public override event ActionRequiredEventHandler ActionRequired; public override event StatusChangedEventHandler StatusChanged; diff --git a/SafeExamBrowser.SystemComponents.Contracts/SafeExamBrowser.SystemComponents.Contracts.csproj b/SafeExamBrowser.SystemComponents.Contracts/SafeExamBrowser.SystemComponents.Contracts.csproj index 7816c2b7..53c9b3e2 100644 --- a/SafeExamBrowser.SystemComponents.Contracts/SafeExamBrowser.SystemComponents.Contracts.csproj +++ b/SafeExamBrowser.SystemComponents.Contracts/SafeExamBrowser.SystemComponents.Contracts.csproj @@ -62,8 +62,6 @@ - - diff --git a/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj b/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj index 4e783d5e..c29e936a 100644 --- a/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj +++ b/SafeExamBrowser.SystemComponents/SafeExamBrowser.SystemComponents.csproj @@ -65,10 +65,8 @@ - -