From 3711555f704d3a99d037081b7b3e8d7486b68f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Tue, 5 Sep 2023 17:47:05 +0200 Subject: [PATCH] SEBWIN-727: Implemented support for configuration data URIs. --- .../Handlers/RequestHandlerTests.cs | 44 ++++++++++++++++--- .../Handlers/RequestHandler.cs | 26 ++++++++--- SafeExamBrowser.Client/ClientController.cs | 4 +- .../Operations/ServerOperation.cs | 5 +++ .../Windows/ServerFailureDialog.xaml | 2 +- 5 files changed, 68 insertions(+), 13 deletions(-) diff --git a/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs b/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs index 34b24d44..7d15ace7 100644 --- a/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs @@ -69,6 +69,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers var quitUrl = "http://www.byebye.com"; var request = new Mock(); + appConfig.ConfigurationFileMimeType = "application/seb"; request.SetupGet(r => r.Url).Returns(quitUrl); settings.QuitUrl = quitUrl; sut.QuitUrlVisited += (url) => eventFired = true; @@ -122,6 +123,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers var request = new Mock(); var url = "https://www.test.org"; + appConfig.ConfigurationFileMimeType = "application/seb"; filter.Setup(f => f.Process(It.Is(r => r.Url.Equals(url)))).Returns(FilterResult.Block); request.SetupGet(r => r.ResourceType).Returns(ResourceType.MainFrame); request.SetupGet(r => r.Url).Returns(url); @@ -155,6 +157,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers var request = new Mock(); var url = "https://www.test.org"; + appConfig.ConfigurationFileMimeType = "application/seb"; filter.Setup(f => f.Process(It.Is(r => r.Url.Equals(url)))).Returns(FilterResult.Block); request.SetupGet(r => r.ResourceType).Returns(ResourceType.SubFrame); request.SetupGet(r => r.Url).Returns(url); @@ -182,13 +185,34 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers } [TestMethod] - public void MustInitiateConfigurationFileDownload() + public void MustInitiateDataUriConfigurationFileDownload() { var browser = new Mock(); var host = new Mock(); var request = new Mock(); appConfig.ConfigurationFileExtension = ".xyz"; + appConfig.ConfigurationFileMimeType = "application/seb"; + appConfig.SebUriScheme = "abc"; + appConfig.SebUriSchemeSecure = "abcd"; + browser.Setup(b => b.GetHost()).Returns(host.Object); + request.SetupGet(r => r.Url).Returns($"{appConfig.SebUriSchemeSecure}://{appConfig.ConfigurationFileMimeType};base64,H4sIAAAAAAAAE41WbXPaRhD..."); + + var handled = sut.OnBeforeBrowse(Mock.Of(), browser.Object, Mock.Of