Skip to content

Commit

Permalink
Removes AutoLegacy routing and the legacy UseDomainPrefixes from umbr…
Browse files Browse the repository at this point in the history
…aco settings
  • Loading branch information
Shazwazza committed Jan 30, 2019
1 parent 82ba360 commit 9571f48
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 96 deletions.
Expand Up @@ -4,8 +4,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IRequestHandlerSection : IUmbracoConfigurationSection
{
bool UseDomainPrefixes { get; }

bool AddTrailingSlash { get; }

bool RemoveDoubleDashes { get; }
Expand Down
Expand Up @@ -7,12 +7,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class RequestHandlerElement : UmbracoConfigurationElement, IRequestHandlerSection
{
[ConfigurationProperty("useDomainPrefixes")]
public InnerTextConfigurationElement<bool> UseDomainPrefixes
{
get { return GetOptionalTextElement("useDomainPrefixes", false); }
}

[ConfigurationProperty("addTrailingSlash")]
public InnerTextConfigurationElement<bool> AddTrailingSlash
{
Expand Down Expand Up @@ -94,11 +88,6 @@ internal static CharCollection GetDefaultCharReplacements()
return collection;
}

bool IRequestHandlerSection.UseDomainPrefixes
{
get { return UseDomainPrefixes; }
}

bool IRequestHandlerSection.AddTrailingSlash
{
get { return AddTrailingSlash; }
Expand Down
Expand Up @@ -7,12 +7,6 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[TestFixture]
public class RequestHandlerElementTests : UmbracoSettingsTests
{
[Test]
public void UseDomainPrefixes()
{
Assert.IsTrue(SettingsSection.RequestHandler.UseDomainPrefixes == false);

}
[Test]
public void AddTrailingSlash()
{
Expand Down
Expand Up @@ -15,9 +15,6 @@
<!-- https://our.umbraco.com/documentation/using-umbraco/config-files/umbracoSettings/#Imaging -->
<imaging/>

<!-- https://our.umbraco.com/documentation/using-umbraco/config-files/umbracoSettings/#Scripteditor -->
<scripteditor/>

<!-- https://our.umbraco.com/documentation/using-umbraco/config-files/umbracoSettings/#Errors -->
<errors>
<error404>1</error404>
Expand Down
31 changes: 2 additions & 29 deletions src/Umbraco.Tests/Routing/UrlProviderTests.cs
Expand Up @@ -114,8 +114,6 @@ public void Get_Url_Not_Hiding_Top_Level(int nodeId, string niceUrlMatch)
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
}, globalSettings: globalSettings.Object);

var requestMock = Mock.Get(umbracoSettings.RequestHandler);
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);

var result = umbracoContext.UrlProvider.GetUrl(nodeId);
Assert.AreEqual(niceUrlMatch, result);
Expand Down Expand Up @@ -144,9 +142,7 @@ public void Get_Url_Hiding_Top_Level(int nodeId, string niceUrlMatch)
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
}, globalSettings: globalSettings.Object);

var requestMock = Mock.Get(umbracoSettings.RequestHandler);
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);


var result = umbracoContext.UrlProvider.GetUrl(nodeId);
Assert.AreEqual(niceUrlMatch, result);
}
Expand All @@ -161,8 +157,6 @@ public void Get_Url_For_Culture_Variant_Without_Domains_Non_Current_Url()

var umbracoSettings = Current.Configs.Settings();

var requestMock = Mock.Get(umbracoSettings.RequestHandler);
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);

var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty<string>(), Enumerable.Empty<PublishedPropertyType>(), ContentVariation.Culture);
var publishedContent = new TestPublishedContent(contentType, 1234, Guid.NewGuid(), new Dictionary<string, object>(), false);
Expand Down Expand Up @@ -209,9 +203,6 @@ public void Get_Url_For_Culture_Variant_With_Current_Url()

var umbracoSettings = Current.Configs.Settings();

var requestMock = Mock.Get(umbracoSettings.RequestHandler);
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);

var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty<string>(), Enumerable.Empty<PublishedPropertyType>(), ContentVariation.Culture);
var publishedContent = new TestPublishedContent(contentType, 1234, Guid.NewGuid(), new Dictionary<string, object>(), false);

Expand Down Expand Up @@ -266,9 +257,6 @@ public void Get_Url_For_Culture_Variant_Non_Current_Url()

var umbracoSettings = Current.Configs.Settings();

var requestMock = Mock.Get(umbracoSettings.RequestHandler);
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);

var contentType = new PublishedContentType(666, "alias", PublishedItemType.Content, Enumerable.Empty<string>(), Enumerable.Empty<PublishedPropertyType>(), ContentVariation.Culture);
var publishedContent = new TestPublishedContent(contentType, 1234, Guid.NewGuid(), new Dictionary<string, object>(), false);

Expand Down Expand Up @@ -319,20 +307,13 @@ public void Get_Url_Relative_Or_Absolute()

var umbracoSettings = Current.Configs.Settings();

var requestMock = Mock.Get(umbracoSettings.RequestHandler);
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);

var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, umbracoSettings: umbracoSettings, urlProviders: new[]
{
new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, globalSettings.Object, new SiteDomainHelper())
}, globalSettings: globalSettings.Object);

Assert.AreEqual("/home/sub1/custom-sub-1/", umbracoContext.UrlProvider.GetUrl(1177));

requestMock.Setup(x => x.UseDomainPrefixes).Returns(true);
Assert.AreEqual("http://example.com/home/sub1/custom-sub-1/", umbracoContext.UrlProvider.GetUrl(1177));

requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
umbracoContext.UrlProvider.Mode = UrlProviderMode.Absolute;
Assert.AreEqual("http://example.com/home/sub1/custom-sub-1/", umbracoContext.UrlProvider.GetUrl(1177));
}
Expand All @@ -351,17 +332,9 @@ public void Get_Url_Unpublished()
}, globalSettings: globalSettings.Object);

//mock the Umbraco settings that we need
var requestMock = Mock.Get(umbracoSettings.RequestHandler);
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);


Assert.AreEqual("#", umbracoContext.UrlProvider.GetUrl(999999));

requestMock.Setup(x => x.UseDomainPrefixes).Returns(true);

Assert.AreEqual("#", umbracoContext.UrlProvider.GetUrl(999999));

requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);

umbracoContext.UrlProvider.Mode = UrlProviderMode.Absolute;

Assert.AreEqual("#", umbracoContext.UrlProvider.GetUrl(999999));
Expand Down
26 changes: 4 additions & 22 deletions src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs
Expand Up @@ -176,8 +176,6 @@ protected override string GetXmlContent(int templateId)
public void Get_Url_SimpleDomain(int nodeId, string currentUrl, bool absolute, string expected)
{
var settings = SettingsForTests.GenerateMockUmbracoSettings();
var request = Mock.Get(settings.RequestHandler);
request.Setup(x => x.UseDomainPrefixes).Returns(false);

var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains
Expand Down Expand Up @@ -210,9 +208,7 @@ public void Get_Url_SimpleDomain(int nodeId, string currentUrl, bool absolute, s
public void Get_Url_SimpleWithSchemeAndPath(int nodeId, string currentUrl, bool absolute, string expected)
{
var settings = SettingsForTests.GenerateMockUmbracoSettings();
var request = Mock.Get(settings.RequestHandler);
request.Setup(x => x.UseDomainPrefixes).Returns(false);


var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains

Expand All @@ -236,8 +232,6 @@ public void Get_Url_SimpleWithSchemeAndPath(int nodeId, string currentUrl, bool
public void Get_Url_DeepDomain(int nodeId, string currentUrl, bool absolute, string expected)
{
var settings = SettingsForTests.GenerateMockUmbracoSettings();
var request = Mock.Get(settings.RequestHandler);
request.Setup(x => x.UseDomainPrefixes).Returns(false);

var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains
Expand Down Expand Up @@ -268,9 +262,7 @@ public void Get_Url_DeepDomain(int nodeId, string currentUrl, bool absolute, str
public void Get_Url_NestedDomains(int nodeId, string currentUrl, bool absolute, string expected)
{
var settings = SettingsForTests.GenerateMockUmbracoSettings();
var request = Mock.Get(settings.RequestHandler);
request.Setup(x => x.UseDomainPrefixes).Returns(false);


var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains

Expand All @@ -290,9 +282,7 @@ public void Get_Url_NestedDomains(int nodeId, string currentUrl, bool absolute,
public void Get_Url_DomainsAndCache()
{
var settings = SettingsForTests.GenerateMockUmbracoSettings();
var request = Mock.Get(settings.RequestHandler);
request.Setup(x => x.UseDomainPrefixes).Returns(false);


var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains

Expand Down Expand Up @@ -355,9 +345,7 @@ private static void CheckRoute(IDictionary<int, string> routes, IDictionary<stri
public void Get_Url_Relative_Or_Absolute()
{
var settings = SettingsForTests.GenerateMockUmbracoSettings();
var requestMock = Mock.Get(settings.RequestHandler);
requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);


var globalSettings = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false); // ignored w/domains

Expand All @@ -371,12 +359,6 @@ public void Get_Url_Relative_Or_Absolute()
Assert.AreEqual("/en/1001-1-1/", umbracoContext.UrlProvider.GetUrl(100111));
Assert.AreEqual("http://domain3.com/en/1003-1-1/", umbracoContext.UrlProvider.GetUrl(100311));

requestMock.Setup(x => x.UseDomainPrefixes).Returns(true);

Assert.AreEqual("http://domain1.com/en/1001-1-1/", umbracoContext.UrlProvider.GetUrl(100111));
Assert.AreEqual("http://domain3.com/en/1003-1-1/", umbracoContext.UrlProvider.GetUrl(100311));

requestMock.Setup(x => x.UseDomainPrefixes).Returns(false);
umbracoContext.UrlProvider.Mode = UrlProviderMode.Absolute;

Assert.AreEqual("http://domain1.com/en/1001-1-1/", umbracoContext.UrlProvider.GetUrl(100111));
Expand Down
2 changes: 0 additions & 2 deletions src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs
Expand Up @@ -34,8 +34,6 @@ public void DoNotPolluteCache()
globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);

var settings = SettingsForTests.GenerateMockUmbracoSettings();
var request = Mock.Get(settings.RequestHandler);
request.Setup(x => x.UseDomainPrefixes).Returns(true);

SetDomains1();

Expand Down
1 change: 0 additions & 1 deletion src/Umbraco.Tests/TestHelpers/SettingsForTests.cs
Expand Up @@ -54,7 +54,6 @@ public static IUmbracoSettingsSection GenerateMockUmbracoSettings()
settings.Setup(x => x.Content.ImageAutoFillProperties).Returns(ContentImagingElement.GetDefaultImageAutoFillProperties());
settings.Setup(x => x.Content.ImageFileTypes).Returns(ContentImagingElement.GetDefaultImageFileTypes());
settings.Setup(x => x.RequestHandler.AddTrailingSlash).Returns(true);
settings.Setup(x => x.RequestHandler.UseDomainPrefixes).Returns(false);
settings.Setup(x => x.RequestHandler.CharCollection).Returns(RequestHandlerElement.GetDefaultCharReplacements());
settings.Setup(x => x.WebRouting.UrlProviderMode).Returns("AutoLegacy");
settings.Setup(x => x.Providers.DefaultBackOfficeUserProvider).Returns("UsersMembershipProvider");
Expand Down
3 changes: 0 additions & 3 deletions src/Umbraco.Web.UI/config/umbracoSettings.Release.config
Expand Up @@ -59,9 +59,6 @@
<!-- Defines the default document type property used when adding properties in the back-office (if missing or empty, defaults to Textstring -->
<defaultDocumentTypeProperty>Textstring</defaultDocumentTypeProperty>

<!-- Enables value converters for all built in property editors so that they return strongly typed object, recommended for use with Models Builder -->
<EnablePropertyValueConverters>true</EnablePropertyValueConverters>

<!-- You can specify your own background image for the login screen here. The image will automatically get an overlay to match back office colors - this path is relative to the ~/umbraco path. The default location is: /umbraco/assets/img/installer.jpg -->
<loginBackgroundImage>assets/img/installer.jpg</loginBackgroundImage>

Expand Down
5 changes: 0 additions & 5 deletions src/Umbraco.Web.UI/config/umbracoSettings.config
Expand Up @@ -68,11 +68,6 @@

<showDeprecatedPropertyEditors>false</showDeprecatedPropertyEditors>

<!-- Enables value converters for all built in property editors so that they return strongly typed object, recommended for use with Models Builder -->
<!--
<EnablePropertyValueConverters>true</EnablePropertyValueConverters>
-->

<!-- You can specify your own background image for the login screen here. The image will automatically get an overlay to match back office colors - this path is relative to the ~/umbraco path. The default location is: /umbraco/assets/img/installer.jpg -->
<loginBackgroundImage>assets/img/installer.jpg</loginBackgroundImage>

Expand Down
7 changes: 0 additions & 7 deletions src/Umbraco.Web/Routing/DefaultUrlProvider.cs
Expand Up @@ -127,13 +127,6 @@ Uri AssembleUrl(DomainAndUri domainUri, string path, Uri current, UrlProviderMod

// ignore vdir at that point, UriFromUmbraco will do it

if (mode == UrlProviderMode.AutoLegacy)
{
mode = _requestSettings.UseDomainPrefixes
? UrlProviderMode.Absolute
: UrlProviderMode.Auto;
}

if (domainUri == null) // no domain was found
{
if (current == null)
Expand Down
5 changes: 0 additions & 5 deletions src/Umbraco.Web/Routing/UrlProviderMode.cs
Expand Up @@ -12,11 +12,6 @@
/// </remarks>
public enum UrlProviderMode
{
/// <summary>
/// Indicates that the url provider should determine automatically whether to return relative or absolute urls,
/// and also respect the legacy <c>useDomainPrefixes</c> setting.
/// </summary>
AutoLegacy,

/// <summary>
/// Indicates that the url provider should produce relative urls exclusively.
Expand Down

0 comments on commit 9571f48

Please sign in to comment.