Remove UmbracoPath setting (#16037)
* Use require modifier instead of setting null-suppressed default values * Only remove read-only properties when IgnoreReadOnlyProperties is set * Obsolete UmbracoPath property and remove work-around for obsolete setter * Remove UmbracoPath setting and use constant instead * Remove usage of GetBackOfficePath * Add IHostingEnvironment.GetBackOfficePath() extension method * Add Constants.System.UmbracoPathSegment constant * Update Constants.System XML docs * Replace StringBuilder with string interpolation Co-authored-by: Nuklon <Nuklon@users.noreply.github.com> * Fix syntax error * Removed uses of obsoletes. * Further obsolete messages. * Cleaned up usings. * Update src/Umbraco.Infrastructure/Install/FilePermissionHelper.cs Co-authored-by: Ronald Barendse <ronald@barend.se> --------- Co-authored-by: Nuklon <Nuklon@users.noreply.github.com> Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using AutoFixture.NUnit3;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Tests.UnitTests.AutoFixture;
|
||||
using Umbraco.Cms.Web.Common.AspNetCore;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Configuration.Models;
|
||||
|
||||
[TestFixture]
|
||||
public class GlobalSettingsTests
|
||||
{
|
||||
[InlineAutoMoqData("~/umbraco", "/", "umbraco")]
|
||||
[InlineAutoMoqData("~/umbraco", "/MyVirtualDir", "umbraco")]
|
||||
[InlineAutoMoqData("~/customPath", "/MyVirtualDir/", "umbraco")]
|
||||
[InlineAutoMoqData("~/some-wacky/nestedPath", "/MyVirtualDir", "umbraco")]
|
||||
[InlineAutoMoqData("~/some-wacky/nestedPath", "/MyVirtualDir/NestedVDir/", "umbraco")]
|
||||
public void Umbraco_Mvc_Area(
|
||||
string path,
|
||||
string rootPath,
|
||||
string outcome,
|
||||
[Frozen] IOptionsMonitor<HostingSettings> hostingSettings,
|
||||
AspNetCoreHostingEnvironment hostingEnvironment)
|
||||
{
|
||||
hostingSettings.CurrentValue.ApplicationVirtualPath = rootPath;
|
||||
|
||||
var globalSettings = new GlobalSettings();
|
||||
|
||||
Assert.AreEqual(outcome, globalSettings.GetUmbracoMvcAreaNoCache(hostingEnvironment));
|
||||
}
|
||||
}
|
||||
@@ -12,26 +12,22 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
||||
[TestFixture]
|
||||
public class UmbracoRequestPathsTests
|
||||
{
|
||||
private IWebHostEnvironment _hostEnvironment;
|
||||
private UmbracoRequestPathsOptions _umbracoRequestPathsOptions;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_hostEnvironment = Mock.Of<IWebHostEnvironment>();
|
||||
_globalSettings = new GlobalSettings();
|
||||
_umbracoRequestPathsOptions = new UmbracoRequestPathsOptions();
|
||||
}
|
||||
|
||||
private IWebHostEnvironment _hostEnvironment;
|
||||
private GlobalSettings _globalSettings;
|
||||
private UmbracoRequestPathsOptions _umbracoRequestPathsOptions;
|
||||
|
||||
private IHostingEnvironment CreateHostingEnvironment(string virtualPath = "")
|
||||
{
|
||||
var hostingSettings = new HostingSettings { ApplicationVirtualPath = virtualPath };
|
||||
var webRoutingSettings = new WebRoutingSettings();
|
||||
var mockedOptionsMonitorOfHostingSettings =
|
||||
Mock.Of<IOptionsMonitor<HostingSettings>>(x => x.CurrentValue == hostingSettings);
|
||||
var mockedOptionsMonitorOfWebRoutingSettings =
|
||||
Mock.Of<IOptionsMonitor<WebRoutingSettings>>(x => x.CurrentValue == webRoutingSettings);
|
||||
var mockedOptionsMonitorOfHostingSettings = Mock.Of<IOptionsMonitor<HostingSettings>>(x => x.CurrentValue == hostingSettings);
|
||||
var mockedOptionsMonitorOfWebRoutingSettings = Mock.Of<IOptionsMonitor<WebRoutingSettings>>(x => x.CurrentValue == webRoutingSettings);
|
||||
|
||||
return new TestHostingEnvironment(
|
||||
mockedOptionsMonitorOfHostingSettings,
|
||||
@@ -50,7 +46,7 @@ public class UmbracoRequestPathsTests
|
||||
public void Is_Client_Side_Request(string url, bool assert)
|
||||
{
|
||||
var hostingEnvironment = CreateHostingEnvironment();
|
||||
var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment, Options.Create(_umbracoRequestPathsOptions));
|
||||
var umbracoRequestPaths = new UmbracoRequestPaths(hostingEnvironment, Options.Create(_umbracoRequestPathsOptions));
|
||||
|
||||
var uri = new Uri("http://test.com" + url);
|
||||
var result = umbracoRequestPaths.IsClientSideRequest(uri.AbsolutePath);
|
||||
@@ -61,7 +57,7 @@ public class UmbracoRequestPathsTests
|
||||
public void Is_Client_Side_Request_InvalidPath_ReturnFalse()
|
||||
{
|
||||
var hostingEnvironment = CreateHostingEnvironment();
|
||||
var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment, Options.Create(_umbracoRequestPathsOptions));
|
||||
var umbracoRequestPaths = new UmbracoRequestPaths(hostingEnvironment, Options.Create(_umbracoRequestPathsOptions));
|
||||
|
||||
// This URL is invalid. Default to false when the extension cannot be determined
|
||||
var uri = new Uri("http://test.com/installing-modules+foobar+\"yipee\"");
|
||||
@@ -93,7 +89,7 @@ public class UmbracoRequestPathsTests
|
||||
{
|
||||
var source = new Uri(input);
|
||||
var hostingEnvironment = CreateHostingEnvironment(virtualPath);
|
||||
var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment, Options.Create(_umbracoRequestPathsOptions));
|
||||
var umbracoRequestPaths = new UmbracoRequestPaths(hostingEnvironment, Options.Create(_umbracoRequestPathsOptions));
|
||||
Assert.AreEqual(expected, umbracoRequestPaths.IsBackOfficeRequest(source.AbsolutePath));
|
||||
}
|
||||
|
||||
@@ -105,9 +101,11 @@ public class UmbracoRequestPathsTests
|
||||
{
|
||||
var source = new Uri(input);
|
||||
var hostingEnvironment = CreateHostingEnvironment();
|
||||
var umbracoRequestPathsOptions = new UmbracoRequestPathsOptions();
|
||||
umbracoRequestPathsOptions.IsBackOfficeRequest = _ => true;
|
||||
var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment, Options.Create(umbracoRequestPathsOptions));
|
||||
var umbracoRequestPathsOptions = new UmbracoRequestPathsOptions
|
||||
{
|
||||
IsBackOfficeRequest = _ => true
|
||||
};
|
||||
var umbracoRequestPaths = new UmbracoRequestPaths(hostingEnvironment, Options.Create(umbracoRequestPathsOptions));
|
||||
Assert.AreEqual(expected, umbracoRequestPaths.IsBackOfficeRequest(source.AbsolutePath));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user