Merge pull request #7800 from umbraco/netcore/feature/cleanup-config

NetCore: Granulate the Config/Settings
This commit is contained in:
Shannon Deminick
2020-03-13 11:09:15 +11:00
committed by GitHub
164 changed files with 1368 additions and 1258 deletions
+23 -9
View File
@@ -1,8 +1,10 @@
using System.Configuration;
using Umbraco.Configuration;
using Umbraco.Configuration.Implementations;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Configuration
{
@@ -18,25 +20,27 @@ namespace Umbraco.Core.Configuration
public IRuntimeSettings RuntimeSettings { get; } = new RuntimeSettings();
public IActiveDirectorySettings ActiveDirectorySettings { get; } = new ActiveDirectorySettings();
public IExceptionFilterSettings ExceptionFilterSettings { get; } = new ExceptionFilterSettings();
public ITourSettings TourSettings { get; } = new TourSettings();
public ILoggingSettings LoggingSettings { get; } = new LoggingSettings();
public IKeepAliveSettings KeepAliveSettings { get; } = new KeepAliveSettings();
public IWebRoutingSettings WebRoutingSettings { get; } = new WebRoutingSettings();
public IRequestHandlerSettings RequestHandlerSettings { get; } = new RequestHandlerSettings();
public ISecuritySettings SecuritySettings { get; } = new SecuritySettings();
public IUserPasswordConfiguration UserPasswordConfigurationSettings { get; } = new UserPasswordConfigurationSettings();
public IMemberPasswordConfiguration MemberPasswordConfigurationSettings { get; } = new MemberPasswordConfigurationSettings();
public IContentSettings ContentSettings { get; } = new ContentSettings();
public IUmbracoSettingsSection UmbracoSettings { get; }
public Configs Create(IIOHelper ioHelper)
public Configs Create(IIOHelper ioHelper, ILogger logger)
{
var configs = new Configs(section => ConfigurationManager.GetSection(section));
configs.Add<IGlobalSettings>(() => new GlobalSettings(ioHelper));
configs.Add(() => HostingSettings);
configs.Add<IUmbracoSettingsSection>("umbracoConfiguration/settings");
configs.Add<IHealthChecks>("umbracoConfiguration/HealthChecks");
// Password configuration is held within IUmbracoSettingsSection from umbracoConfiguration/settings but we'll add explicitly
// so it can be independently retrieved in classes that need it.
configs.AddPasswordConfigurations();
configs.Add(() => CoreDebug);
configs.Add(() => MachineKeyConfig);
configs.Add<IConnectionStrings>(() => new ConnectionStrings(ioHelper));
configs.Add<IConnectionStrings>(() => new ConnectionStrings(ioHelper, logger));
configs.Add<IModelsBuilderConfig>(() => new ModelsBuilderConfig(ioHelper));
@@ -47,6 +51,16 @@ namespace Umbraco.Core.Configuration
configs.Add<IActiveDirectorySettings>(() => ActiveDirectorySettings);
configs.Add<IExceptionFilterSettings>(() => ExceptionFilterSettings);
configs.Add<ITourSettings>(() => TourSettings);
configs.Add<ILoggingSettings>(() => LoggingSettings);
configs.Add<IKeepAliveSettings>(() => KeepAliveSettings);
configs.Add<IWebRoutingSettings>(() => WebRoutingSettings);
configs.Add<IRequestHandlerSettings>(() => RequestHandlerSettings);
configs.Add<ISecuritySettings>(() => SecuritySettings);
configs.Add<IUserPasswordConfiguration>(() => UserPasswordConfigurationSettings);
configs.Add<IMemberPasswordConfiguration>(() => MemberPasswordConfigurationSettings);
configs.Add<IContentSettings>(() => ContentSettings);
configs.AddCoreConfigs(ioHelper);
return configs;
}
+77 -1
View File
@@ -1,18 +1,22 @@
using System;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Configuration
{
public class ConnectionStrings : IConnectionStrings
{
private readonly IIOHelper _ioHelper;
private readonly ILogger _logger;
public ConnectionStrings(IIOHelper ioHelper)
public ConnectionStrings(IIOHelper ioHelper, ILogger logger)
{
_ioHelper = ioHelper;
_logger = logger;
}
public ConfigConnectionString this[string key]
@@ -41,5 +45,77 @@ namespace Umbraco.Core.Configuration
}
var settings = ConfigurationManager.ConnectionStrings[key];
}
/// <summary>
/// Saves the connection string as a proper .net connection string in web.config.
/// </summary>
/// <remarks>Saves the ConnectionString in the very nasty 'medium trust'-supportive way.</remarks>
/// <param name="connectionString">The connection string.</param>
/// <param name="providerName">The provider name.</param>
public void SaveConnectionString(string connectionString, string providerName)
{
if (connectionString == null) throw new ArgumentNullException(nameof(connectionString));
if (string.IsNullOrWhiteSpace(connectionString)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(connectionString));
if (providerName == null) throw new ArgumentNullException(nameof(providerName));
if (string.IsNullOrWhiteSpace(providerName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(providerName));
var fileSource = "web.config";
var fileName = _ioHelper.MapPath(_ioHelper.Root +"/" + fileSource);
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
if (xml.Root == null) throw new Exception($"Invalid {fileSource} file (no root).");
var connectionStrings = xml.Root.DescendantsAndSelf("connectionStrings").FirstOrDefault();
if (connectionStrings == null) throw new Exception($"Invalid {fileSource} file (no connection strings).");
// handle configSource
var configSourceAttribute = connectionStrings.Attribute("configSource");
if (configSourceAttribute != null)
{
fileSource = configSourceAttribute.Value;
fileName = _ioHelper.MapPath(_ioHelper.Root + "/" + fileSource);
if (!File.Exists(fileName))
throw new Exception($"Invalid configSource \"{fileSource}\" (no such file).");
xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
if (xml.Root == null) throw new Exception($"Invalid {fileSource} file (no root).");
connectionStrings = xml.Root.DescendantsAndSelf("connectionStrings").FirstOrDefault();
if (connectionStrings == null) throw new Exception($"Invalid {fileSource} file (no connection strings).");
}
// create or update connection string
var setting = connectionStrings.Descendants("add").FirstOrDefault(s => s.Attribute("name")?.Value == Constants.System.UmbracoConnectionName);
if (setting == null)
{
connectionStrings.Add(new XElement("add",
new XAttribute("name", Constants.System.UmbracoConnectionName),
new XAttribute("connectionString", connectionString),
new XAttribute("providerName", providerName)));
}
else
{
AddOrUpdateAttribute(setting, "connectionString", connectionString);
AddOrUpdateAttribute(setting, "providerName", providerName);
}
// save
_logger.Info<ConnectionStrings>("Saving connection string to {ConfigFile}.", fileSource);
xml.Save(fileName, SaveOptions.DisableFormatting);
_logger.Info<ConnectionStrings>("Saved connection string to {ConfigFile}.", fileSource);
}
private static void AddOrUpdateAttribute(XElement element, string name, string value)
{
var attribute = element.Attribute(name);
if (attribute == null)
element.Add(new XAttribute(name, value));
else
attribute.Value = value;
}
}
}
@@ -0,0 +1,22 @@
using System.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Configuration.Implementations
{
internal abstract class ConfigurationManagerConfigBase
{
private UmbracoSettingsSection _umbracoSettingsSection;
public UmbracoSettingsSection UmbracoSettingsSection
{
get
{
if (_umbracoSettingsSection is null)
{
_umbracoSettingsSection = ConfigurationManager.GetSection("umbracoConfiguration/settings") as UmbracoSettingsSection;
}
return _umbracoSettingsSection;
}
}
}
}
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Macros;
namespace Umbraco.Configuration.Implementations
{
internal class ContentSettings : ConfigurationManagerConfigBase, IContentSettings
{
public string NotificationEmailAddress => UmbracoSettingsSection.Content.Notifications.NotificationEmailAddress;
public bool DisableHtmlEmail => UmbracoSettingsSection.Content.Notifications.DisableHtmlEmail;
public IEnumerable<string> ImageFileTypes => UmbracoSettingsSection.Content.Imaging.ImageFileTypes;
public IEnumerable<IImagingAutoFillUploadField> ImageAutoFillProperties => UmbracoSettingsSection.Content.Imaging.ImageAutoFillProperties;
public bool ResolveUrlsFromTextString => UmbracoSettingsSection.Content.ResolveUrlsFromTextString;
public IEnumerable<IContentErrorPage> Error404Collection => UmbracoSettingsSection.Content.Error404Collection;
public string PreviewBadge => UmbracoSettingsSection.Content.PreviewBadge;
public MacroErrorBehaviour MacroErrorBehaviour => UmbracoSettingsSection.Content.MacroErrors;
public IEnumerable<string> DisallowedUploadFiles => UmbracoSettingsSection.Content.DisallowedUploadFiles;
public IEnumerable<string> AllowedUploadFiles => UmbracoSettingsSection.Content.AllowedUploadFiles;
public bool ShowDeprecatedPropertyEditors => UmbracoSettingsSection.Content.ShowDeprecatedPropertyEditors;
public string LoginBackgroundImage => UmbracoSettingsSection.Content.LoginBackgroundImage;
}
}
@@ -0,0 +1,10 @@
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Configuration.Implementations
{
internal class KeepAliveSettings : ConfigurationManagerConfigBase, IKeepAliveSettings
{
public bool DisableKeepAliveTask => UmbracoSettingsSection.KeepAlive.DisableKeepAliveTask;
public string KeepAlivePingUrl => UmbracoSettingsSection.KeepAlive.KeepAlivePingUrl;
}
}
@@ -0,0 +1,9 @@
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Configuration.Implementations
{
internal class LoggingSettings : ConfigurationManagerConfigBase, ILoggingSettings
{
public int MaxLogAge => UmbracoSettingsSection.Logging.MaxLogAge;
}
}
@@ -0,0 +1,16 @@
using Umbraco.Core.Configuration;
namespace Umbraco.Configuration.Implementations
{
internal class MemberPasswordConfigurationSettings : ConfigurationManagerConfigBase, IMemberPasswordConfiguration
{
public int RequiredLength => UmbracoSettingsSection.Security.UserPasswordConfiguration.RequiredLength;
public bool RequireNonLetterOrDigit => UmbracoSettingsSection.Security.UserPasswordConfiguration.RequireNonLetterOrDigit;
public bool RequireDigit => UmbracoSettingsSection.Security.UserPasswordConfiguration.RequireDigit;
public bool RequireLowercase=> UmbracoSettingsSection.Security.UserPasswordConfiguration.RequireLowercase;
public bool RequireUppercase=> UmbracoSettingsSection.Security.UserPasswordConfiguration.RequireUppercase;
public bool UseLegacyEncoding=> UmbracoSettingsSection.Security.UserPasswordConfiguration.UseLegacyEncoding;
public string HashAlgorithmType=> UmbracoSettingsSection.Security.UserPasswordConfiguration.HashAlgorithmType;
public int MaxFailedAccessAttemptsBeforeLockout => UmbracoSettingsSection.Security.UserPasswordConfiguration.MaxFailedAccessAttemptsBeforeLockout;
}
}
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Configuration.Implementations
{
internal class RequestHandlerSettings : ConfigurationManagerConfigBase, IRequestHandlerSettings
{
public bool AddTrailingSlash => UmbracoSettingsSection.RequestHandler.AddTrailingSlash;
public bool ConvertUrlsToAscii => UmbracoSettingsSection.RequestHandler.UrlReplacing.ConvertUrlsToAscii.InvariantEquals("true");
public bool TryConvertUrlsToAscii => UmbracoSettingsSection.RequestHandler.UrlReplacing.ConvertUrlsToAscii.InvariantEquals("try");
public IEnumerable<IChar> CharCollection => UmbracoSettingsSection.RequestHandler.UrlReplacing.CharCollection;
}
}
@@ -0,0 +1,14 @@
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Configuration.Implementations
{
internal class SecuritySettings : ConfigurationManagerConfigBase, ISecuritySettings
{
public bool KeepUserLoggedIn => UmbracoSettingsSection.Security.KeepUserLoggedIn;
public bool HideDisabledUsersInBackoffice => UmbracoSettingsSection.Security.HideDisabledUsersInBackoffice;
public bool AllowPasswordReset => UmbracoSettingsSection.Security.AllowPasswordReset;
public string AuthCookieName => UmbracoSettingsSection.Security.AuthCookieName;
public string AuthCookieDomain => UmbracoSettingsSection.Security.AuthCookieDomain;
public bool UsernameIsEmail => UmbracoSettingsSection.Security.UsernameIsEmail;
}
}
@@ -0,0 +1,9 @@
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Configuration.Implementations
{
internal class TourSettings : ConfigurationManagerConfigBase, ITourSettings
{
public bool EnableTours => UmbracoSettingsSection.BackOffice.Tours.EnableTours;
}
}
@@ -0,0 +1,15 @@
using Umbraco.Core.Configuration;
namespace Umbraco.Configuration.Implementations
{
internal class UserPasswordConfigurationSettings : ConfigurationManagerConfigBase, IUserPasswordConfiguration
{
public int RequiredLength => UmbracoSettingsSection.Security.UserPasswordConfiguration.RequiredLength;
public bool RequireNonLetterOrDigit => UmbracoSettingsSection.Security.UserPasswordConfiguration.RequireNonLetterOrDigit;
public bool RequireDigit => UmbracoSettingsSection.Security.UserPasswordConfiguration.RequireDigit;
public bool RequireLowercase=> UmbracoSettingsSection.Security.UserPasswordConfiguration.RequireLowercase;
public bool RequireUppercase=> UmbracoSettingsSection.Security.UserPasswordConfiguration.RequireUppercase;
public bool UseLegacyEncoding=> UmbracoSettingsSection.Security.UserPasswordConfiguration.UseLegacyEncoding;
public string HashAlgorithmType=> UmbracoSettingsSection.Security.UserPasswordConfiguration.HashAlgorithmType;
public int MaxFailedAccessAttemptsBeforeLockout => UmbracoSettingsSection.Security.UserPasswordConfiguration.MaxFailedAccessAttemptsBeforeLockout;
}
}
@@ -0,0 +1,16 @@
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Configuration.Implementations
{
internal class WebRoutingSettings : ConfigurationManagerConfigBase, IWebRoutingSettings
{
public bool TrySkipIisCustomErrors => UmbracoSettingsSection.WebRouting.TrySkipIisCustomErrors;
public bool InternalRedirectPreservesTemplate => UmbracoSettingsSection.WebRouting.InternalRedirectPreservesTemplate;
public bool DisableAlternativeTemplates => UmbracoSettingsSection.WebRouting.DisableAlternativeTemplates;
public bool ValidateAlternativeTemplates => UmbracoSettingsSection.WebRouting.ValidateAlternativeTemplates;
public bool DisableFindContentByIdPath => UmbracoSettingsSection.WebRouting.DisableFindContentByIdPath;
public bool DisableRedirectUrlTracking => UmbracoSettingsSection.WebRouting.DisableRedirectUrlTracking;
public string UrlProviderMode => UmbracoSettingsSection.WebRouting.UrlProviderMode;
public string UmbracoApplicationUrl => UmbracoSettingsSection.WebRouting.UmbracoApplicationUrl;
}
}
@@ -7,6 +7,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("tours")]
internal TourConfigElement Tours => (TourConfigElement)this["tours"];
ITourSection IBackOfficeSection.Tours => Tours;
ITourSettings IBackOfficeSection.Tours => Tours;
}
}
@@ -4,7 +4,7 @@ using Umbraco.Core.Macros;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class ContentElement : UmbracoConfigurationElement, IContentSection
internal class ContentElement : UmbracoConfigurationElement, IContentSettings
{
private const string DefaultPreviewBadge = @"<div id=""umbracoPreviewBadge"" class=""umbraco-preview-badge""><span class=""umbraco-preview-badge__header"">Preview mode</span><a href=""{0}/preview/end?redir={1}"" class=""umbraco-preview-badge__end""><svg viewBox=""0 0 100 100"" xmlns=""http://www.w3.org/2000/svg""><title>Click to end</title><path d=""M5273.1 2400.1v-2c0-2.8-5-4-9.7-4s-9.7 1.3-9.7 4v2a7 7 0 002 4.9l5 4.9c.3.3.4.6.4 1v6.4c0 .4.2.7.6.8l2.9.9c.5.1 1-.2 1-.8v-7.2c0-.4.2-.7.4-1l5.1-5a7 7 0 002-4.9zm-9.7-.1c-4.8 0-7.4-1.3-7.5-1.8.1-.5 2.7-1.8 7.5-1.8s7.3 1.3 7.5 1.8c-.2.5-2.7 1.8-7.5 1.8z""/><path d=""M5268.4 2410.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1h-4.3zM5272.7 2413.7h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1zM5272.7 2417h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1 0-.5-.4-1-1-1z""/><path d=""M78.2 13l-8.7 11.7a32.5 32.5 0 11-51.9 25.8c0-10.3 4.7-19.7 12.9-25.8L21.8 13a47 47 0 1056.4 0z""/><path d=""M42.7 2.5h14.6v49.4H42.7z""/></svg></a></div><style type=""text/css"">.umbraco-preview-badge {{position: absolute;top: 1em;right: 1em;display: inline-flex;background: #1b264f;color: #fff;padding: 1em;font-size: 12px;z-index: 99999999;justify-content: center;align-items: center;box-shadow: 0 10px 50px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .16);line-height: 1;}}.umbraco-preview-badge__header {{font-weight: bold;}}.umbraco-preview-badge__end {{width: 3em;padding: 1em;margin: -1em -1em -1em 2em;display: flex;flex-shrink: 0;align-items: center;align-self: stretch;}}.umbraco-preview-badge__end:hover,.umbraco-preview-badge__end:focus {{background: #f5c1bc;}}.umbraco-preview-badge__end svg {{fill: #fff;width:1em;}}</style>";
@@ -40,26 +40,26 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("loginBackgroundImage")]
internal InnerTextConfigurationElement<string> LoginBackgroundImage => GetOptionalTextElement("loginBackgroundImage", string.Empty);
string IContentSection.NotificationEmailAddress => Notifications.NotificationEmailAddress;
string IContentSettings.NotificationEmailAddress => Notifications.NotificationEmailAddress;
bool IContentSection.DisableHtmlEmail => Notifications.DisableHtmlEmail;
bool IContentSettings.DisableHtmlEmail => Notifications.DisableHtmlEmail;
IEnumerable<string> IContentSection.ImageFileTypes => Imaging.ImageFileTypes;
IEnumerable<string> IContentSettings.ImageFileTypes => Imaging.ImageFileTypes;
IEnumerable<IImagingAutoFillUploadField> IContentSection.ImageAutoFillProperties => Imaging.ImageAutoFillProperties;
IEnumerable<IImagingAutoFillUploadField> IContentSettings.ImageAutoFillProperties => Imaging.ImageAutoFillProperties;
bool IContentSection.ResolveUrlsFromTextString => ResolveUrlsFromTextString;
bool IContentSettings.ResolveUrlsFromTextString => ResolveUrlsFromTextString;
string IContentSection.PreviewBadge => PreviewBadge;
string IContentSettings.PreviewBadge => PreviewBadge;
MacroErrorBehaviour IContentSection.MacroErrorBehaviour => MacroErrors;
MacroErrorBehaviour IContentSettings.MacroErrorBehaviour => MacroErrors;
IEnumerable<string> IContentSection.DisallowedUploadFiles => DisallowedUploadFiles;
IEnumerable<string> IContentSettings.DisallowedUploadFiles => DisallowedUploadFiles;
IEnumerable<string> IContentSection.AllowedUploadFiles => AllowedUploadFiles;
IEnumerable<string> IContentSettings.AllowedUploadFiles => AllowedUploadFiles;
bool IContentSection.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors;
bool IContentSettings.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors;
string IContentSection.LoginBackgroundImage => LoginBackgroundImage;
string IContentSettings.LoginBackgroundImage => LoginBackgroundImage;
}
}
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class KeepAliveElement : ConfigurationElement, IKeepAliveSection
internal class KeepAliveElement : ConfigurationElement, IKeepAliveSettings
{
[ConfigurationProperty("disableKeepAliveTask", DefaultValue = "false")]
public bool DisableKeepAliveTask => (bool)base["disableKeepAliveTask"];
@@ -3,12 +3,12 @@ using System.Configuration;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class LoggingElement : UmbracoConfigurationElement, ILoggingSection
internal class LoggingElement : UmbracoConfigurationElement, ILoggingSettings
{
[ConfigurationProperty("maxLogAge")]
internal InnerTextConfigurationElement<int> MaxLogAge => GetOptionalTextElement("maxLogAge", -1);
int ILoggingSection.MaxLogAge => MaxLogAge;
int ILoggingSettings.MaxLogAge => MaxLogAge;
}
}
@@ -1,6 +1,6 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class MemberPasswordConfigurationElement : PasswordConfigurationElement, IMemberPasswordConfigurationSection
internal class MemberPasswordConfigurationElement : PasswordConfigurationElement, IMemberPasswordConfiguration
{
}
}
@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class RequestHandlerElement : UmbracoConfigurationElement, IRequestHandlerSection
internal class RequestHandlerElement : UmbracoConfigurationElement, IRequestHandlerSettings
{
[ConfigurationProperty("addTrailingSlash")]
public InnerTextConfigurationElement<bool> AddTrailingSlash => GetOptionalTextElement("addTrailingSlash", true);
@@ -85,12 +85,12 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
return collection;
}
bool IRequestHandlerSection.AddTrailingSlash => AddTrailingSlash;
bool IRequestHandlerSettings.AddTrailingSlash => AddTrailingSlash;
bool IRequestHandlerSection.ConvertUrlsToAscii => UrlReplacing.ConvertUrlsToAscii.InvariantEquals("true");
bool IRequestHandlerSettings.ConvertUrlsToAscii => UrlReplacing.ConvertUrlsToAscii.InvariantEquals("true");
bool IRequestHandlerSection.TryConvertUrlsToAscii => UrlReplacing.ConvertUrlsToAscii.InvariantEquals("try");
bool IRequestHandlerSettings.TryConvertUrlsToAscii => UrlReplacing.ConvertUrlsToAscii.InvariantEquals("try");
IEnumerable<IChar> IRequestHandlerSection.CharCollection => UrlReplacing.CharCollection;
IEnumerable<IChar> IRequestHandlerSettings.CharCollection => UrlReplacing.CharCollection;
}
}
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class SecurityElement : UmbracoConfigurationElement, ISecuritySection
internal class SecurityElement : UmbracoConfigurationElement, ISecuritySettings
{
[ConfigurationProperty("keepUserLoggedIn")]
internal InnerTextConfigurationElement<bool> KeepUserLoggedIn => GetOptionalTextElement("keepUserLoggedIn", true);
@@ -38,14 +38,14 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("memberPasswordConfiguration")]
public MemberPasswordConfigurationElement MemberPasswordConfiguration => (MemberPasswordConfigurationElement)this["memberPasswordConfiguration"];
bool ISecuritySection.KeepUserLoggedIn => KeepUserLoggedIn;
bool ISecuritySettings.KeepUserLoggedIn => KeepUserLoggedIn;
bool ISecuritySection.HideDisabledUsersInBackoffice => HideDisabledUsersInBackoffice;
bool ISecuritySettings.HideDisabledUsersInBackoffice => HideDisabledUsersInBackoffice;
/// <summary>
/// Used to enable/disable the forgot password functionality on the back office login screen
/// </summary>
bool ISecuritySection.AllowPasswordReset => AllowPasswordReset;
bool ISecuritySettings.AllowPasswordReset => AllowPasswordReset;
/// <summary>
/// A boolean indicating that by default the email address will be the username
@@ -54,14 +54,10 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
/// Even if this is true and the username is different from the email in the database, the username field will still be shown.
/// When this is false, the username and email fields will be shown in the user section.
/// </remarks>
bool ISecuritySection.UsernameIsEmail => UsernameIsEmail;
bool ISecuritySettings.UsernameIsEmail => UsernameIsEmail;
string ISecuritySection.AuthCookieName => AuthCookieName;
string ISecuritySettings.AuthCookieName => AuthCookieName;
string ISecuritySection.AuthCookieDomain => AuthCookieDomain;
IUserPasswordConfigurationSection ISecuritySection.UserPasswordConfiguration => UserPasswordConfiguration;
IMemberPasswordConfigurationSection ISecuritySection.MemberPasswordConfiguration => MemberPasswordConfiguration;
string ISecuritySettings.AuthCookieDomain => AuthCookieDomain;
}
}
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class TourConfigElement : UmbracoConfigurationElement, ITourSection
internal class TourConfigElement : UmbracoConfigurationElement, ITourSettings
{
//disabled by default so that upgraders don't get it enabled by default
// TODO: we probably just want to disable the initial one from automatically loading ?
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class UmbracoSettingsSection : ConfigurationSection, IUmbracoSettingsSection
internal class UmbracoSettingsSection : ConfigurationSection
{
[ConfigurationProperty("backOffice")]
public BackOfficeElement BackOffice => (BackOfficeElement)this["backOffice"];
@@ -24,19 +24,5 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("keepAlive")]
internal KeepAliveElement KeepAlive => (KeepAliveElement)this["keepAlive"];
IContentSection IUmbracoSettingsSection.Content => Content;
ISecuritySection IUmbracoSettingsSection.Security => Security;
IRequestHandlerSection IUmbracoSettingsSection.RequestHandler => RequestHandler;
IBackOfficeSection IUmbracoSettingsSection.BackOffice => BackOffice;
ILoggingSection IUmbracoSettingsSection.Logging => Logging;
IWebRoutingSection IUmbracoSettingsSection.WebRouting => WebRouting;
IKeepAliveSection IUmbracoSettingsSection.KeepAlive => KeepAlive;
}
}
@@ -1,6 +1,6 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class UserPasswordConfigurationElement : PasswordConfigurationElement, IUserPasswordConfigurationSection
internal class UserPasswordConfigurationElement : PasswordConfigurationElement, IUserPasswordConfiguration
{
}
}
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class WebRoutingElement : ConfigurationElement, IWebRoutingSection
internal class WebRoutingElement : ConfigurationElement, IWebRoutingSettings
{
[ConfigurationProperty("trySkipIisCustomErrors", DefaultValue = "false")]
public bool TrySkipIisCustomErrors => (bool) base["trySkipIisCustomErrors"];
@@ -25,8 +25,23 @@ namespace Umbraco.Core
public static IConnectionStrings ConnectionStrings(this Configs configs)
=> configs.GetConfig<IConnectionStrings>();
public static IUmbracoSettingsSection Settings(this Configs configs)
=> configs.GetConfig<IUmbracoSettingsSection>();
public static IContentSettings Content(this Configs configs)
=> configs.GetConfig<IContentSettings>();
public static ISecuritySettings Security(this Configs configs)
=> configs.GetConfig<ISecuritySettings>();
public static IUserPasswordConfiguration UserPasswordConfiguration(this Configs configs)
=> configs.GetConfig<IUserPasswordConfiguration>();
public static IMemberPasswordConfiguration MemberPasswordConfiguration(this Configs configs)
=> configs.GetConfig<IMemberPasswordConfiguration>();
public static IRequestHandlerSettings RequestHandler(this Configs configs)
=> configs.GetConfig<IRequestHandlerSettings>();
public static IWebRoutingSettings WebRouting(this Configs configs)
=> configs.GetConfig<IWebRoutingSettings>();
public static IHealthChecks HealthChecks(this Configs configs)
=> configs.GetConfig<IHealthChecks>();
@@ -37,24 +52,6 @@ namespace Umbraco.Core
public static ICoreDebug CoreDebug(this Configs configs)
=> configs.GetConfig<ICoreDebug>();
public static IUserPasswordConfiguration UserPasswordConfiguration(this Configs configs)
=> configs.GetConfig<IUserPasswordConfiguration>();
public static IMemberPasswordConfiguration MemberPasswordConfiguration(this Configs configs)
=> configs.GetConfig<IMemberPasswordConfiguration>();
public static void AddPasswordConfigurations(this Configs configs)
{
configs.Add<IUserPasswordConfiguration>(() =>
{
return new UserPasswordConfiguration(configs.Settings().Security.UserPasswordConfiguration);
});
configs.Add<IMemberPasswordConfiguration>(() =>
{
return new MemberPasswordConfiguration(configs.Settings().Security.MemberPasswordConfiguration);
});
}
public static void AddCoreConfigs(this Configs configs, IIOHelper ioHelper)
{
var configDir = new DirectoryInfo(ioHelper.MapPath(Constants.SystemDirectories.Config));
@@ -1,9 +1,10 @@
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Configuration
{
public interface IConfigsFactory
{
Configs Create(IIOHelper ioHelper);
Configs Create(IIOHelper ioHelper, ILogger logger);
}
}
@@ -8,5 +8,6 @@ namespace Umbraco.Core.Configuration
}
void RemoveConnectionString(string umbracoConnectionName);
void SaveConnectionString(string connectionString, string providerName);
}
}
@@ -7,9 +7,9 @@ namespace Umbraco.Core.Configuration
/// </summary>
public class MemberPasswordConfiguration : PasswordConfiguration, IMemberPasswordConfiguration
{
public MemberPasswordConfiguration(IMemberPasswordConfigurationSection configSection)
: base(configSection)
{
public MemberPasswordConfiguration(IMemberPasswordConfiguration configSettings)
: base(configSettings)
{
}
}
}
@@ -5,21 +5,21 @@ namespace Umbraco.Core.Configuration
{
public abstract class PasswordConfiguration : IPasswordConfiguration
{
protected PasswordConfiguration(IPasswordConfigurationSection configSection)
protected PasswordConfiguration(IPasswordConfiguration configSettings)
{
if (configSection == null)
if (configSettings == null)
{
throw new ArgumentNullException(nameof(configSection));
throw new ArgumentNullException(nameof(configSettings));
}
RequiredLength = configSection.RequiredLength;
RequireNonLetterOrDigit = configSection.RequireNonLetterOrDigit;
RequireDigit = configSection.RequireDigit;
RequireLowercase = configSection.RequireLowercase;
RequireUppercase = configSection.RequireUppercase;
UseLegacyEncoding = configSection.UseLegacyEncoding;
HashAlgorithmType = configSection.HashAlgorithmType;
MaxFailedAccessAttemptsBeforeLockout = configSection.MaxFailedAccessAttemptsBeforeLockout;
RequiredLength = configSettings.RequiredLength;
RequireNonLetterOrDigit = configSettings.RequireNonLetterOrDigit;
RequireDigit = configSettings.RequireDigit;
RequireLowercase = configSettings.RequireLowercase;
RequireUppercase = configSettings.RequireUppercase;
UseLegacyEncoding = configSettings.UseLegacyEncoding;
HashAlgorithmType = configSettings.HashAlgorithmType;
MaxFailedAccessAttemptsBeforeLockout = configSettings.MaxFailedAccessAttemptsBeforeLockout;
}
public int RequiredLength { get; }
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
/// <param name="extension">The file extension.</param>
/// <param name="contentConfig"></param>
/// <returns>A value indicating whether the file extension corresponds to an image.</returns>
public static bool IsImageFile(this IContentSection contentConfig, string extension)
public static bool IsImageFile(this IContentSettings contentConfig, string extension)
{
if (contentConfig == null) throw new ArgumentNullException(nameof(contentConfig));
if (extension == null) return false;
@@ -24,22 +24,22 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
/// held in settings.
/// Allow upload if extension is whitelisted OR if there is no whitelist and extension is NOT blacklisted.
/// </summary>
public static bool IsFileAllowedForUpload(this IContentSection contentSection, string extension)
public static bool IsFileAllowedForUpload(this IContentSettings contentSettings, string extension)
{
return contentSection.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)) ||
(contentSection.AllowedUploadFiles.Any() == false &&
contentSection.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)) == false);
return contentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)) ||
(contentSettings.AllowedUploadFiles.Any() == false &&
contentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)) == false);
}
/// <summary>
/// Gets the auto-fill configuration for a specified property alias.
/// </summary>
/// <param name="contentSection"></param>
/// <param name="contentSettings"></param>
/// <param name="propertyTypeAlias">The property type alias.</param>
/// <returns>The auto-fill configuration for the specified property alias, or null.</returns>
public static IImagingAutoFillUploadField GetConfig(this IContentSection contentSection, string propertyTypeAlias)
public static IImagingAutoFillUploadField GetConfig(this IContentSettings contentSettings, string propertyTypeAlias)
{
var autoFillConfigs = contentSection.ImageAutoFillProperties;
var autoFillConfigs = contentSettings.ImageAutoFillProperties;
return autoFillConfigs?.FirstOrDefault(x => x.Alias == propertyTypeAlias);
}
}
@@ -2,6 +2,6 @@
{
public interface IBackOfficeSection
{
ITourSection Tours { get; }
ITourSettings Tours { get; }
}
}
@@ -3,7 +3,7 @@ using Umbraco.Core.Macros;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IContentSection : IUmbracoConfigurationSection
public interface IContentSettings : IUmbracoConfigurationSection
{
string NotificationEmailAddress { get; }
@@ -1,6 +1,6 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IKeepAliveSection : IUmbracoConfigurationSection
public interface IKeepAliveSettings : IUmbracoConfigurationSection
{
bool DisableKeepAliveTask { get; }
string KeepAlivePingUrl { get; }
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface ILoggingSection : IUmbracoConfigurationSection
public interface ILoggingSettings : IUmbracoConfigurationSection
{
int MaxLogAge { get; }
}
@@ -1,6 +0,0 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IMemberPasswordConfigurationSection : IPasswordConfigurationSection
{
}
}
@@ -2,7 +2,7 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IRequestHandlerSection : IUmbracoConfigurationSection
public interface IRequestHandlerSettings : IUmbracoConfigurationSection
{
bool AddTrailingSlash { get; }
@@ -1,9 +1,9 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface ISecuritySection : IUmbracoConfigurationSection
public interface ISecuritySettings : IUmbracoConfigurationSection
{
bool KeepUserLoggedIn { get; }
bool HideDisabledUsersInBackoffice { get; }
/// <summary>
@@ -23,9 +23,5 @@
/// When this is false, the username and email fields will be shown in the user section.
/// </remarks>
bool UsernameIsEmail { get; }
IUserPasswordConfigurationSection UserPasswordConfiguration { get; }
IMemberPasswordConfigurationSection MemberPasswordConfiguration { get; }
}
}
@@ -1,6 +1,6 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface ITourSection
public interface ITourSettings
{
bool EnableTours { get; }
}
@@ -1,21 +0,0 @@
using System;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IUmbracoSettingsSection : IUmbracoConfigurationSection
{
IBackOfficeSection BackOffice { get; }
IContentSection Content { get; }
ISecuritySection Security { get; }
IRequestHandlerSection RequestHandler { get; }
ILoggingSection Logging { get; }
IWebRoutingSection WebRouting { get; }
IKeepAliveSection KeepAlive { get; }
}
}
@@ -1,6 +0,0 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IUserPasswordConfigurationSection : IPasswordConfigurationSection
{
}
}
@@ -1,6 +1,6 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IWebRoutingSection : IUmbracoConfigurationSection
public interface IWebRoutingSettings : IUmbracoConfigurationSection
{
bool TrySkipIisCustomErrors { get; }
@@ -7,9 +7,9 @@ namespace Umbraco.Core.Configuration
/// </summary>
public class UserPasswordConfiguration : PasswordConfiguration, IUserPasswordConfiguration
{
public UserPasswordConfiguration(IUserPasswordConfigurationSection configSection)
: base(configSection)
{
public UserPasswordConfiguration(IUserPasswordConfiguration configSettings)
: base(configSettings)
{
}
}
}
@@ -149,11 +149,11 @@ namespace Umbraco.Core
}
public static bool IsAllowedTemplate(this IPublishedContent content, IContentTypeService contentTypeService,
IUmbracoSettingsSection umbracoSettingsSection, int templateId)
IWebRoutingSettings webRoutingSettings, int templateId)
{
return content.IsAllowedTemplate(contentTypeService,
umbracoSettingsSection.WebRouting.DisableAlternativeTemplates,
umbracoSettingsSection.WebRouting.ValidateAlternativeTemplates, templateId);
webRoutingSettings.DisableAlternativeTemplates,
webRoutingSettings.ValidateAlternativeTemplates, templateId);
}
public static bool IsAllowedTemplate(this IPublishedContent content, IContentTypeService contentTypeService, bool disableAlternativeTemplates, bool validateAlternativeTemplates, int templateId)
+2 -2
View File
@@ -14,13 +14,13 @@ namespace Umbraco.Web.Routing
public class AliasUrlProvider : IUrlProvider
{
private readonly IGlobalSettings _globalSettings;
private readonly IRequestHandlerSection _requestConfig;
private readonly IRequestHandlerSettings _requestConfig;
private readonly ISiteDomainHelper _siteDomainHelper;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly UriUtility _uriUtility;
private readonly IPublishedValueFallback _publishedValueFallback;
public AliasUrlProvider(IGlobalSettings globalSettings, IRequestHandlerSection requestConfig, ISiteDomainHelper siteDomainHelper, UriUtility uriUtility, IPublishedValueFallback publishedValueFallback, IUmbracoContextAccessor umbracoContextAccessor)
public AliasUrlProvider(IGlobalSettings globalSettings, IRequestHandlerSettings requestConfig, ISiteDomainHelper siteDomainHelper, UriUtility uriUtility, IPublishedValueFallback publishedValueFallback, IUmbracoContextAccessor umbracoContextAccessor)
{
_globalSettings = globalSettings;
_requestConfig = requestConfig;
@@ -18,11 +18,11 @@ namespace Umbraco.Web.Routing
{
private readonly ILogger _logger;
private readonly IRequestAccessor _requestAccessor;
private readonly IWebRoutingSection _webRoutingSection;
private readonly IWebRoutingSettings _webRoutingSettings;
public ContentFinderByIdPath(IWebRoutingSection webRoutingSection, ILogger logger, IRequestAccessor requestAccessor)
public ContentFinderByIdPath(IWebRoutingSettings webRoutingSettings, ILogger logger, IRequestAccessor requestAccessor)
{
_webRoutingSection = webRoutingSection ?? throw new System.ArgumentNullException(nameof(webRoutingSection));
_webRoutingSettings = webRoutingSettings ?? throw new System.ArgumentNullException(nameof(webRoutingSettings));
_logger = logger ?? throw new System.ArgumentNullException(nameof(logger));
_requestAccessor = requestAccessor;
}
@@ -36,7 +36,7 @@ namespace Umbraco.Web.Routing
{
if (frequest.UmbracoContext != null && frequest.UmbracoContext.InPreviewMode == false
&& _webRoutingSection.DisableFindContentByIdPath)
&& _webRoutingSettings.DisableFindContentByIdPath)
return false;
IPublishedContent node = null;
@@ -17,15 +17,16 @@ namespace Umbraco.Web.Routing
public class ContentFinderByUrlAndTemplate : ContentFinderByUrl
{
private readonly IFileService _fileService;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentTypeService _contentTypeService;
public ContentFinderByUrlAndTemplate(ILogger logger, IFileService fileService, IUmbracoSettingsSection umbracoSettingsSection, IContentTypeService contentTypeService)
private readonly IContentTypeService _contentTypeService;
private readonly IWebRoutingSettings _webRoutingSettings;
public ContentFinderByUrlAndTemplate(ILogger logger, IFileService fileService, IContentTypeService contentTypeService, IWebRoutingSettings webRoutingSettings)
: base(logger)
{
_fileService = fileService;
_umbracoSettingsSection = umbracoSettingsSection;
_contentTypeService = contentTypeService;
_webRoutingSettings = webRoutingSettings;
}
/// <summary>
@@ -75,7 +76,7 @@ namespace Umbraco.Web.Routing
}
// IsAllowedTemplate deals both with DisableAlternativeTemplates and ValidateAlternativeTemplates settings
if (!node.IsAllowedTemplate(_contentTypeService, _umbracoSettingsSection, template.Id))
if (!node.IsAllowedTemplate(_contentTypeService, _webRoutingSettings, template.Id))
{
Logger.Warn<ContentFinderByUrlAndTemplate>("Alternative template '{TemplateAlias}' is not allowed on node {NodeId}.", template.Alias, node.Id);
frequest.PublishedContent = null; // clear
@@ -12,14 +12,14 @@ namespace Umbraco.Web.Routing
/// </summary>
public class DefaultUrlProvider : IUrlProvider
{
private readonly IRequestHandlerSection _requestSettings;
private readonly IRequestHandlerSettings _requestSettings;
private readonly ILogger _logger;
private readonly IGlobalSettings _globalSettings;
private readonly ISiteDomainHelper _siteDomainHelper;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly UriUtility _uriUtility;
public DefaultUrlProvider(IRequestHandlerSection requestSettings, ILogger logger, IGlobalSettings globalSettings, ISiteDomainHelper siteDomainHelper, IUmbracoContextAccessor umbracoContextAccessor, UriUtility uriUtility)
public DefaultUrlProvider(IRequestHandlerSettings requestSettings, ILogger logger, IGlobalSettings globalSettings, ISiteDomainHelper siteDomainHelper, IUmbracoContextAccessor umbracoContextAccessor, UriUtility uriUtility)
{
_requestSettings = requestSettings;
_logger = logger;
+4 -4
View File
@@ -16,7 +16,7 @@ namespace Umbraco.Web.Routing
public class PublishedRequest : IPublishedRequest
{
private readonly IPublishedRouter _publishedRouter;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IWebRoutingSettings _webRoutingSettings;
private bool _readonly; // after prepared
private bool _readonlyUri; // after preparing
@@ -33,11 +33,11 @@ namespace Umbraco.Web.Routing
/// <param name="publishedRouter">The published router.</param>
/// <param name="umbracoContext">The Umbraco context.</param>
/// <param name="uri">The request <c>Uri</c>.</param>
internal PublishedRequest(IPublishedRouter publishedRouter, IUmbracoContext umbracoContext, IUmbracoSettingsSection umbracoSettingsSection, Uri uri = null)
internal PublishedRequest(IPublishedRouter publishedRouter, IUmbracoContext umbracoContext, IWebRoutingSettings webRoutingSettings, Uri uri = null)
{
UmbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext));
_publishedRouter = publishedRouter ?? throw new ArgumentNullException(nameof(publishedRouter));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_webRoutingSettings = webRoutingSettings;
Uri = uri ?? umbracoContext.CleanedUmbracoUrl;
}
@@ -178,7 +178,7 @@ namespace Umbraco.Web.Routing
IsInternalRedirectPublishedContent = isInternalRedirect;
// must restore the template if it's an internal redirect & the config option is set
if (isInternalRedirect && _umbracoSettingsSection.WebRouting.InternalRedirectPreservesTemplate)
if (isInternalRedirect && _webRoutingSettings.InternalRedirectPreservesTemplate)
{
// restore
TemplateModel = template;
+7 -10
View File
@@ -19,13 +19,12 @@ namespace Umbraco.Web.Routing
/// </summary>
public class PublishedRouter : IPublishedRouter
{
private readonly IWebRoutingSection _webRoutingSection;
private readonly IWebRoutingSettings _webRoutingSettings;
private readonly ContentFinderCollection _contentFinders;
private readonly IContentLastChanceFinder _contentLastChanceFinder;
private readonly IProfilingLogger _profilingLogger;
private readonly IVariationContextAccessor _variationContextAccessor;
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IPublishedUrlProvider _publishedUrlProvider;
private readonly IRequestAccessor _requestAccessor;
private readonly IPublishedValueFallback _publishedValueFallback;
@@ -38,12 +37,11 @@ namespace Umbraco.Web.Routing
/// Initializes a new instance of the <see cref="PublishedRouter"/> class.
/// </summary>
public PublishedRouter(
IWebRoutingSection webRoutingSection,
IWebRoutingSettings webRoutingSettings,
ContentFinderCollection contentFinders,
IContentLastChanceFinder contentLastChanceFinder,
IVariationContextAccessor variationContextAccessor,
IProfilingLogger proflog,
IUmbracoSettingsSection umbracoSettingsSection,
IPublishedUrlProvider publishedUrlProvider,
IRequestAccessor requestAccessor,
IPublishedValueFallback publishedValueFallback,
@@ -52,13 +50,12 @@ namespace Umbraco.Web.Routing
IContentTypeService contentTypeService,
IPublicAccessService publicAccessService)
{
_webRoutingSection = webRoutingSection ?? throw new ArgumentNullException(nameof(webRoutingSection));
_webRoutingSettings = webRoutingSettings ?? throw new ArgumentNullException(nameof(webRoutingSettings));
_contentFinders = contentFinders ?? throw new ArgumentNullException(nameof(contentFinders));
_contentLastChanceFinder = contentLastChanceFinder ?? throw new ArgumentNullException(nameof(contentLastChanceFinder));
_profilingLogger = proflog ?? throw new ArgumentNullException(nameof(proflog));
_variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
_logger = proflog;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_publishedUrlProvider = publishedUrlProvider;
_requestAccessor = requestAccessor;
_publishedValueFallback = publishedValueFallback;
@@ -71,7 +68,7 @@ namespace Umbraco.Web.Routing
/// <inheritdoc />
public IPublishedRequest CreateRequest(IUmbracoContext umbracoContext, Uri uri = null)
{
return new PublishedRequest(this, umbracoContext, _umbracoSettingsSection, uri ?? umbracoContext.CleanedUmbracoUrl);
return new PublishedRequest(this, umbracoContext, _webRoutingSettings, uri ?? umbracoContext.CleanedUmbracoUrl);
}
#region Request
@@ -628,7 +625,7 @@ namespace Umbraco.Web.Routing
// does not apply
// + optionally, apply the alternate template on internal redirects
var useAltTemplate = request.IsInitialPublishedContent
|| (_webRoutingSection.InternalRedirectPreservesTemplate && request.IsInternalRedirectPublishedContent);
|| (_webRoutingSettings.InternalRedirectPreservesTemplate && request.IsInternalRedirectPublishedContent);
var altTemplate = useAltTemplate
? _requestAccessor.GetRequestValue(Constants.Conventions.Url.AltTemplate)
: null;
@@ -670,8 +667,8 @@ namespace Umbraco.Web.Routing
if (request.PublishedContent.IsAllowedTemplate(
_fileService,
_contentTypeService,
_umbracoSettingsSection.WebRouting.DisableAlternativeTemplates,
_umbracoSettingsSection.WebRouting.ValidateAlternativeTemplates,
_webRoutingSettings.DisableAlternativeTemplates,
_webRoutingSettings.ValidateAlternativeTemplates,
altTemplate))
{
// allowed, use
+1 -1
View File
@@ -61,7 +61,7 @@ namespace Umbraco.Web
// maps an internal umbraco uri to a public uri
// ie with virtual directory, .aspx if required...
public Uri UriFromUmbraco(Uri uri, IGlobalSettings globalSettings, IRequestHandlerSection requestConfig)
public Uri UriFromUmbraco(Uri uri, IGlobalSettings globalSettings, IRequestHandlerSettings requestConfig)
{
var path = uri.GetSafeAbsolutePath();
+1 -1
View File
@@ -24,7 +24,7 @@ namespace Umbraco.Web.Routing
/// <param name="mediaUrlProviders">The list of media url providers.</param>
/// <param name="variationContextAccessor">The current variation accessor.</param>
/// <param name="propertyEditorCollection"></param>
public UrlProvider(IUmbracoContextAccessor umbracoContextAccessor, IWebRoutingSection routingSettings, UrlProviderCollection urlProviders, MediaUrlProviderCollection mediaUrlProviders, IVariationContextAccessor variationContextAccessor)
public UrlProvider(IUmbracoContextAccessor umbracoContextAccessor, IWebRoutingSettings routingSettings, UrlProviderCollection urlProviders, MediaUrlProviderCollection mediaUrlProviders, IVariationContextAccessor variationContextAccessor)
{
if (routingSettings == null) throw new ArgumentNullException(nameof(routingSettings));
+4 -4
View File
@@ -12,16 +12,16 @@ namespace Umbraco.Web.Scheduling
public class KeepAlive : RecurringTaskBase
{
private readonly IRuntimeState _runtime;
private readonly IKeepAliveSection _keepAliveSection;
private readonly IKeepAliveSettings _keepAliveSettings;
private readonly IProfilingLogger _logger;
private static HttpClient _httpClient;
public KeepAlive(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
IRuntimeState runtime, IKeepAliveSection keepAliveSection, IProfilingLogger logger)
IRuntimeState runtime, IKeepAliveSettings keepAliveSettings, IProfilingLogger logger)
: base(runner, delayMilliseconds, periodMilliseconds)
{
_runtime = runtime;
_keepAliveSection = keepAliveSection;
_keepAliveSettings = keepAliveSettings;
_logger = logger;
if (_httpClient == null)
_httpClient = new HttpClient();
@@ -49,7 +49,7 @@ namespace Umbraco.Web.Scheduling
using (_logger.DebugDuration<KeepAlive>("Keep alive executing", "Keep alive complete"))
{
var keepAlivePingUrl = _keepAliveSection.KeepAlivePingUrl;
var keepAlivePingUrl = _keepAliveSettings.KeepAlivePingUrl;
try
{
if (keepAlivePingUrl.Contains("{umbracoApplicationUrl}"))
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Strings
{
#region Ctor, consts and vars
public DefaultShortStringHelper(IUmbracoSettingsSection settings)
public DefaultShortStringHelper(IRequestHandlerSettings settings)
{
_config = new DefaultShortStringHelperConfig().WithDefault(settings);
}
@@ -619,6 +619,6 @@ namespace Umbraco.Core.Strings
return new string(output, 0, opos);
}
#endregion
#endregion
}
}
@@ -30,7 +30,7 @@ namespace Umbraco.Core.Strings
public string DefaultCulture { get; set; } = ""; // invariant
public Dictionary<string, string> UrlReplaceCharacters { get; set; }
public DefaultShortStringHelperConfig WithConfig(Config config)
{
return WithConfig(DefaultCulture, CleanStringType.RoleMask, config);
@@ -57,16 +57,16 @@ namespace Umbraco.Core.Strings
/// Sets the default configuration.
/// </summary>
/// <returns>The short string helper.</returns>
public DefaultShortStringHelperConfig WithDefault(IUmbracoSettingsSection umbracoSettings)
public DefaultShortStringHelperConfig WithDefault(IRequestHandlerSettings requestHandlerSettings)
{
UrlReplaceCharacters = umbracoSettings.RequestHandler.CharCollection
UrlReplaceCharacters = requestHandlerSettings.CharCollection
.Where(x => string.IsNullOrEmpty(x.Char) == false)
.ToDictionary(x => x.Char, x => x.Replacement);
var urlSegmentConvertTo = CleanStringType.Utf8;
if (umbracoSettings.RequestHandler.ConvertUrlsToAscii)
if (requestHandlerSettings.ConvertUrlsToAscii)
urlSegmentConvertTo = CleanStringType.Ascii;
if (umbracoSettings.RequestHandler.TryConvertUrlsToAscii)
if (requestHandlerSettings.TryConvertUrlsToAscii)
urlSegmentConvertTo = CleanStringType.TryAscii;
return WithConfig(CleanStringType.UrlSegment, new Config
+4 -4
View File
@@ -7,16 +7,16 @@ namespace Umbraco.Web.Templates
{
public sealed class HtmlUrlParser
{
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
private readonly IIOHelper _ioHelper;
private readonly IProfilingLogger _logger;
private static readonly Regex ResolveUrlPattern = new Regex("(=[\"\']?)(\\W?\\~(?:.(?![\"\']?\\s+(?:\\S+)=|[>\"\']))+.)[\"\']?",
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
public HtmlUrlParser(IContentSection contentSection, IProfilingLogger logger, IIOHelper ioHelper)
public HtmlUrlParser(IContentSettings contentSettings, IProfilingLogger logger, IIOHelper ioHelper)
{
_contentSection = contentSection;
_contentSettings = contentSettings;
_ioHelper = ioHelper;
_logger = logger;
}
@@ -32,7 +32,7 @@ namespace Umbraco.Web.Templates
/// </remarks>
public string EnsureUrls(string text)
{
if (_contentSection.ResolveUrlsFromTextString == false) return text;
if (_contentSettings.ResolveUrlsFromTextString == false) return text;
using (var timer = _logger.DebugDuration(typeof(IOHelper), "ResolveUrlsFromTextString starting", "ResolveUrlsFromTextString complete"))
{
@@ -1,24 +0,0 @@
using Umbraco.Core.Configuration;
using Umbraco.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Core.Composing.CompositionExtensions
{
/// <summary>
/// Compose configurations.
/// </summary>
internal static class Configuration
{
public static Composition ComposeConfiguration(this Composition composition)
{
// common configurations are already registered
// register others
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().RequestHandler);
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Security);
return composition;
}
}
}
@@ -18,9 +18,9 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
private readonly IRuntimeState _runtimeState;
private readonly ILogger _logger;
private readonly IGlobalSettings _globalSettings;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks, IUmbracoSettingsSection umbracoSettingsSection) : base(healthChecks)
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks, IContentSettings contentSettings) : base(healthChecks)
{
var recipientEmail = Settings["recipientEmail"]?.Value;
if (string.IsNullOrWhiteSpace(recipientEmail))
@@ -35,7 +35,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
_runtimeState = runtimeState;
_logger = logger;
_globalSettings = globalSettings;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
public string RecipientEmail { get; }
@@ -74,7 +74,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
private MailMessage CreateMailMessage(string subject, string message)
{
var to = _umbracoSettingsSection.Content.NotificationEmailAddress;
var to = _contentSettings.NotificationEmailAddress;
if (string.IsNullOrWhiteSpace(subject))
subject = "Umbraco Health Check Status";
@@ -17,13 +17,13 @@ namespace Umbraco.Web.Media
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly ILogger _logger;
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
public UploadAutoFillProperties(IMediaFileSystem mediaFileSystem, ILogger logger, IContentSection contentSection)
public UploadAutoFillProperties(IMediaFileSystem mediaFileSystem, ILogger logger, IContentSettings contentSettings)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_contentSection = contentSection ?? throw new ArgumentNullException(nameof(contentSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
/// <summary>
@@ -68,7 +68,7 @@ namespace Umbraco.Web.Media
using (var filestream = _mediaFileSystem.OpenFile(filepath))
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
var size = _contentSection.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
@@ -102,7 +102,7 @@ namespace Umbraco.Web.Media
else
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
var size = _contentSection.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
@@ -28,6 +28,7 @@ namespace Umbraco.Core.Migrations.Install
private readonly IIOHelper _ioHelper;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IDbProviderFactoryCreator _dbProviderFactoryCreator;
private readonly IConnectionStrings _connectionStrings;
private DatabaseSchemaResult _databaseSchemaValidationResult;
@@ -44,7 +45,8 @@ namespace Umbraco.Core.Migrations.Install
IKeyValueService keyValueService,
IIOHelper ioHelper,
IUmbracoVersion umbracoVersion,
IDbProviderFactoryCreator dbProviderFactoryCreator)
IDbProviderFactoryCreator dbProviderFactoryCreator,
IConnectionStrings connectionStrings)
{
_scopeProvider = scopeProvider;
_globalSettings = globalSettings;
@@ -56,6 +58,7 @@ namespace Umbraco.Core.Migrations.Install
_ioHelper = ioHelper;
_umbracoVersion = umbracoVersion;
_dbProviderFactoryCreator = dbProviderFactoryCreator;
_connectionStrings = connectionStrings;
}
#region Status
@@ -138,12 +141,12 @@ namespace Umbraco.Core.Migrations.Install
/// </summary>
public void ConfigureEmbeddedDatabaseConnection()
{
ConfigureEmbeddedDatabaseConnection(_databaseFactory, _ioHelper, _logger);
ConfigureEmbeddedDatabaseConnection(_databaseFactory, _ioHelper);
}
private void ConfigureEmbeddedDatabaseConnection(IUmbracoDatabaseFactory factory, IIOHelper ioHelper, ILogger logger)
private void ConfigureEmbeddedDatabaseConnection(IUmbracoDatabaseFactory factory, IIOHelper ioHelper)
{
SaveConnectionString(EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe, ioHelper, logger);
_connectionStrings.SaveConnectionString(EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe);
var path = Path.Combine(ioHelper.GetRootDirectorySafe(), "App_Data", "Umbraco.sdf");
if (File.Exists(path) == false)
@@ -166,7 +169,7 @@ namespace Umbraco.Core.Migrations.Install
{
const string providerName = Constants.DbProviderNames.SqlServer;
SaveConnectionString(connectionString, providerName, _ioHelper, _logger);
_connectionStrings.SaveConnectionString(connectionString, providerName);
_databaseFactory.Configure(connectionString, providerName);
}
@@ -182,7 +185,7 @@ namespace Umbraco.Core.Migrations.Install
{
var connectionString = GetDatabaseConnectionString(server, databaseName, user, password, databaseProvider, out var providerName);
SaveConnectionString(connectionString, providerName, _ioHelper, _logger);
_connectionStrings.SaveConnectionString(connectionString, providerName);
_databaseFactory.Configure(connectionString, providerName);
}
@@ -213,7 +216,7 @@ namespace Umbraco.Core.Migrations.Install
public void ConfigureIntegratedSecurityDatabaseConnection(string server, string databaseName)
{
var connectionString = GetIntegratedSecurityDatabaseConnectionString(server, databaseName);
SaveConnectionString(connectionString, Constants.DbProviderNames.SqlServer, _ioHelper, _logger);
_connectionStrings.SaveConnectionString(connectionString, Constants.DbProviderNames.SqlServer);
_databaseFactory.Configure(connectionString, Constants.DbProviderNames.SqlServer);
}
@@ -282,75 +285,8 @@ namespace Umbraco.Core.Migrations.Install
return server.ToLower().StartsWith("tcp:".ToLower());
}
/// <summary>
/// Saves the connection string as a proper .net connection string in web.config.
/// </summary>
/// <remarks>Saves the ConnectionString in the very nasty 'medium trust'-supportive way.</remarks>
/// <param name="connectionString">The connection string.</param>
/// <param name="providerName">The provider name.</param>
/// <param name="logger">A logger.</param>
private static void SaveConnectionString(string connectionString, string providerName, IIOHelper ioHelper, ILogger logger)
{
if (connectionString == null) throw new ArgumentNullException(nameof(connectionString));
if (string.IsNullOrWhiteSpace(connectionString)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(connectionString));
if (providerName == null) throw new ArgumentNullException(nameof(providerName));
if (string.IsNullOrWhiteSpace(providerName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(providerName));
var fileSource = "web.config";
var fileName = ioHelper.MapPath(ioHelper.Root +"/" + fileSource);
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
if (xml.Root == null) throw new Exception($"Invalid {fileSource} file (no root).");
var connectionStrings = xml.Root.DescendantsAndSelf("connectionStrings").FirstOrDefault();
if (connectionStrings == null) throw new Exception($"Invalid {fileSource} file (no connection strings).");
// handle configSource
var configSourceAttribute = connectionStrings.Attribute("configSource");
if (configSourceAttribute != null)
{
fileSource = configSourceAttribute.Value;
fileName = ioHelper.MapPath(ioHelper.Root + "/" + fileSource);
if (!File.Exists(fileName))
throw new Exception($"Invalid configSource \"{fileSource}\" (no such file).");
xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
if (xml.Root == null) throw new Exception($"Invalid {fileSource} file (no root).");
connectionStrings = xml.Root.DescendantsAndSelf("connectionStrings").FirstOrDefault();
if (connectionStrings == null) throw new Exception($"Invalid {fileSource} file (no connection strings).");
}
// create or update connection string
var setting = connectionStrings.Descendants("add").FirstOrDefault(s => s.Attribute("name")?.Value == Constants.System.UmbracoConnectionName);
if (setting == null)
{
connectionStrings.Add(new XElement("add",
new XAttribute("name", Constants.System.UmbracoConnectionName),
new XAttribute("connectionString", connectionString),
new XAttribute("providerName", providerName)));
}
else
{
AddOrUpdateAttribute(setting, "connectionString", connectionString);
AddOrUpdateAttribute(setting, "providerName", providerName);
}
// save
logger.Info<DatabaseBuilder>("Saving connection string to {ConfigFile}.", fileSource);
xml.Save(fileName, SaveOptions.DisableFormatting);
logger.Info<DatabaseBuilder>("Saved connection string to {ConfigFile}.", fileSource);
}
private static void AddOrUpdateAttribute(XElement element, string name, string value)
{
var attribute = element.Attribute(name);
if (attribute == null)
element.Add(new XAttribute(name, value));
else
attribute.Value = value;
}
#endregion
@@ -33,7 +33,7 @@ namespace Umbraco.Web.Models.ContentEditing
if (UserGroups.Any() == false)
yield return new ValidationResult("A user must be assigned to at least one group", new[] { nameof(UserGroups) });
if (Current.Configs.Settings().Security.UsernameIsEmail == false && Username.IsNullOrWhiteSpace())
if (Current.Configs.Security().UsernameIsEmail == false && Username.IsNullOrWhiteSpace())
yield return new ValidationResult("A username cannot be empty", new[] { nameof(Username) });
}
}
@@ -15,13 +15,13 @@ namespace Umbraco.Web.Models.Mapping
{
private readonly PropertyEditorCollection _propertyEditors;
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public DataTypeMapDefinition(PropertyEditorCollection propertyEditors, ILogger logger, IUmbracoSettingsSection umbracoSettingsSection)
public DataTypeMapDefinition(PropertyEditorCollection propertyEditors, ILogger logger, IContentSettings contentSettings)
{
_propertyEditors = propertyEditors;
_logger = logger;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
private static readonly int[] SystemIds =
@@ -128,9 +128,8 @@ namespace Umbraco.Web.Models.Mapping
private IEnumerable<PropertyEditorBasic> MapAvailableEditors(IDataType source, MapperContext context)
{
var contentSection = _umbracoSettingsSection.Content;
var properties = _propertyEditors
.Where(x => !x.IsDeprecated || contentSection.ShowDeprecatedPropertyEditors || source.EditorAlias == x.Alias)
.Where(x => !x.IsDeprecated || _contentSettings.ShowDeprecatedPropertyEditors || source.EditorAlias == x.Alias)
.OrderBy(x => x.Name);
return context.MapEnumerable<IDataEditor, PropertyEditorBasic>(properties);
}
@@ -27,9 +27,9 @@ namespace Umbraco.Core.Models
/// <summary>
/// Gets the urls of a media item.
/// </summary>
public static string[] GetUrls(this IMedia media, IContentSection contentSection, MediaUrlGeneratorCollection mediaUrlGenerators)
public static string[] GetUrls(this IMedia media, IContentSettings contentSettings, MediaUrlGeneratorCollection mediaUrlGenerators)
{
return contentSection.ImageAutoFillProperties
return contentSettings.ImageAutoFillProperties
.Select(field => media.GetUrl(field.Alias, mediaUrlGenerators))
.Where(link => string.IsNullOrWhiteSpace(link) == false)
.ToArray();
@@ -22,23 +22,21 @@ namespace Umbraco.Web.PropertyEditors
public class FileUploadPropertyEditor : DataEditor, IMediaUrlGenerator
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
private readonly UploadAutoFillProperties _uploadAutoFillProperties;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly ILocalizedTextService _localizedTextService;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public FileUploadPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSection, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection)
public FileUploadPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSettings contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_contentSection = contentSection;
_contentSettings = contentSettings;
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_localizedTextService = localizedTextService;
_uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSection);
_umbracoSettingsSection = umbracoSettingsSection;
_uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSettings);
}
/// <summary>
@@ -47,8 +45,8 @@ namespace Umbraco.Web.PropertyEditors
/// <returns>The corresponding property value editor.</returns>
protected override IDataValueEditor CreateValueEditor()
{
var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, _umbracoSettingsSection);
editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, _umbracoSettingsSection));
var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, _contentSettings);
editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, _contentSettings));
return editor;
}
@@ -179,7 +177,7 @@ namespace Umbraco.Web.PropertyEditors
foreach (var property in properties)
{
var autoFillConfig = _contentSection.GetConfig(property.Alias);
var autoFillConfig = _contentSettings.GetConfig(property.Alias);
if (autoFillConfig == null) continue;
foreach (var pvalue in property.Values)
@@ -16,13 +16,13 @@ namespace Umbraco.Web.PropertyEditors
internal class FileUploadPropertyValueEditor : DataValueEditor
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public FileUploadPropertyValueEditor(DataEditorAttribute attribute, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection)
public FileUploadPropertyValueEditor(DataEditorAttribute attribute, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IContentSettings contentSettings)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
/// <summary>
@@ -101,7 +101,7 @@ namespace Umbraco.Web.PropertyEditors
{
// process the file
// no file, invalid file, reject change
if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _umbracoSettingsSection) == false)
if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _contentSettings) == false)
return null;
// get the filepath
@@ -29,17 +29,16 @@ namespace Umbraco.Web.PropertyEditors
public class ImageCropperPropertyEditor : DataEditor, IMediaUrlGenerator
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IContentSection _contentSettings;
private readonly IContentSettings _contentSettings;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly UploadAutoFillProperties _autoFillProperties;
/// <summary>
/// Initializes a new instance of the <see cref="ImageCropperPropertyEditor"/> class.
/// </summary>
public ImageCropperPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService, IUmbracoSettingsSection umbracoSettingsSection)
public ImageCropperPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSettings contentSettings, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService)
: base(logger, dataTypeService, localizationService, localizedTextService,shortStringHelper)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
@@ -47,7 +46,6 @@ namespace Umbraco.Web.PropertyEditors
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
// TODO: inject?
_autoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, _contentSettings);
@@ -68,7 +66,7 @@ namespace Umbraco.Web.PropertyEditors
/// Creates the corresponding property value editor.
/// </summary>
/// <returns>The corresponding property value editor.</returns>
protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, Logger, _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _umbracoSettingsSection);
protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, Logger, _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _contentSettings);
/// <summary>
/// Creates the corresponding preValue editor.
@@ -22,14 +22,14 @@ namespace Umbraco.Web.PropertyEditors
{
private readonly ILogger _logger;
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public ImageCropperPropertyValueEditor(DataEditorAttribute attribute, ILogger logger, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection)
public ImageCropperPropertyValueEditor(DataEditorAttribute attribute, ILogger logger, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IContentSettings contentSettings)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
}
/// <summary>
@@ -146,7 +146,7 @@ namespace Umbraco.Web.PropertyEditors
{
// process the file
// no file, invalid file, reject change
if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _umbracoSettingsSection) == false)
if (UploadFileTypeValidator.IsValidFileExtension(file.FileName, _contentSettings) == false)
return null;
// get the filepath
@@ -16,12 +16,12 @@ namespace Umbraco.Web.PropertyEditors
internal class UploadFileTypeValidator : IValueValidator
{
private readonly ILocalizedTextService _localizedTextService;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IContentSettings _contentSettings;
public UploadFileTypeValidator(ILocalizedTextService localizedTextService, IUmbracoSettingsSection umbracoSettingsSection)
public UploadFileTypeValidator(ILocalizedTextService localizedTextService, IContentSettings contentSettings)
{
_localizedTextService = localizedTextService;
_umbracoSettingsSection = umbracoSettingsSection;
_contentSettings = contentSettings;
}
public IEnumerable<ValidationResult> Validate(object value, string valueType, object dataTypeConfiguration)
@@ -46,7 +46,7 @@ namespace Umbraco.Web.PropertyEditors
foreach (string filename in fileNames)
{
if (IsValidFileExtension(filename, _umbracoSettingsSection) == false)
if (IsValidFileExtension(filename, _contentSettings) == false)
{
//we only store a single value for this editor so the 'member' or 'field'
// we'll associate this error with will simply be called 'value'
@@ -55,11 +55,11 @@ namespace Umbraco.Web.PropertyEditors
}
}
internal static bool IsValidFileExtension(string fileName, IUmbracoSettingsSection umbracoSettingsSection)
internal static bool IsValidFileExtension(string fileName, IContentSettings contentSettings)
{
if (fileName.IndexOf('.') <= 0) return false;
var extension = new FileInfo(fileName).Extension.TrimStart(".");
return umbracoSettingsSection.Content.IsFileAllowedForUpload(extension);
return contentSettings.IsFileAllowedForUpload(extension);
}
}
}
@@ -16,14 +16,14 @@ namespace Umbraco.Web.Routing
{
private readonly ILogger _logger;
private readonly IEntityService _entityService;
private readonly IContentSection _contentConfigSection;
private readonly IContentSettings _contentConfigSettings;
private readonly IExamineManager _examineManager;
public ContentFinderByConfigured404(ILogger logger, IEntityService entityService, IContentSection contentConfigSection, IExamineManager examineManager)
public ContentFinderByConfigured404(ILogger logger, IEntityService entityService, IContentSettings contentConfigSettings, IExamineManager examineManager)
{
_logger = logger;
_entityService = entityService;
_contentConfigSection = contentConfigSection;
_contentConfigSettings = contentConfigSettings;
_examineManager = examineManager;
}
@@ -63,7 +63,7 @@ namespace Umbraco.Web.Routing
}
var error404 = NotFoundHandlerHelper.GetCurrentNotFoundPageId(
_contentConfigSection.Error404Collection.ToArray(),
_contentConfigSettings.Error404Collection.ToArray(),
_entityService,
new PublishedContentQuery(frequest.UmbracoContext.PublishedSnapshot, frequest.UmbracoContext.VariationContextAccessor, _examineManager),
errorCulture);
@@ -24,14 +24,15 @@ namespace Umbraco.Web.Routing
{
private const string _eventStateKey = "Umbraco.Web.Redirects.RedirectTrackingEventHandler";
private readonly IUmbracoSettingsSection _umbracoSettings;
private readonly IWebRoutingSettings _webRoutingSettings;
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IRedirectUrlService _redirectUrlService;
private readonly IVariationContextAccessor _variationContextAccessor;
public RedirectTrackingComponent(IUmbracoSettingsSection umbracoSettings, IPublishedSnapshotAccessor publishedSnapshotAccessor, IRedirectUrlService redirectUrlService, IVariationContextAccessor variationContextAccessor)
public RedirectTrackingComponent(IWebRoutingSettings webRoutingSettings, IPublishedSnapshotAccessor publishedSnapshotAccessor, IRedirectUrlService redirectUrlService, IVariationContextAccessor variationContextAccessor)
{
_umbracoSettings = umbracoSettings;
_webRoutingSettings = webRoutingSettings;
_publishedSnapshotAccessor = publishedSnapshotAccessor;
_redirectUrlService = redirectUrlService;
_variationContextAccessor = variationContextAccessor;
@@ -40,7 +41,7 @@ namespace Umbraco.Web.Routing
public void Initialize()
{
// don't let the event handlers kick in if Redirect Tracking is turned off in the config
if (_umbracoSettings.WebRouting.DisableRedirectUrlTracking) return;
if (_webRoutingSettings.DisableRedirectUrlTracking) return;
ContentService.Publishing += ContentService_Publishing;
ContentService.Published += ContentService_Published;
@@ -44,7 +44,6 @@ namespace Umbraco.Core.Runtime
// composers
composition
.ComposeConfiguration()
.ComposeRepositories()
.ComposeServices()
.ComposeCoreMappingProfiles()
@@ -139,7 +138,7 @@ namespace Umbraco.Core.Runtime
composition.RegisterUnique<IPublishedContentTypeFactory, PublishedContentTypeFactory>();
composition.RegisterUnique<IShortStringHelper>(factory
=> new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(factory.GetInstance<IUmbracoSettingsSection>())));
=> new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(factory.GetInstance<IRequestHandlerSettings>())));
composition.UrlSegmentProviders()
.Append<DefaultUrlSegmentProvider>();
@@ -57,7 +57,7 @@ namespace Umbraco.Core.Runtime
// beware! must use '() => _factory.GetInstance<T>()' and NOT '_factory.GetInstance<T>'
// as the second one captures the current value (null) and therefore fails
_state = new RuntimeState(Logger,
Configs.Settings(), Configs.Global(),
Configs.Global(),
new Lazy<IMainDom>(() => mainDom),
new Lazy<IServerRegistrar>(() => _factory.GetInstance<IServerRegistrar>()),
UmbracoVersion,HostingEnvironment, BackOfficeInfo)
@@ -171,7 +171,7 @@ namespace Umbraco.Core.Runtime
// beware! must use '() => _factory.GetInstance<T>()' and NOT '_factory.GetInstance<T>'
// as the second one captures the current value (null) and therefore fails
_state = new RuntimeState(Logger,
Configs.Settings(), Configs.Global(),
Configs.Global(),
new Lazy<IMainDom>(() => _factory.GetInstance<IMainDom>()),
new Lazy<IServerRegistrar>(() => _factory.GetInstance<IServerRegistrar>()),
UmbracoVersion, HostingEnvironment, BackOfficeInfo)
+1 -3
View File
@@ -20,7 +20,6 @@ namespace Umbraco.Core
public class RuntimeState : IRuntimeState
{
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _settings;
private readonly IGlobalSettings _globalSettings;
private readonly ConcurrentHashSet<string> _applicationUrls = new ConcurrentHashSet<string>();
private readonly Lazy<IMainDom> _mainDom;
@@ -32,13 +31,12 @@ namespace Umbraco.Core
/// <summary>
/// Initializes a new instance of the <see cref="RuntimeState"/> class.
/// </summary>
public RuntimeState(ILogger logger, IUmbracoSettingsSection settings, IGlobalSettings globalSettings,
public RuntimeState(ILogger logger, IGlobalSettings globalSettings,
Lazy<IMainDom> mainDom, Lazy<IServerRegistrar> serverRegistrar, IUmbracoVersion umbracoVersion,
IHostingEnvironment hostingEnvironment,
IBackOfficeInfo backOfficeInfo)
{
_logger = logger;
_settings = settings;
_globalSettings = globalSettings;
_mainDom = mainDom;
_serverRegistrar = serverRegistrar;
@@ -13,12 +13,12 @@ namespace Umbraco.Web.Scheduling
{
private readonly IRuntimeState _runtime;
private readonly IAuditService _auditService;
private readonly IUmbracoSettingsSection _settings;
private readonly ILoggingSettings _settings;
private readonly IProfilingLogger _logger;
private readonly IScopeProvider _scopeProvider;
public LogScrubber(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
IRuntimeState runtime, IAuditService auditService, IUmbracoSettingsSection settings, IScopeProvider scopeProvider, IProfilingLogger logger)
IRuntimeState runtime, IAuditService auditService, ILoggingSettings settings, IScopeProvider scopeProvider, IProfilingLogger logger)
: base(runner, delayMilliseconds, periodMilliseconds)
{
_runtime = runtime;
@@ -29,13 +29,13 @@ namespace Umbraco.Web.Scheduling
}
// maximum age, in minutes
private int GetLogScrubbingMaximumAge(IUmbracoSettingsSection settings)
private int GetLogScrubbingMaximumAge(ILoggingSettings settings)
{
var maximumAge = 24 * 60; // 24 hours, in minutes
try
{
if (settings.Logging.MaxLogAge > -1)
maximumAge = settings.Logging.MaxLogAge;
if (settings.MaxLogAge > -1)
maximumAge = settings.MaxLogAge;
}
catch (Exception ex)
{
@@ -45,7 +45,7 @@ namespace Umbraco.Web.Scheduling
}
public static int GetLogScrubbingInterval(IUmbracoSettingsSection settings, ILogger logger)
public static int GetLogScrubbingInterval()
{
const int interval = 4 * 60 * 60 * 1000; // 4 hours, in milliseconds
return interval;
@@ -35,10 +35,11 @@ namespace Umbraco.Web.Scheduling
private readonly HealthCheckNotificationMethodCollection _notifications;
private readonly IUmbracoContextFactory _umbracoContextFactory;
private readonly IHealthChecks _healthChecksConfig;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IIOHelper _ioHelper;
private readonly IServerMessenger _serverMessenger;
private readonly IRequestAccessor _requestAccessor;
private readonly ILoggingSettings _loggingSettings;
private readonly IKeepAliveSettings _keepAliveSettings;
private BackgroundTaskRunner<IBackgroundTask> _keepAliveRunner;
private BackgroundTaskRunner<IBackgroundTask> _publishingRunner;
@@ -56,7 +57,8 @@ namespace Umbraco.Web.Scheduling
HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications,
IScopeProvider scopeProvider, IUmbracoContextFactory umbracoContextFactory, IProfilingLogger logger,
IHostingEnvironment hostingEnvironment, IHealthChecks healthChecksConfig,
IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, IServerMessenger serverMessenger, IRequestAccessor requestAccessor)
IIOHelper ioHelper, IServerMessenger serverMessenger, IRequestAccessor requestAccessor,
ILoggingSettings loggingSettings, IKeepAliveSettings keepAliveSettings)
{
_runtime = runtime;
_contentService = contentService;
@@ -69,10 +71,11 @@ namespace Umbraco.Web.Scheduling
_healthChecks = healthChecks;
_notifications = notifications;
_healthChecksConfig = healthChecksConfig ?? throw new ArgumentNullException(nameof(healthChecksConfig));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_ioHelper = ioHelper;
_serverMessenger = serverMessenger;
_requestAccessor = requestAccessor;
_loggingSettings = loggingSettings;
_keepAliveSettings = keepAliveSettings;
}
public void Initialize()
@@ -111,17 +114,16 @@ namespace Umbraco.Web.Scheduling
LazyInitializer.EnsureInitialized(ref _tasks, ref _started, ref _locker, () =>
{
_logger.Debug<SchedulerComponent>("Initializing the scheduler");
var settings = _umbracoSettingsSection;
var tasks = new List<IBackgroundTask>();
if (settings.KeepAlive.DisableKeepAliveTask == false)
if (_keepAliveSettings.DisableKeepAliveTask == false)
{
tasks.Add(RegisterKeepAlive(settings.KeepAlive));
tasks.Add(RegisterKeepAlive(_keepAliveSettings));
}
tasks.Add(RegisterScheduledPublishing());
tasks.Add(RegisterLogScrubber(settings));
tasks.Add(RegisterLogScrubber(_loggingSettings));
tasks.Add(RegisterTempFileCleanup());
var healthCheckConfig = _healthChecksConfig;
@@ -132,11 +134,11 @@ namespace Umbraco.Web.Scheduling
});
}
private IBackgroundTask RegisterKeepAlive(IKeepAliveSection keepAliveSection)
private IBackgroundTask RegisterKeepAlive(IKeepAliveSettings keepAliveSettings)
{
// ping/keepalive
// on all servers
var task = new KeepAlive(_keepAliveRunner, DefaultDelayMilliseconds, FiveMinuteMilliseconds, _runtime, keepAliveSection, _logger);
var task = new KeepAlive(_keepAliveRunner, DefaultDelayMilliseconds, FiveMinuteMilliseconds, _runtime, keepAliveSettings, _logger);
_keepAliveRunner.TryAdd(task);
return task;
}
@@ -176,11 +178,11 @@ namespace Umbraco.Web.Scheduling
return task;
}
private IBackgroundTask RegisterLogScrubber(IUmbracoSettingsSection settings)
private IBackgroundTask RegisterLogScrubber(ILoggingSettings settings)
{
// log scrubbing
// install on all, will only run on non-replica servers
var task = new LogScrubber(_scrubberRunner, DefaultDelayMilliseconds, LogScrubber.GetLogScrubbingInterval(settings, _logger), _runtime, _auditService, settings, _scopeProvider, _logger);
var task = new LogScrubber(_scrubberRunner, DefaultDelayMilliseconds, LogScrubber.GetLogScrubbingInterval(), _runtime, _auditService, settings, _scopeProvider, _logger);
_scrubberRunner.TryAdd(task);
return task;
}
@@ -28,16 +28,16 @@ namespace Umbraco.Core.Services.Implement
private readonly ILocalizationService _localizationService;
private readonly INotificationsRepository _notificationsRepository;
private readonly IGlobalSettings _globalSettings;
private readonly IContentSection _contentSection;
private readonly IContentSettings _contentSettings;
private readonly ILogger _logger;
private readonly IIOHelper _ioHelper;
public NotificationService(IScopeProvider provider, IUserService userService, IContentService contentService, ILocalizationService localizationService,
ILogger logger, IIOHelper ioHelper, INotificationsRepository notificationsRepository, IGlobalSettings globalSettings, IContentSection contentSection)
ILogger logger, IIOHelper ioHelper, INotificationsRepository notificationsRepository, IGlobalSettings globalSettings, IContentSettings contentSettings)
{
_notificationsRepository = notificationsRepository;
_globalSettings = globalSettings;
_contentSection = contentSection;
_contentSettings = contentSettings;
_uowProvider = provider ?? throw new ArgumentNullException(nameof(provider));
_userService = userService ?? throw new ArgumentNullException(nameof(userService));
_contentService = contentService ?? throw new ArgumentNullException(nameof(contentService));
@@ -302,7 +302,7 @@ namespace Umbraco.Core.Services.Implement
if (content.ContentType.VariesByNothing())
{
if (!_contentSection.DisableHtmlEmail)
if (!_contentSettings.DisableHtmlEmail)
{
//create the HTML summary for invariant content
@@ -344,7 +344,7 @@ namespace Umbraco.Core.Services.Implement
{
//it's variant, so detect what cultures have changed
if (!_contentSection.DisableHtmlEmail)
if (!_contentSettings.DisableHtmlEmail)
{
//Create the HTML based summary (ul of culture names)
@@ -406,13 +406,13 @@ namespace Umbraco.Core.Services.Implement
summary.ToString());
// create the mail message
var mail = new MailMessage(_contentSection.NotificationEmailAddress, mailingUser.Email);
var mail = new MailMessage(_contentSettings.NotificationEmailAddress, mailingUser.Email);
// populate the message
mail.Subject = createSubject((mailingUser, subjectVars));
if (_contentSection.DisableHtmlEmail)
if (_contentSettings.DisableHtmlEmail)
{
mail.IsBodyHtml = false;
mail.Body = createBody((user: mailingUser, body: bodyVars, false));
@@ -57,7 +57,6 @@ namespace Umbraco.Tests.Cache.PublishedCache
_httpContextFactory = new FakeHttpContextFactory("~/Home");
var umbracoSettings = Factory.GetInstance<IUmbracoSettingsSection>();
var globalSettings = Factory.GetInstance<IGlobalSettings>();
var umbracoContextAccessor = Factory.GetInstance<IUmbracoContextAccessor>();
@@ -14,27 +14,27 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public override void DisableHtmlEmail()
{
Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail == false);
Assert.IsTrue(ContentSettings.DisableHtmlEmail == false);
}
[Test]
public override void Can_Set_Multiple()
{
Assert.IsTrue(SettingsSection.Content.Error404Collection.Count() == 1);
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).Culture == null);
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId == 1);
Assert.IsTrue(ContentSettings.Error404Collection.Count() == 1);
Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(0).Culture == null);
Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(0).ContentId == 1);
}
[Test]
public override void ImageAutoFillProperties()
{
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.Count() == 1);
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias == "umbracoFile");
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias == "umbracoWidth");
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias == "umbracoHeight");
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes");
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.Count() == 1);
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).Alias == "umbracoFile");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias == "umbracoWidth");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias == "umbracoHeight");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes");
Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension");
}
}
}
@@ -16,80 +16,80 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public void EmailAddress()
{
Assert.AreEqual(SettingsSection.Content.NotificationEmailAddress, "robot@umbraco.dk");
Assert.AreEqual(ContentSettings.NotificationEmailAddress, "robot@umbraco.dk");
}
[Test]
public virtual void DisableHtmlEmail()
{
Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail);
Assert.IsTrue(ContentSettings.DisableHtmlEmail);
}
[Test]
public virtual void Can_Set_Multiple()
{
Assert.AreEqual(SettingsSection.Content.Error404Collection.Count(), 3);
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).Culture, "default");
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId, 1047);
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentId);
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentKey);
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).Culture, "en-US");
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).ContentXPath, "$site/error [@name = 'error']");
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentId);
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentKey);
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).Culture, "en-UK");
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).ContentKey, new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentKey);
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentId);
Assert.AreEqual(ContentSettings.Error404Collection.Count(), 3);
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(0).Culture, "default");
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(0).ContentId, 1047);
Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(0).HasContentId);
Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(0).HasContentKey);
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(1).Culture, "en-US");
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(1).ContentXPath, "$site/error [@name = 'error']");
Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(1).HasContentId);
Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(1).HasContentKey);
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(2).Culture, "en-UK");
Assert.AreEqual(ContentSettings.Error404Collection.ElementAt(2).ContentKey, new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
Assert.IsTrue(ContentSettings.Error404Collection.ElementAt(2).HasContentKey);
Assert.IsFalse(ContentSettings.Error404Collection.ElementAt(2).HasContentId);
}
[Test]
public void ImageFileTypes()
{
Assert.IsTrue(SettingsSection.Content.ImageFileTypes.All(x => "jpeg,jpg,gif,bmp,png,tiff,tif".Split(',').Contains(x)));
Assert.IsTrue(ContentSettings.ImageFileTypes.All(x => "jpeg,jpg,gif,bmp,png,tiff,tif".Split(',').Contains(x)));
}
[Test]
public virtual void ImageAutoFillProperties()
{
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.Count(), 2);
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias, "umbracoFile");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias, "umbracoWidth");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias, "umbracoHeight");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias, "umbracoBytes");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias, "umbracoExtension");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).Alias, "umbracoFile2");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias, "umbracoWidth2");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias, "umbracoHeight2");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias, "umbracoBytes2");
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias, "umbracoExtension2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.Count(), 2);
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).Alias, "umbracoFile");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias, "umbracoWidth");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias, "umbracoHeight");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias, "umbracoBytes");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias, "umbracoExtension");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).Alias, "umbracoFile2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias, "umbracoWidth2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias, "umbracoHeight2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias, "umbracoBytes2");
Assert.AreEqual(ContentSettings.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias, "umbracoExtension2");
}
[Test]
public void PreviewBadge()
{
Assert.AreEqual(SettingsSection.Content.PreviewBadge, @"<div id=""umbracoPreviewBadge"" class=""umbraco-preview-badge""><span class=""umbraco-preview-badge__header"">Preview mode</span><a href=""{0}/preview/end?redir={1}"" class=""umbraco-preview-badge__end""><svg viewBox=""0 0 100 100"" xmlns=""http://www.w3.org/2000/svg""><title>Click to end</title><path d=""M5273.1 2400.1v-2c0-2.8-5-4-9.7-4s-9.7 1.3-9.7 4v2a7 7 0 002 4.9l5 4.9c.3.3.4.6.4 1v6.4c0 .4.2.7.6.8l2.9.9c.5.1 1-.2 1-.8v-7.2c0-.4.2-.7.4-1l5.1-5a7 7 0 002-4.9zm-9.7-.1c-4.8 0-7.4-1.3-7.5-1.8.1-.5 2.7-1.8 7.5-1.8s7.3 1.3 7.5 1.8c-.2.5-2.7 1.8-7.5 1.8z""/><path d=""M5268.4 2410.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1h-4.3zM5272.7 2413.7h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1zM5272.7 2417h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1 0-.5-.4-1-1-1z""/><path d=""M78.2 13l-8.7 11.7a32.5 32.5 0 11-51.9 25.8c0-10.3 4.7-19.7 12.9-25.8L21.8 13a47 47 0 1056.4 0z""/><path d=""M42.7 2.5h14.6v49.4H42.7z""/></svg></a></div><style type=""text/css"">.umbraco-preview-badge {{position: absolute;top: 1em;right: 1em;display: inline-flex;background: #1b264f;color: #fff;padding: 1em;font-size: 12px;z-index: 99999999;justify-content: center;align-items: center;box-shadow: 0 10px 50px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .16);line-height: 1;}}.umbraco-preview-badge__header {{font-weight: bold;}}.umbraco-preview-badge__end {{width: 3em;padding: 1em;margin: -1em -1em -1em 2em;display: flex;flex-shrink: 0;align-items: center;align-self: stretch;}}.umbraco-preview-badge__end:hover,.umbraco-preview-badge__end:focus {{background: #f5c1bc;}}.umbraco-preview-badge__end svg {{fill: #fff;width:1em;}}</style>");
Assert.AreEqual(ContentSettings.PreviewBadge, @"<div id=""umbracoPreviewBadge"" class=""umbraco-preview-badge""><span class=""umbraco-preview-badge__header"">Preview mode</span><a href=""{0}/preview/end?redir={1}"" class=""umbraco-preview-badge__end""><svg viewBox=""0 0 100 100"" xmlns=""http://www.w3.org/2000/svg""><title>Click to end</title><path d=""M5273.1 2400.1v-2c0-2.8-5-4-9.7-4s-9.7 1.3-9.7 4v2a7 7 0 002 4.9l5 4.9c.3.3.4.6.4 1v6.4c0 .4.2.7.6.8l2.9.9c.5.1 1-.2 1-.8v-7.2c0-.4.2-.7.4-1l5.1-5a7 7 0 002-4.9zm-9.7-.1c-4.8 0-7.4-1.3-7.5-1.8.1-.5 2.7-1.8 7.5-1.8s7.3 1.3 7.5 1.8c-.2.5-2.7 1.8-7.5 1.8z""/><path d=""M5268.4 2410.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1h-4.3zM5272.7 2413.7h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1zM5272.7 2417h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1 0-.5-.4-1-1-1z""/><path d=""M78.2 13l-8.7 11.7a32.5 32.5 0 11-51.9 25.8c0-10.3 4.7-19.7 12.9-25.8L21.8 13a47 47 0 1056.4 0z""/><path d=""M42.7 2.5h14.6v49.4H42.7z""/></svg></a></div><style type=""text/css"">.umbraco-preview-badge {{position: absolute;top: 1em;right: 1em;display: inline-flex;background: #1b264f;color: #fff;padding: 1em;font-size: 12px;z-index: 99999999;justify-content: center;align-items: center;box-shadow: 0 10px 50px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .16);line-height: 1;}}.umbraco-preview-badge__header {{font-weight: bold;}}.umbraco-preview-badge__end {{width: 3em;padding: 1em;margin: -1em -1em -1em 2em;display: flex;flex-shrink: 0;align-items: center;align-self: stretch;}}.umbraco-preview-badge__end:hover,.umbraco-preview-badge__end:focus {{background: #f5c1bc;}}.umbraco-preview-badge__end svg {{fill: #fff;width:1em;}}</style>");
}
[Test]
public void ResolveUrlsFromTextString()
{
Assert.IsFalse(SettingsSection.Content.ResolveUrlsFromTextString);
Assert.IsFalse(ContentSettings.ResolveUrlsFromTextString);
}
[Test]
public void MacroErrors()
{
Assert.AreEqual(SettingsSection.Content.MacroErrorBehaviour, MacroErrorBehaviour.Inline);
Assert.AreEqual(ContentSettings.MacroErrorBehaviour, MacroErrorBehaviour.Inline);
}
[Test]
public void DisallowedUploadFiles()
{
Assert.IsTrue(SettingsSection.Content.DisallowedUploadFiles.All(x => "ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd".Split(',').Contains(x)));
Assert.IsTrue(ContentSettings.DisallowedUploadFiles.All(x => "ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd".Split(',').Contains(x)));
}
[Test]
public void AllowedUploadFiles()
{
Assert.IsTrue(SettingsSection.Content.AllowedUploadFiles.All(x => "jpg,gif,png".Split(',').Contains(x)));
Assert.IsTrue(ContentSettings.AllowedUploadFiles.All(x => "jpg,gif,png".Split(',').Contains(x)));
}
[Test]
@@ -107,16 +107,16 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
TestingDefaults = false;
Debug.WriteLine("Extension being tested", extension);
Debug.WriteLine("AllowedUploadFiles: {0}", SettingsSection.Content.AllowedUploadFiles);
Debug.WriteLine("DisallowedUploadFiles: {0}", SettingsSection.Content.DisallowedUploadFiles);
Debug.WriteLine("AllowedUploadFiles: {0}", ContentSettings.AllowedUploadFiles);
Debug.WriteLine("DisallowedUploadFiles: {0}", ContentSettings.DisallowedUploadFiles);
var allowedContainsExtension = SettingsSection.Content.AllowedUploadFiles.Any(x => x.InvariantEquals(extension));
var disallowedContainsExtension = SettingsSection.Content.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension));
var allowedContainsExtension = ContentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension));
var disallowedContainsExtension = ContentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension));
Debug.WriteLine("AllowedContainsExtension: {0}", allowedContainsExtension);
Debug.WriteLine("DisallowedContainsExtension: {0}", disallowedContainsExtension);
Assert.AreEqual(SettingsSection.Content.IsFileAllowedForUpload(extension), expected);
Assert.AreEqual(ContentSettings.IsFileAllowedForUpload(extension), expected);
}
}
}
@@ -14,7 +14,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public override void MaxLogAge()
{
Assert.IsTrue(SettingsSection.Logging.MaxLogAge == -1);
Assert.IsTrue(LoggingSettings.MaxLogAge == -1);
}
}
}
@@ -6,11 +6,11 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[TestFixture]
public class LoggingElementTests : UmbracoSettingsTests
{
[Test]
public virtual void MaxLogAge()
{
Assert.IsTrue(SettingsSection.Logging.MaxLogAge == 1440);
Assert.IsTrue(LoggingSettings.MaxLogAge == 1440);
}
@@ -10,7 +10,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public void AddTrailingSlash()
{
Assert.IsTrue(SettingsSection.RequestHandler.AddTrailingSlash == true);
Assert.IsTrue(RequestHandlerSettings.AddTrailingSlash == true);
}
[Test]
@@ -18,14 +18,14 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
{
var chars = @" ,"",',%,.,;,/,\,:,#,+,*,&,?,æ,ø,å,ä,ö,ü,ß,Ä,Ö,|,<,>";
var items = chars.Split(',');
Assert.AreEqual(items.Length, SettingsSection.RequestHandler.CharCollection.Count());
Assert.IsTrue(SettingsSection.RequestHandler.CharCollection
Assert.AreEqual(items.Length, RequestHandlerSettings.CharCollection.Count());
Assert.IsTrue(RequestHandlerSettings.CharCollection
.All(x => items.Contains(x.Char)));
var vals = @"-,plus,star,ae,oe,aa,ae,oe,ue,ss,ae,oe,-";
var splitVals = vals.Split(',');
Assert.AreEqual(splitVals.Length, SettingsSection.RequestHandler.CharCollection.Count(x => x.Replacement.IsNullOrWhiteSpace() == false));
Assert.IsTrue(SettingsSection.RequestHandler.CharCollection
Assert.AreEqual(splitVals.Length, RequestHandlerSettings.CharCollection.Count(x => x.Replacement.IsNullOrWhiteSpace() == false));
Assert.IsTrue(RequestHandlerSettings.CharCollection
.All(x => string.IsNullOrEmpty(x.Replacement) || vals.Split(',').Contains(x.Replacement)));
}
@@ -9,127 +9,127 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public void KeepUserLoggedIn()
{
Assert.IsTrue(SettingsSection.Security.KeepUserLoggedIn == true);
Assert.IsTrue(SecuritySettings.KeepUserLoggedIn == true);
}
[Test]
public void HideDisabledUsersInBackoffice()
{
Assert.IsTrue(SettingsSection.Security.HideDisabledUsersInBackoffice == false);
Assert.IsTrue(SecuritySettings.HideDisabledUsersInBackoffice == false);
}
[Test]
public void AllowPasswordReset()
{
Assert.IsTrue(SettingsSection.Security.AllowPasswordReset == true);
Assert.IsTrue(SecuritySettings.AllowPasswordReset == true);
}
[Test]
public void AuthCookieDomain()
{
Assert.IsTrue(SettingsSection.Security.AuthCookieDomain == null);
Assert.IsTrue(SecuritySettings.AuthCookieDomain == null);
}
[Test]
public void AuthCookieName()
{
Assert.IsTrue(SettingsSection.Security.AuthCookieName == "UMB_UCONTEXT");
Assert.IsTrue(SecuritySettings.AuthCookieName == "UMB_UCONTEXT");
}
[Test]
public void UserPasswordConfiguration_RequiredLength()
{
Assert.IsTrue(SettingsSection.Security.UserPasswordConfiguration.RequiredLength == 12);
Assert.IsTrue(UserPasswordConfiguration.RequiredLength == 12);
}
[Test]
public void UserPasswordConfiguration_RequireNonLetterOrDigit()
{
Assert.IsTrue(SettingsSection.Security.UserPasswordConfiguration.RequireNonLetterOrDigit == false);
Assert.IsTrue(UserPasswordConfiguration.RequireNonLetterOrDigit == false);
}
[Test]
public void UserPasswordConfiguration_RequireDigit()
{
Assert.IsTrue(SettingsSection.Security.UserPasswordConfiguration.RequireDigit == false);
Assert.IsTrue(UserPasswordConfiguration.RequireDigit == false);
}
[Test]
public void UserPasswordConfiguration_RequireLowercase()
{
Assert.IsTrue(SettingsSection.Security.UserPasswordConfiguration.RequireLowercase == false);
Assert.IsTrue(UserPasswordConfiguration.RequireLowercase == false);
}
[Test]
public void UserPasswordConfiguration_RequireUppercase()
{
Assert.IsTrue(SettingsSection.Security.UserPasswordConfiguration.RequireUppercase == false);
Assert.IsTrue(UserPasswordConfiguration.RequireUppercase == false);
}
[Test]
public void UserPasswordConfiguration_UseLegacyEncoding()
{
Assert.IsTrue(SettingsSection.Security.UserPasswordConfiguration.UseLegacyEncoding == false);
Assert.IsTrue(UserPasswordConfiguration.UseLegacyEncoding == false);
}
[Test]
public void UserPasswordConfiguration_HashAlgorithmType()
{
Assert.IsTrue(SettingsSection.Security.UserPasswordConfiguration.HashAlgorithmType == "HMACSHA256");
Assert.IsTrue(UserPasswordConfiguration.HashAlgorithmType == "HMACSHA256");
}
[Test]
public void UserPasswordConfiguration_MaxFailedAccessAttemptsBeforeLockout()
{
Assert.IsTrue(SettingsSection.Security.UserPasswordConfiguration.MaxFailedAccessAttemptsBeforeLockout == 5);
Assert.IsTrue(UserPasswordConfiguration.MaxFailedAccessAttemptsBeforeLockout == 5);
}
[Test]
public void MemberPasswordConfiguration_RequiredLength()
{
Assert.IsTrue(SettingsSection.Security.MemberPasswordConfiguration.RequiredLength == 12);
Assert.IsTrue(MemberPasswordConfiguration.RequiredLength == 12);
}
[Test]
public void MemberPasswordConfiguration_RequireNonLetterOrDigit()
{
Assert.IsTrue(SettingsSection.Security.MemberPasswordConfiguration.RequireNonLetterOrDigit == false);
Assert.IsTrue(MemberPasswordConfiguration.RequireNonLetterOrDigit == false);
}
[Test]
public void MemberPasswordConfiguration_RequireDigit()
{
Assert.IsTrue(SettingsSection.Security.MemberPasswordConfiguration.RequireDigit == false);
Assert.IsTrue(MemberPasswordConfiguration.RequireDigit == false);
}
[Test]
public void MemberPasswordConfiguration_RequireLowercase()
{
Assert.IsTrue(SettingsSection.Security.MemberPasswordConfiguration.RequireLowercase == false);
Assert.IsTrue(MemberPasswordConfiguration.RequireLowercase == false);
}
[Test]
public void MemberPasswordConfiguration_RequireUppercase()
{
Assert.IsTrue(SettingsSection.Security.MemberPasswordConfiguration.RequireUppercase == false);
Assert.IsTrue(MemberPasswordConfiguration.RequireUppercase == false);
}
[Test]
public void MemberPasswordConfiguration_UseLegacyEncoding()
{
Assert.IsTrue(SettingsSection.Security.MemberPasswordConfiguration.UseLegacyEncoding == false);
Assert.IsTrue(MemberPasswordConfiguration.UseLegacyEncoding == false);
}
[Test]
public void MemberPasswordConfiguration_HashAlgorithmType()
{
Assert.IsTrue(SettingsSection.Security.MemberPasswordConfiguration.HashAlgorithmType == "HMACSHA256");
Assert.IsTrue(MemberPasswordConfiguration.HashAlgorithmType == "HMACSHA256");
}
[Test]
public void MemberPasswordConfiguration_MaxFailedAccessAttemptsBeforeLockout()
{
Assert.IsTrue(SettingsSection.Security.MemberPasswordConfiguration.MaxFailedAccessAttemptsBeforeLockout == 5);
Assert.IsTrue(MemberPasswordConfiguration.MaxFailedAccessAttemptsBeforeLockout == 5);
}
}
}
@@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using NUnit.Framework;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Tests.TestHelpers;
@@ -22,16 +23,23 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
Debug.WriteLine("Testing defaults? {0}", TestingDefaults);
if (TestingDefaults)
{
SettingsSection = configuration.GetSection("umbracoConfiguration/defaultSettings") as UmbracoSettingsSection;
Settings = configuration.GetSection("umbracoConfiguration/defaultSettings") as UmbracoSettingsSection;
}
else
{
SettingsSection = configuration.GetSection("umbracoConfiguration/settings") as UmbracoSettingsSection;
Settings = configuration.GetSection("umbracoConfiguration/settings") as UmbracoSettingsSection;
}
Assert.IsNotNull(SettingsSection);
Assert.IsNotNull(Settings);
}
private UmbracoSettingsSection Settings { get; set; }
protected IUmbracoSettingsSection SettingsSection { get; private set; }
protected ILoggingSettings LoggingSettings => Settings.Logging;
protected IWebRoutingSettings WebRoutingSettings => Settings.WebRouting;
protected IRequestHandlerSettings RequestHandlerSettings => Settings.RequestHandler;
protected ISecuritySettings SecuritySettings => Settings.Security;
protected IUserPasswordConfiguration UserPasswordConfiguration => Settings.Security.UserPasswordConfiguration;
protected IMemberPasswordConfiguration MemberPasswordConfiguration => Settings.Security.MemberPasswordConfiguration;
protected IContentSettings ContentSettings => Settings.Content;
}
}
@@ -14,31 +14,31 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public override void UrlProviderMode()
{
Assert.IsTrue(SettingsSection.WebRouting.UrlProviderMode == "Auto");
Assert.IsTrue(WebRoutingSettings.UrlProviderMode == "Auto");
}
[Test]
public void DisableAlternativeTemplates()
{
Assert.IsTrue(SettingsSection.WebRouting.DisableAlternativeTemplates == false);
Assert.IsTrue(WebRoutingSettings.DisableAlternativeTemplates == false);
}
[Test]
public void ValidateAlternativeTemplates()
{
Assert.IsTrue(SettingsSection.WebRouting.ValidateAlternativeTemplates == false);
Assert.IsTrue(WebRoutingSettings.ValidateAlternativeTemplates == false);
}
[Test]
public void DisableFindContentByIdPath()
{
Assert.IsTrue(SettingsSection.WebRouting.DisableFindContentByIdPath == false);
Assert.IsTrue(WebRoutingSettings.DisableFindContentByIdPath == false);
}
[Test]
public void DisableRedirectUrlTracking()
{
Assert.IsTrue(SettingsSection.WebRouting.DisableRedirectUrlTracking == false);
Assert.IsTrue(WebRoutingSettings.DisableRedirectUrlTracking == false);
}
}
}
@@ -8,19 +8,19 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public void TrySkipIisCustomErrors()
{
Assert.IsTrue(SettingsSection.WebRouting.TrySkipIisCustomErrors == false);
Assert.IsTrue(WebRoutingSettings.TrySkipIisCustomErrors == false);
}
[Test]
public void InternalRedirectPreservesTemplate()
{
Assert.IsTrue(SettingsSection.WebRouting.InternalRedirectPreservesTemplate == false);
Assert.IsTrue(WebRoutingSettings.InternalRedirectPreservesTemplate == false);
}
[Test]
public virtual void UrlProviderMode()
{
Assert.IsTrue(SettingsSection.WebRouting.UrlProviderMode == "Auto");
Assert.IsTrue(WebRoutingSettings.UrlProviderMode == "Auto");
}
}
}
@@ -14,7 +14,7 @@ namespace Umbraco.Tests.CoreThings
{
base.Compose();
Composition.RegisterUnique<IShortStringHelper>(f => new DefaultShortStringHelper(f.GetInstance<IUmbracoSettingsSection>()));
Composition.RegisterUnique<IShortStringHelper>(f => new DefaultShortStringHelper(f.GetInstance<IRequestHandlerSettings>()));
}
[Test]
+3 -3
View File
@@ -34,18 +34,18 @@ namespace Umbraco.Tests.IO
composition.Register(_ => Mock.Of<ILogger>());
composition.Register(_ => Mock.Of<IDataTypeService>());
composition.Register(_ => Mock.Of<IContentSection>());
composition.Register(_ => Mock.Of<IContentSettings>());
composition.Register(_ => TestHelper.ShortStringHelper);
composition.Register(_ => TestHelper.IOHelper);
composition.RegisterUnique<IMediaPathScheme, UniqueMediaPathScheme>();
composition.RegisterUnique(TestHelper.IOHelper);
composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings);
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
composition.ComposeFileSystems();
composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
_factory = composition.CreateFactory();
+3 -3
View File
@@ -77,15 +77,15 @@ namespace Umbraco.Tests.Misc
{
var globalConfig = Mock.Get(SettingsForTests.GenerateMockGlobalSettings());
var settings = SettingsForTests.GenerateMockUmbracoSettings();
var requestMock = Mock.Get(settings.RequestHandler);
var settings = SettingsForTests.GenerateMockRequestHandlerSettings();
var requestMock = Mock.Get(settings);
requestMock.Setup(x => x.AddTrailingSlash).Returns(trailingSlash);
UriUtility.SetAppDomainAppVirtualPath("/");
var expectedUri = NewUri(expectedUrl);
var sourceUri = NewUri(sourceUrl);
var resultUri = UriUtility.UriFromUmbraco(sourceUri, globalConfig.Object, settings.RequestHandler);
var resultUri = UriUtility.UriFromUmbraco(sourceUri, globalConfig.Object, settings);
Assert.AreEqual(expectedUri.ToString(), resultUri.ToString());
}
@@ -29,7 +29,7 @@ namespace Umbraco.Tests.Models
Composition.ComposeFileSystems();
Composition.Register(_ => Mock.Of<IDataTypeService>());
Composition.Register(_ => Mock.Of<IContentSection>());
Composition.Register(_ => Mock.Of<IContentSettings>());
// all this is required so we can validate properties...
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), IOHelper, ShortStringHelper, LocalizedTextService) { Alias = "test" };
+1 -1
View File
@@ -39,7 +39,7 @@ namespace Umbraco.Tests.Models
Composition.ComposeFileSystems();
Composition.Register(_ => Mock.Of<IDataTypeService>());
Composition.Register(_ => Mock.Of<IContentSection>());
Composition.Register(_ => Mock.Of<IContentSettings>());
// all this is required so we can validate properties...
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), IOHelper, ShortStringHelper, LocalizedTextService) { Alias = "test" };
@@ -34,7 +34,7 @@ namespace Umbraco.Tests.Models.Mapping
Composition.ComposeFileSystems();
Composition.Register(_ => Mock.Of<IDataTypeService>());
Composition.Register(_ => Mock.Of<IContentSection>());
Composition.Register(_ => Mock.Of<IContentSettings>());
// all this is required so we can validate properties...
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), IOHelper, ShortStringHelper, LocalizedTextService) { Alias = "test" };
+2 -5
View File
@@ -31,13 +31,10 @@ namespace Umbraco.Tests.Models
// and then, this will reset the width, height... because the file does not exist, of course ;-(
var logger = Mock.Of<ILogger>();
var scheme = Mock.Of<IMediaPathScheme>();
var config = Mock.Of<IContentSection>();
var dataTypeService = Mock.Of<IDataTypeService>();
var localizationService = Mock.Of<ILocalizationService>();
var umbracoSettingsSection = TestObjects.GetUmbracoSettings();
var config = Mock.Of<IContentSettings>();
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, ShortStringHelper);
var ignored = new FileUploadPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, config, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, umbracoSettingsSection);
var ignored = new FileUploadPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, config, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper);
var media = MockedMedia.CreateMediaImage(mediaType, -1);
media.WriterId = -1; // else it's zero and that's not a user and it breaks the tests
+1 -1
View File
@@ -35,7 +35,7 @@ namespace Umbraco.Tests.Models
var configs = TestHelper.GetConfigs();
configs.Add(SettingsForTests.GetDefaultGlobalSettings);
configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
configs.Add(SettingsForTests.GenerateMockContentSettings);
_factory = Mock.Of<IFactory>();
@@ -85,10 +85,8 @@ namespace Umbraco.Tests.PropertyEditors
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, shortStringHelper);
var umbracoSettingsSection = Mock.Of<IUmbracoSettingsSection>();
var dataTypeService = new TestObjects.TestDataTypeService(
new DataType(new ImageCropperPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, Mock.Of<IContentSection>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), TestHelper.IOHelper, TestHelper.ShortStringHelper, Mock.Of<ILocalizedTextService>(), umbracoSettingsSection)) { Id = 1 });
new DataType(new ImageCropperPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, Mock.Of<IContentSettings>(), Mock.Of<IDataTypeService>(), Mock.Of<ILocalizationService>(), TestHelper.IOHelper, TestHelper.ShortStringHelper, Mock.Of<ILocalizedTextService>())) { Id = 1 });
var factory = new PublishedContentTypeFactory(Mock.Of<IPublishedModelFactory>(), new PropertyValueConverterCollection(Array.Empty<IPropertyValueConverter>()), dataTypeService);
@@ -28,7 +28,7 @@ namespace Umbraco.Tests.PropertyEditors
var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of<IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
register.Register<IShortStringHelper>(_
=> new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(SettingsForTests.GetDefaultUmbracoSettings())));
=> new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(SettingsForTests.GenerateMockRequestHandlerSettings())));
Current.Factory = composition.CreateFactory();
}
@@ -63,7 +63,7 @@ namespace Umbraco.Tests.PublishedContent
Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs);
var globalSettings = new GlobalSettings(TestHelper.IOHelper);
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
configs.Add(SettingsForTests.GenerateMockContentSettings);
configs.Add<IGlobalSettings>(() => globalSettings);
Mock.Get(factory).Setup(x => x.GetInstance(typeof(IPublishedModelFactory))).Returns(PublishedModelFactory);
@@ -55,7 +55,7 @@ namespace Umbraco.Tests.PublishedContent
var configs = TestHelper.GetConfigs();
Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs);
var globalSettings = new GlobalSettings(TestHelper.IOHelper);
configs.Add(SettingsForTests.GenerateMockUmbracoSettings);
configs.Add(SettingsForTests.GenerateMockContentSettings);
configs.Add<IGlobalSettings>(() => globalSettings);
var publishedModelFactory = new NoopPublishedModelFactory();
@@ -18,7 +18,7 @@ namespace Umbraco.Tests.Routing
var umbracoContext = GetUmbracoContext(urlAsString);
var publishedRouter = CreatePublishedRouter();
var frequest = publishedRouter.CreateRequest(umbracoContext);
var lookup = new ContentFinderByIdPath(Factory.GetInstance<IUmbracoSettingsSection>().WebRouting, Logger, Factory.GetInstance<IRequestAccessor>());
var lookup = new ContentFinderByIdPath(SettingsForTests.GenerateMockWebRoutingSettings(), Logger, Factory.GetInstance<IRequestAccessor>());
var result = lookup.TryFindContent(frequest);
@@ -38,7 +38,7 @@ namespace Umbraco.Tests.Routing
var umbracoContext = GetUmbracoContext(urlAsString, template1.Id, globalSettings:globalSettings.Object);
var publishedRouter = CreatePublishedRouter();
var frequest = publishedRouter.CreateRequest(umbracoContext);
var lookup = new ContentFinderByUrlAndTemplate(Logger, ServiceContext.FileService, TestObjects.GetUmbracoSettings(), ServiceContext.ContentTypeService);
var lookup = new ContentFinderByUrlAndTemplate(Logger, ServiceContext.FileService, ServiceContext.ContentTypeService, SettingsForTests.GenerateMockWebRoutingSettings());
var result = lookup.TryFindContent(frequest);
@@ -77,15 +77,15 @@ namespace Umbraco.Tests.Routing
content.Path = "-1,1046";
content.Published = true;
var umbracoSettings = Current.Configs.Settings();
var umbracoSettings = Current.Configs.RequestHandler();
var umbContext = GetUmbracoContext("http://localhost:8000");
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbContext);
var urlProvider = new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper(),
var urlProvider = new DefaultUrlProvider(umbracoSettings, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper(),
umbracoContextAccessor, UriUtility);
var publishedUrlProvider = new UrlProvider(
umbracoContextAccessor,
TestHelper.WebRoutingSection,
TestHelper.WebRoutingSettings,
new UrlProviderCollection(new []{urlProvider}),
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
Mock.Of<IVariationContextAccessor>()
@@ -122,15 +122,15 @@ namespace Umbraco.Tests.Routing
child.Path = "-1,1046,1173";
child.Published = true;
var umbracoSettings = Current.Configs.Settings();
var umbracoSettings = Current.Configs.RequestHandler();
var umbContext = GetUmbracoContext("http://localhost:8000");
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbContext);
var urlProvider = new DefaultUrlProvider(umbracoSettings.RequestHandler, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper(), umbracoContextAccessor, UriUtility);
var urlProvider = new DefaultUrlProvider(umbracoSettings, Logger, TestObjects.GetGlobalSettings(), new SiteDomainHelper(), umbracoContextAccessor, UriUtility);
var publishedUrlProvider = new UrlProvider(
umbracoContextAccessor,
TestHelper.WebRoutingSection,
TestHelper.WebRoutingSettings,
new UrlProviderCollection(new []{urlProvider}),
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
Mock.Of<IVariationContextAccessor>()
@@ -34,14 +34,12 @@ namespace Umbraco.Tests.Routing
var logger = Mock.Of<ILogger>();
var mediaFileSystemMock = Mock.Of<IMediaFileSystem>();
var contentSection = Mock.Of<IContentSection>();
var contentSection = Mock.Of<IContentSettings>();
var dataTypeService = Mock.Of<IDataTypeService>();
var umbracoSettingsSection = TestObjects.GetUmbracoSettings();
var propertyEditors = new MediaUrlGeneratorCollection(new IMediaUrlGenerator[]
{
new FileUploadPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, umbracoSettingsSection),
new ImageCropperPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService, umbracoSettingsSection),
new FileUploadPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper),
new ImageCropperPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService),
});
_mediaUrlProvider = new DefaultMediaUrlProvider(propertyEditors, UriUtility);
}
@@ -153,7 +151,7 @@ namespace Umbraco.Tests.Routing
{
return new UrlProvider(
new TestUmbracoContextAccessor(umbracoContext),
TestHelper.WebRoutingSection,
TestHelper.WebRoutingSettings,
new UrlProviderCollection(Enumerable.Empty<IUrlProvider>()),
new MediaUrlProviderCollection(new []{_mediaUrlProvider}),
Mock.Of<IVariationContextAccessor>()

Some files were not shown because too many files have changed in this diff Show More