From 751bfcb1446e9563ccb509ea76b6fa65ae526e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Wed, 1 Nov 2023 13:52:39 +0100 Subject: [PATCH] SEBWIN-762: Added user identifier detection via Moodle plugin and overall renamed session to user identifier. --- ... => UserIdentifierDetectedEventHandler.cs} | 4 +- .../IBrowserApplication.cs | 8 +- .../SafeExamBrowser.Browser.Contracts.csproj | 2 +- .../Handlers/ResourceHandlerTests.cs | 38 ++-- SafeExamBrowser.Browser/BrowserApplication.cs | 4 +- SafeExamBrowser.Browser/BrowserWindow.cs | 6 +- .../Handlers/ResourceHandler.cs | 194 +++++++++++------- .../ClientControllerTests.cs | 8 +- SafeExamBrowser.Client/ClientController.cs | 16 +- .../IServerProxy.cs | 4 +- ...ierRequest.cs => UserIdentifierRequest.cs} | 4 +- .../SafeExamBrowser.Server.csproj | 2 +- SafeExamBrowser.Server/ServerProxy.cs | 8 +- 13 files changed, 173 insertions(+), 125 deletions(-) rename SafeExamBrowser.Browser.Contracts/Events/{SessionIdentifierDetectedEventHandler.cs => UserIdentifierDetectedEventHandler.cs} (79%) rename SafeExamBrowser.Server/Requests/{SessionIdentifierRequest.cs => UserIdentifierRequest.cs} (91%) diff --git a/SafeExamBrowser.Browser.Contracts/Events/SessionIdentifierDetectedEventHandler.cs b/SafeExamBrowser.Browser.Contracts/Events/UserIdentifierDetectedEventHandler.cs similarity index 79% rename from SafeExamBrowser.Browser.Contracts/Events/SessionIdentifierDetectedEventHandler.cs rename to SafeExamBrowser.Browser.Contracts/Events/UserIdentifierDetectedEventHandler.cs index dbbd52c3..2d44db5a 100644 --- a/SafeExamBrowser.Browser.Contracts/Events/SessionIdentifierDetectedEventHandler.cs +++ b/SafeExamBrowser.Browser.Contracts/Events/UserIdentifierDetectedEventHandler.cs @@ -9,7 +9,7 @@ namespace SafeExamBrowser.Browser.Contracts.Events { /// - /// Event handler used to indicate that the browser has detected a session identifier of a LMS. + /// Event handler used to indicate that the browser has detected a user identifier of an LMS. /// - public delegate void SessionIdentifierDetectedEventHandler(string identifier); + public delegate void UserIdentifierDetectedEventHandler(string identifier); } diff --git a/SafeExamBrowser.Browser.Contracts/IBrowserApplication.cs b/SafeExamBrowser.Browser.Contracts/IBrowserApplication.cs index 8cb418f8..98ab461e 100644 --- a/SafeExamBrowser.Browser.Contracts/IBrowserApplication.cs +++ b/SafeExamBrowser.Browser.Contracts/IBrowserApplication.cs @@ -22,9 +22,9 @@ namespace SafeExamBrowser.Browser.Contracts event DownloadRequestedEventHandler ConfigurationDownloadRequested; /// - /// Event fired when the browser application detects a session identifier of an LMS. + /// Event fired when the user tries to focus the taskbar. /// - event SessionIdentifierDetectedEventHandler SessionIdentifierDetected; + event LoseFocusRequestedEventHandler LoseFocusRequested; /// /// Event fired when the browser application detects a request to terminate SEB. @@ -32,9 +32,9 @@ namespace SafeExamBrowser.Browser.Contracts event TerminationRequestedEventHandler TerminationRequested; /// - /// Event fired when the user tries to focus the taskbar. + /// Event fired when the browser application detects a user identifier of an LMS. /// - event LoseFocusRequestedEventHandler LoseFocusRequested; + event UserIdentifierDetectedEventHandler UserIdentifierDetected; /// /// Transfers the focus to the browser application. If the parameter is true, the first focusable element in the browser window diff --git a/SafeExamBrowser.Browser.Contracts/SafeExamBrowser.Browser.Contracts.csproj b/SafeExamBrowser.Browser.Contracts/SafeExamBrowser.Browser.Contracts.csproj index e74e58d5..e993bfcc 100644 --- a/SafeExamBrowser.Browser.Contracts/SafeExamBrowser.Browser.Contracts.csproj +++ b/SafeExamBrowser.Browser.Contracts/SafeExamBrowser.Browser.Contracts.csproj @@ -60,7 +60,7 @@ - + diff --git a/SafeExamBrowser.Browser.UnitTests/Handlers/ResourceHandlerTests.cs b/SafeExamBrowser.Browser.UnitTests/Handlers/ResourceHandlerTests.cs index 06441071..c999b63e 100644 --- a/SafeExamBrowser.Browser.UnitTests/Handlers/ResourceHandlerTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Handlers/ResourceHandlerTests.cs @@ -166,7 +166,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers [TestMethod] public void MustLetOperatingSystemHandleUnknownProtocols() { - Assert.IsTrue(sut.OnProtocolExecution(default(IWebBrowser), default(IBrowser), default(IFrame), default(IRequest))); + Assert.IsTrue(sut.OnProtocolExecution(default, default, default, default)); } [TestMethod] @@ -232,28 +232,28 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers var newUrl = default(string); var request = new Mock(); var response = new Mock(); - var sessionId = default(string); + var userId = default(string); headers.Add("X-LMS-USER-ID", "some-session-id-123"); request.SetupGet(r => r.Url).Returns("https://www.somelms.org"); response.SetupGet(r => r.Headers).Returns(headers); - sut.SessionIdentifierDetected += (id) => + sut.UserIdentifierDetected += (id) => { - sessionId = id; + userId = id; @event.Set(); }; sut.OnResourceRedirect(Mock.Of(), Mock.Of(), Mock.Of