diff --git a/src/Umbraco.Core/Constants-Web.cs b/src/Umbraco.Core/Constants-Web.cs index 5d5fb4646b..b263de816b 100644 --- a/src/Umbraco.Core/Constants-Web.cs +++ b/src/Umbraco.Core/Constants-Web.cs @@ -53,8 +53,8 @@ public static class Mvc { public const string InstallArea = "UmbracoInstall"; - - public const string BackOfficeArea = "UmbracoApi"; + public const string BackOfficeArea = "UmbracoBackOffice"; // Used for area routes of non-api controllers + public const string BackOfficeApiArea = "UmbracoApi"; // Same name as v8 so all routing remains the same } } } diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/BackOfficeAreaRoutesTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/BackOfficeAreaRoutesTests.cs index a3a992bc22..7d0c3c8e04 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/BackOfficeAreaRoutesTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/BackOfficeAreaRoutesTests.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Routing; using Moq; using NUnit.Framework; using System.Linq; @@ -63,6 +64,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Web.Common.Routing Assert.AreEqual(Constants.Web.Mvc.BackOfficeArea, endpoint3.RoutePattern.Defaults["area"]); Assert.AreEqual("Index", endpoint3.RoutePattern.Defaults["action"]); Assert.AreEqual(previewControllerName, endpoint3.RoutePattern.Defaults["controller"]); + Assert.AreEqual(endpoint3.RoutePattern.Defaults["area"], typeof(PreviewController).GetCustomAttribute(false).RouteValue); var endpoint4 = (RouteEndpoint)route.Endpoints[3]; var apiControllerName = ControllerExtensions.GetControllerName(); @@ -79,13 +81,15 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Web.Common.Routing Assert.AreEqual(Constants.Web.Mvc.BackOfficeArea, endpoint1.RoutePattern.Defaults["area"]); Assert.AreEqual("Default", endpoint1.RoutePattern.Defaults["action"]); Assert.AreEqual(ControllerExtensions.GetControllerName(), endpoint1.RoutePattern.Defaults["controller"]); + Assert.AreEqual(endpoint1.RoutePattern.Defaults["area"], typeof(BackOfficeController).GetCustomAttribute(false).RouteValue); var endpoint2 = (RouteEndpoint)route.Endpoints[1]; var controllerName = ControllerExtensions.GetControllerName(); - Assert.AreEqual($"umbraco/backoffice/{Constants.Web.Mvc.BackOfficeArea.ToLowerInvariant()}/{controllerName.ToLowerInvariant()}/{{action}}/{{id?}}", endpoint2.RoutePattern.RawText); - Assert.AreEqual(Constants.Web.Mvc.BackOfficeArea, endpoint2.RoutePattern.Defaults["area"]); + Assert.AreEqual($"umbraco/backoffice/{Constants.Web.Mvc.BackOfficeApiArea.ToLowerInvariant()}/{controllerName.ToLowerInvariant()}/{{action}}/{{id?}}", endpoint2.RoutePattern.RawText); + Assert.AreEqual(Constants.Web.Mvc.BackOfficeApiArea, endpoint2.RoutePattern.Defaults["area"]); Assert.IsFalse(endpoint2.RoutePattern.Defaults.ContainsKey("action")); Assert.AreEqual(controllerName, endpoint2.RoutePattern.Defaults["controller"]); + Assert.AreEqual(endpoint1.RoutePattern.Defaults["area"], typeof(BackOfficeController).GetCustomAttribute(false).RouteValue); } private BackOfficeAreaRoutes GetBackOfficeAreaRoutes(RuntimeLevel level) diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/EndpointRouteBuilderExtensionsTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/EndpointRouteBuilderExtensionsTests.cs index 4c4d282813..a5b7c6dae3 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/EndpointRouteBuilderExtensionsTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/EndpointRouteBuilderExtensionsTests.cs @@ -16,14 +16,14 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Web.Common.Routing [TestFixture] public class EndpointRouteBuilderExtensionsTests { - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, "test", null, true)] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, "test", "GetStuff", true)] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, null, null, true)] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, null, "GetStuff", true)] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, "test", null, false)] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, "test", "GetStuff", false)] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, null, null, false)] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, null, "GetStuff", false)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, "test", null, true)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, "test", "GetStuff", true)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, null, null, true)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, null, "GetStuff", true)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, "test", null, false)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, "test", "GetStuff", false)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, null, null, false)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, null, "GetStuff", false)] [TestCase("umbraco", null, "test", null, true)] [TestCase("umbraco", null, "test", "GetStuff", true)] [TestCase("umbraco", null, null, null, true)] @@ -65,10 +65,10 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Web.Common.Routing Assert.AreEqual(controllerName, endpoint.RoutePattern.Defaults["controller"]); } - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, true, null)] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, true, "GetStuff")] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, false, null)] - [TestCase("umbraco", Constants.Web.Mvc.BackOfficeArea, false, "GetStuff")] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, true, null)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, true, "GetStuff")] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, false, null)] + [TestCase("umbraco", Constants.Web.Mvc.BackOfficeApiArea, false, "GetStuff")] [TestCase("umbraco", null, true, null)] [TestCase("umbraco", null, true, "GetStuff")] [TestCase("umbraco", null, false, null)] diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/InstallAreaRoutesTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/InstallAreaRoutesTests.cs index 238554e8b7..4035c4d2d0 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/InstallAreaRoutesTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Routing/InstallAreaRoutesTests.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Routing; using Moq; using NUnit.Framework; using System.Linq; @@ -41,12 +42,14 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Web.Common.Routing Assert.AreEqual(Constants.Web.Mvc.InstallArea, endpoint1.RoutePattern.Defaults["area"]); Assert.AreEqual("Index", endpoint1.RoutePattern.Defaults["action"]); Assert.AreEqual(ControllerExtensions.GetControllerName(), endpoint1.RoutePattern.Defaults["controller"]); + Assert.AreEqual(endpoint1.RoutePattern.Defaults["area"], typeof(InstallApiController).GetCustomAttribute(false).RouteValue); var endpoint2 = (RouteEndpoint)route.Endpoints[1]; Assert.AreEqual($"install/{{action}}/{{id?}}", endpoint2.RoutePattern.RawText); Assert.AreEqual(Constants.Web.Mvc.InstallArea, endpoint2.RoutePattern.Defaults["area"]); Assert.AreEqual("Index", endpoint2.RoutePattern.Defaults["action"]); Assert.AreEqual(ControllerExtensions.GetControllerName(), endpoint2.RoutePattern.Defaults["controller"]); + Assert.AreEqual(endpoint2.RoutePattern.Defaults["area"], typeof(InstallController).GetCustomAttribute(false).RouteValue); var fallbackRoute = endpoints.DataSources.Last(); Assert.AreEqual(1, fallbackRoute.Endpoints.Count); diff --git a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs index 67a2086b0d..cb0cb4cc50 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs @@ -5,7 +5,7 @@ using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.BackOffice.Controllers { - [PluginController(Constants.Web.Mvc.BackOfficeArea)] // TODO: Maybe this could be applied with our Application Model conventions + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] // TODO: Maybe this could be applied with our Application Model conventions //[ValidationFilter] // TODO: I don't actually think this is required with our custom Application Model conventions applied [TypeFilter(typeof(AngularJsonOnlyConfigurationAttribute))] // TODO: This could be applied with our Application Model conventions [IsBackOffice] // TODO: This could be applied with our Application Model conventions diff --git a/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs b/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs index 42daf6db9b..ec0a75fe11 100644 --- a/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs +++ b/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs @@ -78,7 +78,7 @@ namespace Umbraco.Web.BackOffice.Routing id = @"[a-zA-Z]*" }); - endpoints.MapUmbracoApiRoute(_umbracoPathSegment, Constants.Web.Mvc.BackOfficeArea, true, defaultAction: string.Empty); + endpoints.MapUmbracoApiRoute(_umbracoPathSegment, Constants.Web.Mvc.BackOfficeApiArea, true, defaultAction: string.Empty); } /// diff --git a/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs b/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs index 5e30c35e9b..5ac3412d61 100644 --- a/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs @@ -27,7 +27,7 @@ namespace Umbraco.Extensions return "/"; // this would indicate that the installer is installed without the back office } - return linkGenerator.GetPathByAction("Default", ControllerExtensions.GetControllerName(backOfficeControllerType), new { area = Constants.Web.Mvc.BackOfficeArea }); + return linkGenerator.GetPathByAction("Default", ControllerExtensions.GetControllerName(backOfficeControllerType), new { area = Constants.Web.Mvc.BackOfficeApiArea }); } /// diff --git a/src/Umbraco.Web.Common/Extensions/UrlHelperExtensions.cs b/src/Umbraco.Web.Common/Extensions/UrlHelperExtensions.cs index c54c370f4e..3b64125053 100644 --- a/src/Umbraco.Web.Common/Extensions/UrlHelperExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/UrlHelperExtensions.cs @@ -22,7 +22,7 @@ namespace Umbraco.Extensions { var backOfficeControllerType = Type.GetType("Umbraco.Web.BackOffice.Controllers"); if (backOfficeControllerType == null) return "/"; // this would indicate that the installer is installed without the back office - return url.Action("Default", ControllerExtensions.GetControllerName(backOfficeControllerType), new { area = Constants.Web.Mvc.BackOfficeArea }); + return url.Action("Default", ControllerExtensions.GetControllerName(backOfficeControllerType), new { area = Constants.Web.Mvc.BackOfficeApiArea }); } ///