SEBWIN-320: Made mutex names application-wide constants and fixed unit test for lockdown operation.
This commit is contained in:
parent
8d0c83998c
commit
d9f546aa74
6 changed files with 24 additions and 7 deletions
|
@ -9,12 +9,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Client
|
namespace SafeExamBrowser.Client
|
||||||
{
|
{
|
||||||
public class App : Application
|
public class App : Application
|
||||||
{
|
{
|
||||||
private static readonly Mutex Mutex = new Mutex(true, "safe_exam_browser_client_mutex");
|
private static readonly Mutex Mutex = new Mutex(true, AppConfig.CLIENT_MUTEX_NAME);
|
||||||
private CompositionRoot instances = new CompositionRoot();
|
private CompositionRoot instances = new CompositionRoot();
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.XML" />
|
<Reference Include="System.XML" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
|
|
@ -26,11 +26,26 @@ namespace SafeExamBrowser.Contracts.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string BASE_ADDRESS = "net.pipe://localhost/safeexambrowser";
|
public const string BASE_ADDRESS = "net.pipe://localhost/safeexambrowser";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the synchronization primitive for the client component.
|
||||||
|
/// </summary>
|
||||||
|
public const string CLIENT_MUTEX_NAME = "safe_exam_browser_client_mutex";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the synchronization primitive for the runtime component.
|
||||||
|
/// </summary>
|
||||||
|
public const string RUNTIME_MUTEX_NAME = "safe_exam_browser_runtime_mutex";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The communication address of the service component.
|
/// The communication address of the service component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string SERVICE_ADDRESS = BASE_ADDRESS + "/service";
|
public const string SERVICE_ADDRESS = BASE_ADDRESS + "/service";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the synchronization primitive for the service component.
|
||||||
|
/// </summary>
|
||||||
|
public const string SERVICE_MUTEX_NAME = "safe_exam_browser_reset_mutex";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file path of the local client configuration for the active user.
|
/// The file path of the local client configuration for the active user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -9,12 +9,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
|
|
||||||
namespace SafeExamBrowser.ResetUtility.Procedure
|
namespace SafeExamBrowser.ResetUtility.Procedure
|
||||||
{
|
{
|
||||||
internal class Initialization : ProcedureStep
|
internal class Initialization : ProcedureStep
|
||||||
{
|
{
|
||||||
private static readonly Mutex mutex = new Mutex(true, "safe_exam_browser_reset_mutex");
|
private static readonly Mutex mutex = new Mutex(true, AppConfig.SERVICE_MUTEX_NAME);
|
||||||
|
|
||||||
public Initialization(ProcedureContext context) : base(context)
|
public Initialization(ProcedureContext context) : base(context)
|
||||||
{
|
{
|
||||||
|
@ -77,7 +78,7 @@ namespace SafeExamBrowser.ResetUtility.Procedure
|
||||||
|
|
||||||
private bool SebNotRunning()
|
private bool SebNotRunning()
|
||||||
{
|
{
|
||||||
var isRunning = Mutex.TryOpenExisting("safe_exam_browser_runtime_mutex", out _);
|
var isRunning = Mutex.TryOpenExisting(AppConfig.RUNTIME_MUTEX_NAME, out _);
|
||||||
|
|
||||||
if (isRunning)
|
if (isRunning)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,12 +10,13 @@ using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using SafeExamBrowser.Contracts.Configuration;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Runtime
|
namespace SafeExamBrowser.Runtime
|
||||||
{
|
{
|
||||||
public class App : Application
|
public class App : Application
|
||||||
{
|
{
|
||||||
private static readonly Mutex Mutex = new Mutex(true, "safe_exam_browser_runtime_mutex");
|
private static readonly Mutex Mutex = new Mutex(true, AppConfig.RUNTIME_MUTEX_NAME);
|
||||||
private CompositionRoot instances = new CompositionRoot();
|
private CompositionRoot instances = new CompositionRoot();
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace SafeExamBrowser.Service.UnitTests.Operations
|
||||||
public void Perform_MustSetConfigurationsCorrectly()
|
public void Perform_MustSetConfigurationsCorrectly()
|
||||||
{
|
{
|
||||||
var configuration = new Mock<IFeatureConfiguration>();
|
var configuration = new Mock<IFeatureConfiguration>();
|
||||||
var count = typeof(IFeatureConfigurationFactory).GetMethods().Where(m => m.Name.StartsWith("Create")).Count();
|
var count = typeof(IFeatureConfigurationFactory).GetMethods().Where(m => m.Name.StartsWith("Create") && m.Name != nameof(IFeatureConfigurationFactory.CreateAll)).Count();
|
||||||
|
|
||||||
configuration.SetReturnsDefault(true);
|
configuration.SetReturnsDefault(true);
|
||||||
factory.SetReturnsDefault(configuration.Object);
|
factory.SetReturnsDefault(configuration.Object);
|
||||||
|
@ -105,7 +105,7 @@ namespace SafeExamBrowser.Service.UnitTests.Operations
|
||||||
public void Perform_MustImmediatelyAbortOnFailure()
|
public void Perform_MustImmediatelyAbortOnFailure()
|
||||||
{
|
{
|
||||||
var configuration = new Mock<IFeatureConfiguration>();
|
var configuration = new Mock<IFeatureConfiguration>();
|
||||||
var count = typeof(IFeatureConfigurationFactory).GetMethods().Where(m => m.Name.StartsWith("Create")).Count();
|
var count = typeof(IFeatureConfigurationFactory).GetMethods().Where(m => m.Name.StartsWith("Create") && m.Name != nameof(IFeatureConfigurationFactory.CreateAll)).Count();
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
var offset = 3;
|
var offset = 3;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue