diff --git a/NuGet.Config b/NuGet.Config
index 64425091dc..d6c63173f8 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -8,5 +8,6 @@
+
diff --git a/src/Umbraco.Core/CompositionExtensions.cs b/src/Umbraco.Core/CompositionExtensions.cs
index 5b9abeeb45..218e2a04e3 100644
--- a/src/Umbraco.Core/CompositionExtensions.cs
+++ b/src/Umbraco.Core/CompositionExtensions.cs
@@ -1,11 +1,11 @@
using Umbraco.Core.Composing;
+using Umbraco.Core.HealthCheck;
using Umbraco.Core.Manifest;
using Umbraco.Core.PropertyEditors;
using Umbraco.Web.Actions;
using Umbraco.Web.ContentApps;
using Umbraco.Web.Dashboards;
using Umbraco.Web.Editors;
-using Umbraco.Web.HealthCheck;
using Umbraco.Web.Routing;
using Umbraco.Web.Sections;
using Umbraco.Web.Tour;
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/AbstractConfigCheck.cs b/src/Umbraco.Core/Configuration/HealthChecks/AbstractConfigCheck.cs
deleted file mode 100644
index f3452131f0..0000000000
--- a/src/Umbraco.Core/Configuration/HealthChecks/AbstractConfigCheck.cs
+++ /dev/null
@@ -1,234 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using Microsoft.Extensions.Logging;
-using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
-using Umbraco.Core.Logging;
-using Umbraco.Core.Services;
-
-namespace Umbraco.Web.HealthCheck.Checks.Config
-{
- public abstract class AbstractConfigCheck : HealthCheck
- {
- private readonly IHostingEnvironment _hostingEnvironment;
- private readonly ConfigurationService _configurationService;
-
- protected ILocalizedTextService TextService { get; }
- protected ILoggerFactory LoggerFactory { get; }
-
- ///
- /// Gets the config file path.
- ///
- public abstract string FilePath { get; }
-
- ///
- /// Gets XPath statement to the config element to check.
- ///
- public abstract string XPath { get; }
-
- ///
- /// Gets the values to compare against.
- ///
- public abstract IEnumerable Values { get; }
-
- ///
- /// Gets the current value
- ///
- public string CurrentValue { get; set; }
-
- ///
- /// Gets the provided value
- ///
- public string ProvidedValue { get; set; }
-
- ///
- /// Gets the comparison type for checking the value.
- ///
- public abstract ValueComparisonType ValueComparisonType { get; }
-
- ///
- /// Gets the flag indicating if the check is considered successful if the config value is missing (defaults to false - an error - if missing)
- ///
- public virtual bool ValidIfConfigMissing
- {
- get { return false; }
- }
-
- protected AbstractConfigCheck(ILocalizedTextService textService, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory)
- {
- _hostingEnvironment = hostingEnvironment;
- TextService = textService;
- LoggerFactory = loggerFactory;
- _configurationService = new ConfigurationService(AbsoluteFilePath, XPath, textService, loggerFactory.CreateLogger());
- }
-
- ///
- /// Gets the name of the file.
- ///
- private string FileName => Path.GetFileName(FilePath);
-
- ///
- /// Gets the absolute file path.
- ///
- private string AbsoluteFilePath => _hostingEnvironment.MapPathContentRoot(FilePath);
-
- ///
- /// Gets the message for when the check has succeeded.
- ///
- public virtual string CheckSuccessMessage
- {
- get
- {
- return TextService.Localize("healthcheck/checkSuccessMessage",
- new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, XPath, AbsoluteFilePath });
- }
- }
-
- ///
- /// Gets the message for when the check has failed.
- ///
- public virtual string CheckErrorMessage
- {
- get
- {
- return ValueComparisonType == ValueComparisonType.ShouldEqual
- ? TextService.Localize("healthcheck/checkErrorMessageDifferentExpectedValue",
- new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, XPath, AbsoluteFilePath })
- : TextService.Localize("healthcheck/checkErrorMessageUnexpectedValue",
- new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, XPath, AbsoluteFilePath });
- }
- }
-
- ///
- /// Gets the rectify success message.
- ///
- public virtual string RectifySuccessMessage
- {
- get
- {
- var recommendedValue = Values.FirstOrDefault(v => v.IsRecommended);
- var rectifiedValue = recommendedValue != null
- ? recommendedValue.Value
- : ProvidedValue;
- return TextService.Localize("healthcheck/rectifySuccessMessage",
- new[]
- {
- CurrentValue,
- rectifiedValue,
- XPath,
- AbsoluteFilePath
- });
- }
- }
-
- ///
- /// Gets a value indicating whether this check can be rectified automatically.
- ///
- public virtual bool CanRectify => ValueComparisonType == ValueComparisonType.ShouldEqual;
-
- ///
- /// Gets a value indicating whether this check can be rectified automatically if a value is provided.
- ///
- public virtual bool CanRectifyWithValue => ValueComparisonType == ValueComparisonType.ShouldNotEqual;
-
- public override IEnumerable GetStatus()
- {
- var successMessage = string.Format(CheckSuccessMessage, FileName, XPath, Values);
-
- var configValue = _configurationService.GetConfigurationValue();
- if (configValue.Success == false)
- {
- if (ValidIfConfigMissing)
- {
- return new[] { new HealthCheckStatus(successMessage) { ResultType = StatusResultType.Success } };
- }
-
- var errorMessage = configValue.Result;
- return new[] { new HealthCheckStatus(errorMessage) { ResultType = StatusResultType.Error } };
- }
-
- CurrentValue = configValue.Result;
-
- // need to update the successMessage with the CurrentValue
- successMessage = string.Format(CheckSuccessMessage, FileName, XPath, Values, CurrentValue);
-
- var valueFound = Values.Any(value => string.Equals(CurrentValue, value.Value, StringComparison.InvariantCultureIgnoreCase));
- if (ValueComparisonType == ValueComparisonType.ShouldEqual && valueFound || ValueComparisonType == ValueComparisonType.ShouldNotEqual && valueFound == false)
- {
- return new[] { new HealthCheckStatus(successMessage) { ResultType = StatusResultType.Success } };
- }
-
- // Declare the action for rectifying the config value
- var rectifyAction = new HealthCheckAction("rectify", Id)
- {
- Name = TextService.Localize("healthcheck/rectifyButton"),
- ValueRequired = CanRectifyWithValue,
- };
-
- var resultMessage = string.Format(CheckErrorMessage, FileName, XPath, Values, CurrentValue);
- return new[]
- {
- new HealthCheckStatus(resultMessage)
- {
- ResultType = StatusResultType.Error,
- Actions = CanRectify || CanRectifyWithValue ? new[] { rectifyAction } : new HealthCheckAction[0]
- }
- };
- }
-
- ///
- /// Rectifies this check.
- ///
- ///
- public virtual HealthCheckStatus Rectify()
- {
- if (ValueComparisonType == ValueComparisonType.ShouldNotEqual)
- throw new InvalidOperationException(TextService.Localize("healthcheck/cannotRectifyShouldNotEqual"));
-
- var recommendedValue = Values.First(v => v.IsRecommended).Value;
- return UpdateConfigurationValue(recommendedValue);
- }
-
- ///
- /// Rectifies this check with a provided value.
- ///
- /// Value provided
- ///
- public virtual HealthCheckStatus Rectify(string value)
- {
- if (ValueComparisonType == ValueComparisonType.ShouldEqual)
- throw new InvalidOperationException(TextService.Localize("healthcheck/cannotRectifyShouldEqualWithValue"));
-
- if (string.IsNullOrWhiteSpace(value))
- throw new InvalidOperationException(TextService.Localize("healthcheck/valueToRectifyNotProvided"));
-
- // Need to track provided value in order to correctly put together the rectify message
- ProvidedValue = value;
-
- return UpdateConfigurationValue(value);
- }
-
- private HealthCheckStatus UpdateConfigurationValue(string value)
- {
- var updateConfigFile = _configurationService.UpdateConfigFile(value);
-
- if (updateConfigFile.Success == false)
- {
- var message = updateConfigFile.Result;
- return new HealthCheckStatus(message) { ResultType = StatusResultType.Error };
- }
-
- var resultMessage = string.Format(RectifySuccessMessage, FileName, XPath, Values);
- return new HealthCheckStatus(resultMessage) { ResultType = StatusResultType.Success };
- }
-
- public override HealthCheckStatus ExecuteAction(HealthCheckAction action)
- {
- return string.IsNullOrEmpty(action.ProvidedValue)
- ? Rectify()
- : Rectify(action.ProvidedValue);
- }
- }
-}
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/CompilationDebugCheck.cs b/src/Umbraco.Core/Configuration/HealthChecks/CompilationDebugCheck.cs
index b400093a34..a7b99ea205 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/CompilationDebugCheck.cs
+++ b/src/Umbraco.Core/Configuration/HealthChecks/CompilationDebugCheck.cs
@@ -1,33 +1,41 @@
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
-using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
+using Microsoft.Extensions.Options;
+using Umbraco.Core.Configuration.Models;
+using Umbraco.Core.HealthCheck;
+using Umbraco.Core.HealthCheck.Checks;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.Configuration.HealthChecks
{
[HealthCheck("61214FF3-FC57-4B31-B5CF-1D095C977D6D", "Debug Compilation Mode",
Description = "Leaving debug compilation mode enabled can severely slow down a website and take up more memory on the server.",
Group = "Live Environment")]
- public class CompilationDebugCheck : AbstractConfigCheck
+ public class CompilationDebugCheck : AbstractSettingsCheck
{
- public CompilationDebugCheck(ILocalizedTextService textService, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory)
- : base(textService, hostingEnvironment, loggerFactory)
- { }
+ private readonly IOptionsMonitor _hostingSettings;
- public override string FilePath => "~/Web.config";
+ public CompilationDebugCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory, IOptionsMonitor hostingSettings)
+ : base(textService, loggerFactory)
+ {
+ _hostingSettings = hostingSettings;
+ }
- public override string XPath => "/configuration/system.web/compilation/@debug";
+ public override string ItemPath => Constants.Configuration.ConfigHostingDebug;
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
- public override bool ValidIfConfigMissing => true;
-
public override IEnumerable Values => new List
{
- new AcceptableConfiguration { IsRecommended = true, Value = bool.FalseString.ToLower() }
+ new AcceptableConfiguration
+ {
+ IsRecommended = true,
+ Value = bool.FalseString.ToLower()
+ }
};
+ public override string CurrentValue => _hostingSettings.CurrentValue.Debug.ToString();
+
public override string CheckSuccessMessage => TextService.Localize("healthcheck/compilationDebugCheckSuccessMessage");
public override string CheckErrorMessage => TextService.Localize("healthcheck/compilationDebugCheckErrorMessage");
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/ConfigurationService.cs b/src/Umbraco.Core/Configuration/HealthChecks/ConfigurationService.cs
index 396d55b735..2459698b7a 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/ConfigurationService.cs
+++ b/src/Umbraco.Core/Configuration/HealthChecks/ConfigurationService.cs
@@ -1,109 +1,61 @@
using System;
-using System.IO;
-using System.Xml;
using Microsoft.Extensions.Logging;
+using Umbraco.Core.HealthCheck;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.Configuration.HealthChecks
{
- // TODO: Add config transform for when config with specified XPath is not found
-
- public class ConfigurationService
+ public class ConfigurationService : IConfigurationService
{
- private readonly string _configFilePath;
- private readonly string _xPath;
private readonly ILocalizedTextService _textService;
private readonly ILogger _logger;
+ private readonly IConfigManipulator _configManipulator;
- /// The absolute file location of the configuration file
- /// The XPath to select the value
///
///
+ ///
///
- public ConfigurationService(string configFilePath, string xPath, ILocalizedTextService textService, ILogger logger)
+ public ConfigurationService(ILocalizedTextService textService, ILogger logger, IConfigManipulator configManipulator)
{
- _configFilePath = configFilePath;
- _xPath = xPath;
+ if (textService == null) HandleNullParameter(nameof(textService));
+ if (configManipulator == null) HandleNullParameter(nameof(configManipulator));
+ if (logger == null) HandleNullParameter(nameof(logger));
+
+ _configManipulator = configManipulator;
_textService = textService;
_logger = logger;
}
- ///
- /// Gets a value from a given configuration file with the given XPath
- ///
- public ConfigurationServiceResult GetConfigurationValue()
+ private void HandleNullParameter(string parameter)
{
- try
- {
- if (File.Exists(_configFilePath) == false)
- return new ConfigurationServiceResult
- {
- Success = false,
- Result = _textService.Localize("healthcheck/configurationServiceFileNotFound", new[] { _configFilePath })
- };
-
- var xmlDocument = new XmlDocument();
- xmlDocument.Load(_configFilePath);
-
- var xmlNode = xmlDocument.SelectSingleNode(_xPath);
- if (xmlNode == null)
- return new ConfigurationServiceResult
- {
- Success = false,
- Result = _textService.Localize("healthcheck/configurationServiceNodeNotFound", new[] { _xPath, _configFilePath })
- };
-
- return new ConfigurationServiceResult
- {
- Success = true,
- Result = string.Format(xmlNode.Value ?? xmlNode.InnerText)
- };
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error trying to get configuration value");
- return new ConfigurationServiceResult
- {
- Success = false,
- Result = _textService.Localize("healthcheck/configurationServiceError", new[] { ex.Message })
- };
- }
+ _logger.LogError("Error trying to get configuration value", parameter);
+ throw new ArgumentNullException(parameter);
}
///
- /// Updates a value in a given configuration file with the given XPath
+ /// Updates a value in a given configuration file with the given path
///
///
+ ///
///
- public ConfigurationServiceResult UpdateConfigFile(string value)
+ public ConfigurationServiceResult UpdateConfigFile(string value, string itemPath)
{
try
{
- if (File.Exists(_configFilePath) == false)
+ if (itemPath == null)
+ {
return new ConfigurationServiceResult
{
Success = false,
- Result = _textService.Localize("healthcheck/configurationServiceFileNotFound", new[] { _configFilePath })
+ Result = _textService.Localize("healthcheck/configurationServiceNodeNotFound", new[] { itemPath, value })
};
+ }
- var xmlDocument = new XmlDocument { PreserveWhitespace = true };
- xmlDocument.Load(_configFilePath);
-
- var node = xmlDocument.SelectSingleNode(_xPath);
- if (node == null)
- return new ConfigurationServiceResult
- {
- Success = false,
- Result = _textService.Localize("healthcheck/configurationServiceNodeNotFound", new[] { _xPath, _configFilePath })
- };
-
- if (node.NodeType == XmlNodeType.Element)
- node.InnerText = value;
- else
- node.Value = value;
-
- xmlDocument.Save(_configFilePath);
- return new ConfigurationServiceResult { Success = true };
+ _configManipulator.SaveConfigValue(itemPath, value);
+ return new ConfigurationServiceResult
+ {
+ Success = true
+ };
}
catch (Exception ex)
{
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/MacroErrorsCheck.cs b/src/Umbraco.Core/Configuration/HealthChecks/MacroErrorsCheck.cs
index 68e76dfc81..b31f23667d 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/MacroErrorsCheck.cs
+++ b/src/Umbraco.Core/Configuration/HealthChecks/MacroErrorsCheck.cs
@@ -1,27 +1,40 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
-using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
+using Microsoft.Extensions.Options;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.HealthCheck.Checks.Configuration
{
[HealthCheck("D0F7599E-9B2A-4D9E-9883-81C7EDC5616F", "Macro errors",
- Description = "Checks to make sure macro errors are not set to throw a YSOD (yellow screen of death), which would prevent certain or all pages from loading completely.",
+ Description =
+ "Checks to make sure macro errors are not set to throw a YSOD (yellow screen of death), which would prevent certain or all pages from loading completely.",
Group = "Configuration")]
- public class MacroErrorsCheck : AbstractConfigCheck
+ public class MacroErrorsCheck : AbstractSettingsCheck
{
- public MacroErrorsCheck(ILocalizedTextService textService, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory)
- : base(textService, hostingEnvironment, loggerFactory)
- { }
+ private readonly ILocalizedTextService _textService;
+ private readonly ILoggerFactory _loggerFactory;
+ private readonly IOptionsMonitor _contentSettings;
- public override string FilePath => "~/Config/umbracoSettings.config";
-
- public override string XPath => "/settings/content/MacroErrors";
+ public MacroErrorsCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory,
+ IOptionsMonitor contentSettings)
+ : base(textService, loggerFactory)
+ {
+ _textService = textService;
+ _loggerFactory = loggerFactory;
+ _contentSettings = contentSettings;
+ }
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
+ public override string ItemPath => Constants.Configuration.ConfigContentMacroErrors;
+
+
+ ///
+ /// Gets the values to compare against.
+ ///
public override IEnumerable Values
{
get
@@ -44,24 +57,35 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
}
}
+ public override string CurrentValue => _contentSettings.CurrentValue.MacroErrors.ToString();
+
+ ///
+ /// Gets the message for when the check has succeeded.
+ ///
public override string CheckSuccessMessage
{
get
{
- return TextService.Localize("healthcheck/macroErrorModeCheckSuccessMessage",
+ return _textService.Localize("healthcheck/macroErrorModeCheckSuccessMessage",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value });
}
}
+ ///
+ /// Gets the message for when the check has failed.
+ ///
public override string CheckErrorMessage
{
get
{
- return TextService.Localize("healthcheck/macroErrorModeCheckErrorMessage",
+ return _textService.Localize("healthcheck/macroErrorModeCheckErrorMessage",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value });
}
}
+ ///
+ /// Gets the rectify success message.
+ ///
public override string RectifySuccessMessage
{
get
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/TrySkipIisCustomErrorsCheck.cs b/src/Umbraco.Core/Configuration/HealthChecks/TrySkipIisCustomErrorsCheck.cs
index 76269d961c..9710080f35 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/TrySkipIisCustomErrorsCheck.cs
+++ b/src/Umbraco.Core/Configuration/HealthChecks/TrySkipIisCustomErrorsCheck.cs
@@ -2,32 +2,40 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.HealthCheck.Checks.Configuration
{
+ [Obsolete("This is not currently in the appsettings.JSON and so can either be removed, or rewritten in .NET Core fashion")]
[HealthCheck("046A066C-4FB2-4937-B931-069964E16C66", "Try Skip IIS Custom Errors",
Description = "Starting with IIS 7.5, this must be set to true for Umbraco 404 pages to show. Otherwise, IIS will takeover and render its built-in error page.",
Group = "Configuration")]
- public class TrySkipIisCustomErrorsCheck : AbstractConfigCheck
+ public class TrySkipIisCustomErrorsCheck : AbstractSettingsCheck
{
+ private readonly ILocalizedTextService _textService;
+ private readonly ILoggerFactory _loggerFactory;
private readonly Version _iisVersion;
+ private readonly GlobalSettings _globalSettings;
- public TrySkipIisCustomErrorsCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory,
- IHostingEnvironment hostingEnvironment)
- : base(textService, hostingEnvironment, loggerFactory)
+ public TrySkipIisCustomErrorsCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory, IOptions globalSettings)
+ : base(textService, loggerFactory)
{
- _iisVersion = hostingEnvironment.IISVersion;
+ _textService = textService;
+ _loggerFactory = loggerFactory;
+ //TODO: detect if hosted in IIS, and then IIS version if we want to go this route
+ _iisVersion = new Version("7.5");
+ _globalSettings = globalSettings.Value;
}
- public override string FilePath => "~/Config/umbracoSettings.config";
-
- public override string XPath => "/settings/web.routing/@trySkipIisCustomErrors";
+ public override string ItemPath => "TBC";
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
+ public override string CurrentValue => null;
+
public override IEnumerable Values
{
get
@@ -36,7 +44,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
var recommendedValue = _iisVersion >= new Version("7.5")
? bool.TrueString.ToLower()
: bool.FalseString.ToLower();
- return new List { new AcceptableConfiguration { IsRecommended = true, Value = recommendedValue } };
+ return new List { new AcceptableConfiguration { IsRecommended = true, Value = recommendedValue } };
}
}
@@ -44,7 +52,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
- return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckSuccessMessage",
+ return _textService.Localize("healthcheck/trySkipIisCustomErrorsCheckSuccessMessage",
new[] { Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() });
}
}
@@ -53,7 +61,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
- return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckErrorMessage",
+ return _textService.Localize("healthcheck/trySkipIisCustomErrorsCheckErrorMessage",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() });
}
}
@@ -62,8 +70,10 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
- return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckRectifySuccessMessage",
- new[] { Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() });
+ return _textService.Localize("healthcheck/trySkipIisCustomErrorsCheckRectifySuccessMessage",
+ new[] { "Not implemented" });
+
+ //new[] { Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() });
}
}
}
diff --git a/src/Umbraco.Core/Configuration/Models/HealthChecksSettings.cs b/src/Umbraco.Core/Configuration/Models/HealthChecksSettings.cs
index 0903a8f242..7600b946fd 100644
--- a/src/Umbraco.Core/Configuration/Models/HealthChecksSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/HealthChecksSettings.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
-using Umbraco.Core.Configuration.HealthChecks;
+using Umbraco.Core.HealthCheck;
+using Umbraco.Core.HealthCheck.Checks;
namespace Umbraco.Core.Configuration.Models
{
diff --git a/src/Umbraco.Core/Configuration/Models/ImagingCacheSettings.cs b/src/Umbraco.Core/Configuration/Models/ImagingCacheSettings.cs
index 90249abc15..44f5ae89b6 100644
--- a/src/Umbraco.Core/Configuration/Models/ImagingCacheSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/ImagingCacheSettings.cs
@@ -12,6 +12,6 @@ namespace Umbraco.Core.Configuration.Models
public uint CachedNameLength { get; set; } = 8;
- public string CacheFolder { get; set; } = Path.Combine("..", "Umbraco", "MediaCache");
+ public string CacheFolder { get; set; } = Path.Combine("..", "umbraco", "mediacache");
}
}
diff --git a/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs b/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs
index 414165d2e4..f0b56561e2 100644
--- a/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/ModelsBuilderSettings.cs
@@ -5,9 +5,10 @@ namespace Umbraco.Core.Configuration.Models
///
/// Represents the models builder configuration.
///
- public class ModelsBuilderSettings
+ public class ModelsBuilderSettings
{
- public static string DefaultModelsDirectory => "~/App_Data/Models";
+ // TODO: This should not go into App_Data - that folder isn't really a real thing anymore
+ public static string DefaultModelsDirectory => "~/umbraco/models";
///
/// Gets a value indicating whether the whole models experience is enabled.
diff --git a/src/Umbraco.Core/Constants-Configuration.cs b/src/Umbraco.Core/Constants-Configuration.cs
index c06ec8f1ec..2c9fe3caee 100644
--- a/src/Umbraco.Core/Constants-Configuration.cs
+++ b/src/Umbraco.Core/Constants-Configuration.cs
@@ -11,9 +11,23 @@
/// ":" is used as marker for nested objects in json. E.g. "Umbraco:CMS:" = {"Umbraco":{"CMS":{....}}
///
public const string ConfigPrefix = "Umbraco:CMS:";
+ public const string ConfigContentPrefix = ConfigPrefix + "Content:";
+ public const string ConfigContentNotificationsPrefix = ConfigContentPrefix + "Notifications:";
+ public const string ConfigCorePrefix = ConfigPrefix + "Core:";
+ public const string ConfigCustomErrorsPrefix = ConfigPrefix + "CustomErrors:";
+ public const string ConfigGlobalPrefix = ConfigPrefix + "Global:";
+ public const string ConfigHostingPrefix = ConfigPrefix + "Hosting:";
+ public const string ConfigModelsBuilderPrefix = ConfigPrefix + "ModelsBuilder:";
+ public const string ConfigSecurityPrefix = ConfigPrefix + "Security:";
+
+ public const string ConfigContentNotificationsEmail = ConfigContentNotificationsPrefix + "Email";
+ public const string ConfigContentMacroErrors = ConfigContentPrefix + "MacroErrors";
+ public const string ConfigGlobalUseHttps = ConfigGlobalPrefix + "UseHttps";
+ public const string ConfigHostingDebug = ConfigHostingPrefix + "Debug";
+ public const string ConfigCustomErrorsMode = ConfigCustomErrorsPrefix + "Mode";
public const string ConfigActiveDirectory = ConfigPrefix + "ActiveDirectory";
public const string ConfigContent = ConfigPrefix + "Content";
- public const string ConfigCoreDebug = ConfigPrefix + "Core:Debug";
+ public const string ConfigCoreDebug = ConfigCorePrefix + "Debug";
public const string ConfigExceptionFilter = ConfigPrefix + "ExceptionFilter";
public const string ConfigGlobal = ConfigPrefix + "Global";
public const string ConfigHealthChecks = ConfigPrefix + "HealthChecks";
@@ -27,14 +41,13 @@
public const string ConfigNuCache = ConfigPrefix + "NuCache";
public const string ConfigRequestHandler = ConfigPrefix + "RequestHandler";
public const string ConfigRuntime = ConfigPrefix + "Runtime";
+ public const string ConfigRuntimeMinification = ConfigPrefix + "RuntimeMinification";
+ public const string ConfigRuntimeMinificationVersion = ConfigRuntimeMinification + ":Version";
public const string ConfigSecurity = ConfigPrefix + "Security";
public const string ConfigTours = ConfigPrefix + "Tours";
public const string ConfigTypeFinder = ConfigPrefix + "TypeFinder";
public const string ConfigWebRouting = ConfigPrefix + "WebRouting";
public const string ConfigUserPassword = ConfigPrefix + "Security:UserPassword";
-
- public const string ConfigRuntimeMinification = ConfigPrefix + "RuntimeMinification";
- public const string ConfigRuntimeMinificationVersion = ConfigRuntimeMinification + ":Version";
}
}
}
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/AcceptableConfiguration.cs b/src/Umbraco.Core/HealthCheck/AcceptableConfiguration.cs
similarity index 74%
rename from src/Umbraco.Core/Configuration/HealthChecks/AcceptableConfiguration.cs
rename to src/Umbraco.Core/HealthCheck/AcceptableConfiguration.cs
index b71bba1d14..f879172a5d 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/AcceptableConfiguration.cs
+++ b/src/Umbraco.Core/HealthCheck/AcceptableConfiguration.cs
@@ -1,4 +1,4 @@
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.HealthCheck
{
public class AcceptableConfiguration
{
diff --git a/src/Umbraco.Core/HealthCheck/Checks/AbstractSettingsCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/AbstractSettingsCheck.cs
new file mode 100644
index 0000000000..62543dcfbd
--- /dev/null
+++ b/src/Umbraco.Core/HealthCheck/Checks/AbstractSettingsCheck.cs
@@ -0,0 +1,160 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Extensions.Logging;
+using Umbraco.Core.Services;
+
+namespace Umbraco.Core.HealthCheck.Checks
+{
+ public abstract class AbstractSettingsCheck : HealthCheck
+ {
+ protected ILocalizedTextService TextService { get; }
+ protected ILoggerFactory LoggerFactory { get; }
+
+ ///
+ /// Gets key within the JSON to check, in the colon-delimited format
+ /// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1
+ ///
+ public abstract string ItemPath { get; }
+
+ ///
+ /// Gets the values to compare against.
+ ///
+ public abstract IEnumerable Values { get; }
+
+ ///
+ /// Gets the current value of the config setting
+ ///
+ public abstract string CurrentValue { get; }
+
+ ///
+ /// Gets the provided value
+ ///
+ public string ProvidedValue { get; set; }
+
+ ///
+ /// Gets the comparison type for checking the value.
+ ///
+ public abstract ValueComparisonType ValueComparisonType { get; }
+
+ protected AbstractSettingsCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory)
+ {
+ TextService = textService;
+ LoggerFactory = loggerFactory;
+ }
+
+ ///
+ /// Gets the message for when the check has succeeded.
+ ///
+ public virtual string CheckSuccessMessage
+ {
+ get
+ {
+ return TextService.Localize("healthcheck/checkSuccessMessage", new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, ItemPath });
+ }
+ }
+
+ ///
+ /// Gets the message for when the check has failed.
+ ///
+ public virtual string CheckErrorMessage
+ {
+ get
+ {
+ return ValueComparisonType == ValueComparisonType.ShouldEqual
+ ? TextService.Localize("healthcheck/checkErrorMessageDifferentExpectedValue",
+ new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, ItemPath })
+ : TextService.Localize("healthcheck/checkErrorMessageUnexpectedValue",
+ new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, ItemPath });
+ }
+ }
+
+ ///
+ /// Gets the rectify success message.
+ ///
+ public virtual string RectifySuccessMessage
+ {
+ get
+ {
+ AcceptableConfiguration recommendedValue = Values.FirstOrDefault(v => v.IsRecommended);
+ string rectifiedValue = recommendedValue != null ? recommendedValue.Value : ProvidedValue;
+ return TextService.Localize("healthcheck/rectifySuccessMessage",
+ new[]
+ {
+ CurrentValue,
+ rectifiedValue,
+ ItemPath
+ });
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether this check can be rectified automatically.
+ ///
+ public virtual bool CanRectify => ValueComparisonType == ValueComparisonType.ShouldEqual;
+
+ ///
+ /// Gets a value indicating whether this check can be rectified automatically if a value is provided.
+ ///
+ public virtual bool CanRectifyWithValue => ValueComparisonType == ValueComparisonType.ShouldNotEqual;
+
+ public override IEnumerable GetStatus()
+ {
+ // update the successMessage with the CurrentValue
+ var successMessage = string.Format(CheckSuccessMessage, ItemPath, Values, CurrentValue);
+ bool valueFound = Values.Any(value => string.Equals(CurrentValue, value.Value, StringComparison.InvariantCultureIgnoreCase));
+
+ if (ValueComparisonType == ValueComparisonType.ShouldEqual
+ && valueFound || ValueComparisonType == ValueComparisonType.ShouldNotEqual
+ && valueFound == false)
+ {
+ return new[]
+ {
+ new HealthCheckStatus(successMessage)
+ {
+ ResultType = StatusResultType.Success
+ }
+ };
+ }
+
+ // Declare the action for rectifying the config value
+ var rectifyAction = new HealthCheckAction("rectify", Id)
+ {
+ Name = TextService.Localize("healthcheck/rectifyButton"),
+ ValueRequired = CanRectifyWithValue
+ };
+
+ string resultMessage = string.Format(CheckErrorMessage, ItemPath, Values, CurrentValue);
+ return new[]
+ {
+ new HealthCheckStatus(resultMessage)
+ {
+ ResultType = StatusResultType.Error,
+ Actions = CanRectify || CanRectifyWithValue ? new[] { rectifyAction } : new HealthCheckAction[0]
+ }
+ };
+ }
+
+ ///
+ /// Rectifies this check.
+ ///
+ ///
+ public virtual HealthCheckStatus Rectify(HealthCheckAction action)
+ {
+ if (ValueComparisonType == ValueComparisonType.ShouldNotEqual)
+ {
+ throw new InvalidOperationException(TextService.Localize("healthcheck/cannotRectifyShouldNotEqual"));
+ }
+
+ //TODO: show message instead of actually fixing config
+ string recommendedValue = Values.First(v => v.IsRecommended).Value;
+ string resultMessage = string.Format(RectifySuccessMessage, ItemPath, Values);
+ return new HealthCheckStatus(resultMessage) { ResultType = StatusResultType.Success };
+ }
+
+ public override HealthCheckStatus ExecuteAction(HealthCheckAction action)
+ {
+ return Rectify(action);
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/NotificationEmailCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Configuration/NotificationEmailCheck.cs
similarity index 61%
rename from src/Umbraco.Core/Configuration/HealthChecks/NotificationEmailCheck.cs
rename to src/Umbraco.Core/HealthCheck/Checks/Configuration/NotificationEmailCheck.cs
index bac2cf1c3c..a6e6a83c47 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/NotificationEmailCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Configuration/NotificationEmailCheck.cs
@@ -1,25 +1,26 @@
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
-using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
+using Microsoft.Extensions.Options;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.HealthCheck.Checks.Configuration
{
[HealthCheck("3E2F7B14-4B41-452B-9A30-E67FBC8E1206", "Notification Email Settings",
Description = "If notifications are used, the 'from' email address should be specified and changed from the default value.",
Group = "Configuration")]
- public class NotificationEmailCheck : AbstractConfigCheck
+ public class NotificationEmailCheck : AbstractSettingsCheck
{
+ private readonly IOptionsMonitor _contentSettings;
private const string DefaultFromEmail = "your@email.here";
- public NotificationEmailCheck(ILocalizedTextService textService, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory)
- : base(textService, hostingEnvironment, loggerFactory)
- { }
+ public NotificationEmailCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory, IOptionsMonitor contentSettings)
+ : base(textService, loggerFactory)
+ {
+ _contentSettings = contentSettings;
+ }
- public override string FilePath => "~/Config/umbracoSettings.config";
-
- public override string XPath => "/settings/content/notifications/email";
+ public override string ItemPath => Constants.Configuration.ConfigContentNotificationsEmail;
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldNotEqual;
@@ -28,8 +29,11 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
new AcceptableConfiguration { IsRecommended = false, Value = DefaultFromEmail }
};
- public override string CheckSuccessMessage => TextService.Localize("healthcheck/notificationEmailsCheckSuccessMessage", new [] { CurrentValue } );
+ public override string CurrentValue => _contentSettings.CurrentValue.Notifications.Email;
+
+ public override string CheckSuccessMessage => TextService.Localize("healthcheck/notificationEmailsCheckSuccessMessage", new[] { CurrentValue });
public override string CheckErrorMessage => TextService.Localize("healthcheck/notificationEmailsCheckErrorMessage", new[] { DefaultFromEmail });
+
}
}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Data/DatabaseIntegrityCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Data/DatabaseIntegrityCheck.cs
index a18edb175a..0fb34950bd 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Data/DatabaseIntegrityCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Data/DatabaseIntegrityCheck.cs
@@ -5,7 +5,7 @@ using System.Text;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Data
+namespace Umbraco.Core.HealthCheck.Checks.Data
{
[HealthCheck(
"73DD0C1C-E0CA-4C31-9564-1DCA509788AF",
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/DisabledHealthCheck.cs
similarity index 80%
rename from src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthCheck.cs
rename to src/Umbraco.Core/HealthCheck/Checks/DisabledHealthCheck.cs
index c962014bd5..99ff05ed55 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/DisabledHealthCheck.cs
@@ -1,6 +1,6 @@
using System;
-namespace Umbraco.Core.Configuration.HealthChecks
+namespace Umbraco.Core.HealthCheck.Checks
{
public class DisabledHealthCheck
{
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/CustomErrorsCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/LiveEnvironment/CustomErrorsCheck.cs
similarity index 78%
rename from src/Umbraco.Core/Configuration/HealthChecks/CustomErrorsCheck.cs
rename to src/Umbraco.Core/HealthCheck/Checks/LiveEnvironment/CustomErrorsCheck.cs
index 9b14847bdf..b003506205 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/CustomErrorsCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/LiveEnvironment/CustomErrorsCheck.cs
@@ -1,24 +1,20 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
-using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.HealthCheck.Checks.LiveEnvironment
{
[HealthCheck("4090C0A1-2C52-4124-92DD-F028FD066A64", "Custom Errors",
Description = "Leaving custom errors off will display a complete stack trace to your visitors if an exception occurs.",
Group = "Live Environment")]
- public class CustomErrorsCheck : AbstractConfigCheck
+ public class CustomErrorsCheck : AbstractSettingsCheck
{
- public CustomErrorsCheck(ILocalizedTextService textService, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory)
- : base(textService, hostingEnvironment, loggerFactory)
+ public CustomErrorsCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory)
+ : base(textService, loggerFactory)
{ }
- public override string FilePath => "~/Web.config";
-
- public override string XPath => "/configuration/system.web/customErrors/@mode";
+ public override string ItemPath => Constants.Configuration.ConfigCustomErrorsMode;
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
@@ -28,6 +24,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
new AcceptableConfiguration { IsRecommended = false, Value = "On" }
};
+ public override string CurrentValue { get; }
+
public override string CheckSuccessMessage
{
get
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/TraceCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/LiveEnvironment/TraceCheck.cs
similarity index 68%
rename from src/Umbraco.Core/Configuration/HealthChecks/TraceCheck.cs
rename to src/Umbraco.Core/HealthCheck/Checks/LiveEnvironment/TraceCheck.cs
index a2c5a84c55..03a6ecfde2 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/TraceCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/LiveEnvironment/TraceCheck.cs
@@ -1,24 +1,19 @@
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
-using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.HealthCheck.Checks.LiveEnvironment
{
[HealthCheck("9BED6EF4-A7F3-457A-8935-B64E9AA8BAB3", "Trace Mode",
Description = "Leaving trace mode enabled can make valuable information about your system available to hackers.",
Group = "Live Environment")]
- public class TraceCheck : AbstractConfigCheck
+ public class TraceCheck : AbstractSettingsCheck
{
-
- public TraceCheck(ILocalizedTextService textService, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory)
- : base(textService, hostingEnvironment, loggerFactory)
+ public TraceCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory)
+ : base(textService, loggerFactory)
{ }
- public override string FilePath => "~/Web.config";
-
- public override string XPath => "/configuration/system.web/trace/@enabled";
+ public override string ItemPath => "/configuration/system.web/trace/@enabled";
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
@@ -27,10 +22,13 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
new AcceptableConfiguration { IsRecommended = true, Value = bool.FalseString.ToLower() }
};
+ public override string CurrentValue { get; }
+
public override string CheckSuccessMessage => TextService.Localize("healthcheck/traceModeCheckSuccessMessage");
public override string CheckErrorMessage => TextService.Localize("healthcheck/traceModeCheckErrorMessage");
public override string RectifySuccessMessage => TextService.Localize("healthcheck/traceModeCheckRectifySuccessMessage");
+
}
}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs
index d6fbfae813..1618daf028 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs
@@ -2,27 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Options;
-using Umbraco.Core;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Install;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Permissions
+namespace Umbraco.Core.HealthCheck.Checks.Permissions
{
- internal enum PermissionCheckRequirement
- {
- Required,
- Optional
- }
-
- internal enum PermissionCheckFor
- {
- Folder,
- File
- }
-
[HealthCheck(
"53DBA282-4A79-4B67-B958-B29EC40FCC23",
"Folder & File Permissions",
@@ -31,14 +17,14 @@ namespace Umbraco.Web.HealthCheck.Checks.Permissions
public class FolderAndFilePermissionsCheck : HealthCheck
{
private readonly ILocalizedTextService _textService;
- private readonly GlobalSettings _globalSettings;
+ private readonly IOptionsMonitor _globalSettings;
private readonly IFilePermissionHelper _filePermissionHelper;
private readonly IIOHelper _ioHelper;
- public FolderAndFilePermissionsCheck(ILocalizedTextService textService, IOptions globalSettings, IFilePermissionHelper filePermissionHelper, IIOHelper ioHelper)
+ public FolderAndFilePermissionsCheck(ILocalizedTextService textService, IOptionsMonitor globalSettings, IFilePermissionHelper filePermissionHelper, IIOHelper ioHelper)
{
_textService = textService;
- _globalSettings = globalSettings.Value;
+ _globalSettings = globalSettings;
_filePermissionHelper = filePermissionHelper;
_ioHelper = ioHelper;
}
@@ -74,10 +60,10 @@ namespace Umbraco.Web.HealthCheck.Checks.Permissions
{ Constants.SystemDirectories.Preview, PermissionCheckRequirement.Required },
{ Constants.SystemDirectories.AppPlugins, PermissionCheckRequirement.Required },
{ Constants.SystemDirectories.Config, PermissionCheckRequirement.Optional },
- { _globalSettings.UmbracoCssPath, PermissionCheckRequirement.Optional },
- { _globalSettings.UmbracoMediaPath, PermissionCheckRequirement.Optional },
- { _globalSettings.UmbracoScriptsPath, PermissionCheckRequirement.Optional },
- { _globalSettings.UmbracoPath, PermissionCheckRequirement.Optional },
+ { _globalSettings.CurrentValue.UmbracoCssPath, PermissionCheckRequirement.Optional },
+ { _globalSettings.CurrentValue.UmbracoMediaPath, PermissionCheckRequirement.Optional },
+ { _globalSettings.CurrentValue.UmbracoScriptsPath, PermissionCheckRequirement.Optional },
+ { _globalSettings.CurrentValue.UmbracoPath, PermissionCheckRequirement.Optional },
{ Constants.SystemDirectories.MvcViews, PermissionCheckRequirement.Optional }
};
@@ -97,7 +83,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Permissions
//now check the special folders
var requiredPathCheckResult2 = _filePermissionHelper.EnsureDirectories(
- GetPathsToCheck(pathsToCheckWithRestarts, PermissionCheckRequirement.Required), out var requiredFailedPaths2, writeCausesRestart:true);
+ GetPathsToCheck(pathsToCheckWithRestarts, PermissionCheckRequirement.Required), out var requiredFailedPaths2, writeCausesRestart: true);
var optionalPathCheckResult2 = _filePermissionHelper.EnsureDirectories(
GetPathsToCheck(pathsToCheckWithRestarts, PermissionCheckRequirement.Optional), out var optionalFailedPaths2, writeCausesRestart: true);
@@ -139,9 +125,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Permissions
.ToArray();
}
- private HealthCheckStatus GetStatus(bool requiredPathCheckResult, IEnumerable requiredFailedPaths,
- bool optionalPathCheckResult, IEnumerable optionalFailedPaths,
- PermissionCheckFor checkingFor)
+ private HealthCheckStatus GetStatus(bool requiredPathCheckResult, IEnumerable requiredFailedPaths, bool optionalPathCheckResult, IEnumerable optionalFailedPaths, PermissionCheckFor checkingFor)
{
// Return error if any required paths fail the check, or warning if any optional ones do
var resultType = StatusResultType.Success;
@@ -164,12 +148,11 @@ namespace Umbraco.Web.HealthCheck.Checks.Permissions
}
var actions = new List();
- return
- new HealthCheckStatus(message)
- {
- ResultType = resultType,
- Actions = actions
- };
+ return new HealthCheckStatus(message)
+ {
+ ResultType = resultType,
+ Actions = actions
+ };
}
private string GetMessageForPathCheckFailure(string messageKey, IEnumerable failedPaths)
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Permissions/PermissionCheckFor.cs b/src/Umbraco.Core/HealthCheck/Checks/Permissions/PermissionCheckFor.cs
new file mode 100644
index 0000000000..bd914d064d
--- /dev/null
+++ b/src/Umbraco.Core/HealthCheck/Checks/Permissions/PermissionCheckFor.cs
@@ -0,0 +1,8 @@
+namespace Umbraco.Core.HealthCheck.Checks.Permissions
+{
+ internal enum PermissionCheckFor
+ {
+ Folder,
+ File
+ }
+}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Permissions/PermissionCheckRequirement.cs b/src/Umbraco.Core/HealthCheck/Checks/Permissions/PermissionCheckRequirement.cs
new file mode 100644
index 0000000000..f77fdbf2e3
--- /dev/null
+++ b/src/Umbraco.Core/HealthCheck/Checks/Permissions/PermissionCheckRequirement.cs
@@ -0,0 +1,8 @@
+namespace Umbraco.Core.HealthCheck.Checks.Permissions
+{
+ internal enum PermissionCheckRequirement
+ {
+ Required,
+ Optional
+ }
+}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs
index 149ad4a48a..5bf92342bf 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs
@@ -4,13 +4,11 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
-using System.Xml.Linq;
-using System.Xml.XPath;
-using Umbraco.Core;
-using Umbraco.Core.IO;
+using Microsoft.Extensions.Configuration;
using Umbraco.Core.Services;
+using Umbraco.Web;
-namespace Umbraco.Web.HealthCheck.Checks.Security
+namespace Umbraco.Core.HealthCheck.Checks.Security
{
public abstract class BaseHttpHeaderCheck : HealthCheck
{
@@ -23,16 +21,14 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
private readonly string _localizedTextPrefix;
private readonly bool _metaTagOptionAvailable;
private readonly IRequestAccessor _requestAccessor;
- private readonly IIOHelper _ioHelper;
protected BaseHttpHeaderCheck(
IRequestAccessor requestAccessor,
ILocalizedTextService textService,
- string header, string value, string localizedTextPrefix, bool metaTagOptionAvailable, IIOHelper ioHelper)
+ string header, string value, string localizedTextPrefix, bool metaTagOptionAvailable)
{
TextService = textService ?? throw new ArgumentNullException(nameof(textService));
_requestAccessor = requestAccessor;
- _ioHelper = ioHelper;
_header = header;
_value = value;
_localizedTextPrefix = localizedTextPrefix;
@@ -72,7 +68,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
var success = false;
// Access the site home page and check for the click-jack protection header or meta tag
- var url = _requestAccessor.GetApplicationUrl();
+ var url = _requestAccessor.GetApplicationUrl();
var request = WebRequest.Create(url);
request.Method = "GET";
try
@@ -146,7 +142,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
private HealthCheckStatus SetHeaderInConfig()
{
var errorMessage = string.Empty;
- var success = SaveHeaderToConfigFile(out errorMessage);
+ //TODO: edit to show fix suggestion instead of making fix
+ var success = true;
if (success)
{
@@ -158,64 +155,10 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
}
return
- new HealthCheckStatus(TextService.Localize("healthcheck/setHeaderInConfigError", new [] { errorMessage }))
+ new HealthCheckStatus(TextService.Localize("healthcheck/setHeaderInConfigError", new[] { errorMessage }))
{
ResultType = StatusResultType.Error
};
}
-
- private bool SaveHeaderToConfigFile(out string errorMessage)
- {
- try
- {
- // There don't look to be any useful classes defined in https://msdn.microsoft.com/en-us/library/system.web.configuration(v=vs.110).aspx
- // for working with the customHeaders section, so working with the XML directly.
- var configFile = _ioHelper.MapPath("~/Web.config");
- var doc = XDocument.Load(configFile);
- var systemWebServerElement = doc.XPathSelectElement("/configuration/system.webServer");
- var httpProtocolElement = systemWebServerElement.Element("httpProtocol");
- if (httpProtocolElement == null)
- {
- httpProtocolElement = new XElement("httpProtocol");
- systemWebServerElement.Add(httpProtocolElement);
- }
-
- var customHeadersElement = httpProtocolElement.Element("customHeaders");
- if (customHeadersElement == null)
- {
- customHeadersElement = new XElement("customHeaders");
- httpProtocolElement.Add(customHeadersElement);
- }
-
- var removeHeaderElement = customHeadersElement.Elements("remove")
- .SingleOrDefault(x => x.Attribute("name")?.Value.Equals(_value, StringComparison.InvariantCultureIgnoreCase) == true);
- if (removeHeaderElement == null)
- {
- customHeadersElement.Add(
- new XElement("remove",
- new XAttribute("name", _header)));
- }
-
- var addHeaderElement = customHeadersElement.Elements("add")
- .SingleOrDefault(x => x.Attribute("name")?.Value.Equals(_header, StringComparison.InvariantCultureIgnoreCase) == true);
- if (addHeaderElement == null)
- {
- customHeadersElement.Add(
- new XElement("add",
- new XAttribute("name", _header),
- new XAttribute("value", _value)));
- }
-
- doc.Save(configFile);
-
- errorMessage = string.Empty;
- return true;
- }
- catch (Exception ex)
- {
- errorMessage = ex.Message;
- return false;
- }
- }
}
}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/ClickJackingCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/ClickJackingCheck.cs
index 048b26afca..a7b4c0ba85 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Security/ClickJackingCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Security/ClickJackingCheck.cs
@@ -1,8 +1,7 @@
-using Umbraco.Core;
-using Umbraco.Core.IO;
-using Umbraco.Core.Services;
+using Umbraco.Core.Services;
+using Umbraco.Web;
-namespace Umbraco.Web.HealthCheck.Checks.Security
+namespace Umbraco.Core.HealthCheck.Checks.Security
{
[HealthCheck(
"ED0D7E40-971E-4BE8-AB6D-8CC5D0A6A5B0",
@@ -11,8 +10,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
Group = "Security")]
public class ClickJackingCheck : BaseHttpHeaderCheck
{
- public ClickJackingCheck(IRequestAccessor requestAccessor, ILocalizedTextService textService, IIOHelper ioHelper)
- : base(requestAccessor, textService, "X-Frame-Options", "sameorigin", "clickJacking", true, ioHelper)
+ public ClickJackingCheck(IRequestAccessor requestAccessor, ILocalizedTextService textService)
+ : base(requestAccessor, textService, "X-Frame-Options", "sameorigin", "clickJacking", true)
{
}
}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs
index 06367ace13..9cf1127bb0 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs
@@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
-using Umbraco.Core;
using Umbraco.Core.Services;
+using Umbraco.Web;
-namespace Umbraco.Web.HealthCheck.Checks.Security
+namespace Umbraco.Core.HealthCheck.Checks.Security
{
[HealthCheck(
"92ABBAA2-0586-4089-8AE2-9A843439D577",
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/HstsCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/HstsCheck.cs
index 61879142f2..ee8f733fca 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Security/HstsCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Security/HstsCheck.cs
@@ -1,8 +1,7 @@
-using Umbraco.Core;
-using Umbraco.Core.IO;
-using Umbraco.Core.Services;
+using Umbraco.Core.Services;
+using Umbraco.Web;
-namespace Umbraco.Web.HealthCheck.Checks.Security
+namespace Umbraco.Core.HealthCheck.Checks.Security
{
[HealthCheck(
"E2048C48-21C5-4BE1-A80B-8062162DF124",
@@ -16,8 +15,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
// and the blog post of Troy Hunt (https://www.troyhunt.com/understanding-http-strict-transport/)
// If you want do to it perfectly, you have to submit it https://hstspreload.org/,
// but then you should include subdomains and I wouldn't suggest to do that for Umbraco-sites.
- public HstsCheck(IRequestAccessor requestAccessor, ILocalizedTextService textService, IIOHelper ioHelper)
- : base(requestAccessor, textService, "Strict-Transport-Security", "max-age=10886400", "hSTS", true, ioHelper)
+ public HstsCheck(IRequestAccessor requestAccessor, ILocalizedTextService textService)
+ : base(requestAccessor, textService, "Strict-Transport-Security", "max-age=10886400", "hSTS", true)
{
}
}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/HttpsCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/HttpsCheck.cs
index 3f788f7460..6bba41b7d5 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Security/HttpsCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Security/HttpsCheck.cs
@@ -3,15 +3,14 @@ using System.Collections.Generic;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Extensions.Logging;
-using Umbraco.Core;
-using Umbraco.Core.Configuration;
-using Umbraco.Core.IO;
using Umbraco.Core.Services;
-using Umbraco.Web.HealthCheck.Checks.Config;
using Umbraco.Core.Configuration.Models;
using Microsoft.Extensions.Options;
+using Umbraco.Core.Configuration.HealthChecks;
+using Umbraco.Core.IO;
+using Umbraco.Web;
-namespace Umbraco.Web.HealthCheck.Checks.Security
+namespace Umbraco.Core.HealthCheck.Checks.Security
{
[HealthCheck(
"EB66BB3B-1BCD-4314-9531-9DA2C1D6D9A7",
@@ -21,22 +20,20 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
public class HttpsCheck : HealthCheck
{
private readonly ILocalizedTextService _textService;
- private readonly GlobalSettings _globalSettings;
- private readonly IIOHelper _ioHelper;
+ private readonly IOptionsMonitor _globalSettings;
private readonly IRequestAccessor _requestAccessor;
- private readonly ILogger _logger;
-
+ private readonly ILogger _logger;
private const string FixHttpsSettingAction = "fixHttpsSetting";
+ string itemPath => Constants.Configuration.ConfigGlobalUseHttps;
public HttpsCheck(ILocalizedTextService textService,
- IOptions globalSettings,
+ IOptionsMonitor globalSettings,
IIOHelper ioHelper,
IRequestAccessor requestAccessor,
- ILogger logger)
+ ILogger logger)
{
_textService = textService;
- _globalSettings = globalSettings.Value;
- _ioHelper = ioHelper;
+ _globalSettings = globalSettings;
_requestAccessor = requestAccessor;
_logger = logger;
}
@@ -75,7 +72,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
// Attempt to access the site over HTTPS to see if it HTTPS is supported
// and a valid certificate has been configured
var url = _requestAccessor.GetApplicationUrl().ToString().Replace("http:", "https:");
- var request = (HttpWebRequest) WebRequest.Create(url);
+ var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "HEAD";
try
@@ -119,8 +116,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
if (exception != null)
{
message = exception.Status == WebExceptionStatus.TrustFailure
- ? _textService.Localize("healthcheck/httpsCheckInvalidCertificate", new [] { exception.Message })
- : _textService.Localize("healthcheck/healthCheckInvalidUrl", new [] { url, exception.Message });
+ ? _textService.Localize("healthcheck/httpsCheckInvalidCertificate", new[] { exception.Message })
+ : _textService.Localize("healthcheck/healthCheckInvalidUrl", new[] { url, exception.Message });
}
else
{
@@ -132,33 +129,31 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
var actions = new List();
- return
- new HealthCheckStatus(message)
- {
- ResultType = result,
- Actions = actions
- };
+ return new HealthCheckStatus(message)
+ {
+ ResultType = result,
+ Actions = actions
+ };
}
private HealthCheckStatus CheckIfCurrentSchemeIsHttps()
{
- var uri = _requestAccessor.GetApplicationUrl();
+ var uri = _requestAccessor.GetApplicationUrl();
var success = uri.Scheme == "https";
var actions = new List();
- return
- new HealthCheckStatus(_textService.Localize("healthcheck/httpsCheckIsCurrentSchemeHttps", new[] { success ? string.Empty : "not" }))
- {
- ResultType = success ? StatusResultType.Success : StatusResultType.Error,
- Actions = actions
- };
+ return new HealthCheckStatus(_textService.Localize("healthcheck/httpsCheckIsCurrentSchemeHttps", new[] { success ? string.Empty : "not" }))
+ {
+ ResultType = success ? StatusResultType.Success : StatusResultType.Error,
+ Actions = actions
+ };
}
private HealthCheckStatus CheckHttpsConfigurationSetting()
{
- var httpsSettingEnabled = _globalSettings.UseHttps;
- var uri = _requestAccessor.GetApplicationUrl();
+ bool httpsSettingEnabled = _globalSettings.CurrentValue.UseHttps;
+ Uri uri = _requestAccessor.GetApplicationUrl();
var actions = new List();
string resultMessage;
@@ -171,46 +166,34 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
else
{
if (httpsSettingEnabled == false)
+ {
actions.Add(new HealthCheckAction(FixHttpsSettingAction, Id)
{
Name = _textService.Localize("healthcheck/httpsCheckEnableHttpsButton"),
Description = _textService.Localize("healthcheck/httpsCheckEnableHttpsDescription")
});
+ }
resultMessage = _textService.Localize("healthcheck/httpsCheckConfigurationCheckResult",
- new[] {httpsSettingEnabled.ToString(), httpsSettingEnabled ? string.Empty : "not"});
- resultType = httpsSettingEnabled ? StatusResultType.Success: StatusResultType.Error;
+ new[] { httpsSettingEnabled.ToString(), httpsSettingEnabled ? string.Empty : "not" });
+ resultType = httpsSettingEnabled ? StatusResultType.Success : StatusResultType.Error;
}
- return
- new HealthCheckStatus(resultMessage)
- {
- ResultType = resultType,
- Actions = actions
- };
+ return new HealthCheckStatus(resultMessage)
+ {
+ ResultType = resultType,
+ Actions = actions
+ };
}
private HealthCheckStatus FixHttpsSetting()
{
- var configFile = _ioHelper.MapPath("~/Web.config");
- const string xPath = "/configuration/appSettings/add[@key='Umbraco.Core.UseHttps']/@value";
- var configurationService = new ConfigurationService(configFile, xPath, _textService, _logger);
- var updateConfigFile = configurationService.UpdateConfigFile("true");
+ //TODO: return message instead of actual fix
- if (updateConfigFile.Success)
+ return new HealthCheckStatus(_textService.Localize("healthcheck/httpsCheckEnableHttpsSuccess"))
{
- return
- new HealthCheckStatus(_textService.Localize("healthcheck/httpsCheckEnableHttpsSuccess"))
- {
- ResultType = StatusResultType.Success
- };
- }
-
- return
- new HealthCheckStatus(_textService.Localize("healthcheck/httpsCheckEnableHttpsError", new [] { updateConfigFile.Result }))
- {
- ResultType = StatusResultType.Error
- };
+ ResultType = StatusResultType.Success
+ };
}
}
}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/NoSniffCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/NoSniffCheck.cs
index 0b6fb9e347..c392842049 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Security/NoSniffCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Security/NoSniffCheck.cs
@@ -1,8 +1,7 @@
-using Umbraco.Core;
-using Umbraco.Core.IO;
-using Umbraco.Core.Services;
+using Umbraco.Core.Services;
+using Umbraco.Web;
-namespace Umbraco.Web.HealthCheck.Checks.Security
+namespace Umbraco.Core.HealthCheck.Checks.Security
{
[HealthCheck(
"1CF27DB3-EFC0-41D7-A1BB-EA912064E071",
@@ -11,8 +10,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
Group = "Security")]
public class NoSniffCheck : BaseHttpHeaderCheck
{
- public NoSniffCheck(IRequestAccessor requestAccessor, ILocalizedTextService textService, IIOHelper ioHelper)
- : base(requestAccessor, textService, "X-Content-Type-Options", "nosniff", "noSniff", false, ioHelper)
+ public NoSniffCheck(IRequestAccessor requestAccessor, ILocalizedTextService textService)
+ : base(requestAccessor, textService, "X-Content-Type-Options", "nosniff", "noSniff", false)
{
}
}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/XssProtectionCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/XssProtectionCheck.cs
index 7d658e2082..a5f0f28f22 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Security/XssProtectionCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Security/XssProtectionCheck.cs
@@ -1,8 +1,7 @@
-using Umbraco.Core;
-using Umbraco.Core.IO;
-using Umbraco.Core.Services;
+using Umbraco.Core.Services;
+using Umbraco.Web;
-namespace Umbraco.Web.HealthCheck.Checks.Security
+namespace Umbraco.Core.HealthCheck.Checks.Security
{
[HealthCheck(
"F4D2B02E-28C5-4999-8463-05759FA15C3A",
@@ -16,8 +15,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
// and the blog post of Troy Hunt (https://www.troyhunt.com/understanding-http-strict-transport/)
// If you want do to it perfectly, you have to submit it https://hstspreload.appspot.com/,
// but then you should include subdomains and I wouldn't suggest to do that for Umbraco-sites.
- public XssProtectionCheck(IRequestAccessor requestAccessor,ILocalizedTextService textService, IIOHelper ioHelper)
- : base(requestAccessor, textService, "X-XSS-Protection", "1; mode=block", "xssProtection", true, ioHelper)
+ public XssProtectionCheck(IRequestAccessor requestAccessor,ILocalizedTextService textService)
+ : base(requestAccessor, textService, "X-XSS-Protection", "1; mode=block", "xssProtection", true)
{
}
}
diff --git a/src/Umbraco.Core/HealthCheck/Checks/Services/SmtpCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Services/SmtpCheck.cs
index 77b1201ef6..9e1a6f84af 100644
--- a/src/Umbraco.Core/HealthCheck/Checks/Services/SmtpCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/Checks/Services/SmtpCheck.cs
@@ -3,12 +3,10 @@ using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using Microsoft.Extensions.Options;
-using Umbraco.Core;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Services;
-namespace Umbraco.Web.HealthCheck.Checks.Services
+namespace Umbraco.Core.HealthCheck.Checks.Services
{
[HealthCheck(
"1B5D221B-CE99-4193-97CB-5F3261EC73DF",
@@ -18,12 +16,12 @@ namespace Umbraco.Web.HealthCheck.Checks.Services
public class SmtpCheck : HealthCheck
{
private readonly ILocalizedTextService _textService;
- private readonly GlobalSettings _globalSettings;
+ private readonly IOptionsMonitor _globalSettings;
- public SmtpCheck(ILocalizedTextService textService, IOptions globalSettings)
+ public SmtpCheck(ILocalizedTextService textService, IOptionsMonitor globalSettings)
{
_textService = textService;
- _globalSettings = globalSettings.Value;
+ _globalSettings = globalSettings;
}
///
@@ -50,7 +48,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Services
{
var success = false;
- var smtpSettings = _globalSettings.Smtp;
+ var smtpSettings = _globalSettings.CurrentValue.Smtp;
string message;
if (smtpSettings == null)
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/ConfigurationServiceResult.cs b/src/Umbraco.Core/HealthCheck/ConfigurationServiceResult.cs
similarity index 73%
rename from src/Umbraco.Core/Configuration/HealthChecks/ConfigurationServiceResult.cs
rename to src/Umbraco.Core/HealthCheck/ConfigurationServiceResult.cs
index 3b1400da5b..b4940f927a 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/ConfigurationServiceResult.cs
+++ b/src/Umbraco.Core/HealthCheck/ConfigurationServiceResult.cs
@@ -1,4 +1,4 @@
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.HealthCheck
{
public class ConfigurationServiceResult
{
diff --git a/src/Umbraco.Core/HealthCheck/HealthCheck.cs b/src/Umbraco.Core/HealthCheck/HealthCheck.cs
index 73defd2fef..89a1f41f4d 100644
--- a/src/Umbraco.Core/HealthCheck/HealthCheck.cs
+++ b/src/Umbraco.Core/HealthCheck/HealthCheck.cs
@@ -1,24 +1,25 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
-using Umbraco.Core;
using Umbraco.Core.Composing;
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Core.HealthCheck
{
///
- /// Provides a base class for health checks.
+ /// Provides a base class for health checks, filling in the healthcheck metadata on construction
///
[DataContract(Name = "healthCheck", Namespace = "")]
public abstract class HealthCheck : IDiscoverable
{
protected HealthCheck()
{
- //Fill in the metadata
- var thisType = GetType();
- var meta = thisType.GetCustomAttribute(false);
+ Type thisType = GetType();
+ HealthCheckAttribute meta = thisType.GetCustomAttribute(false);
if (meta == null)
- throw new InvalidOperationException($"The health check {thisType} requires a {typeof (HealthCheckAttribute)}");
+ {
+ throw new InvalidOperationException($"The health check {thisType} requires a {typeof(HealthCheckAttribute)}");
+ }
+
Name = meta.Name;
Description = meta.Description;
Group = meta.Group;
@@ -49,7 +50,5 @@ namespace Umbraco.Web.HealthCheck
///
///
public abstract HealthCheckStatus ExecuteAction(HealthCheckAction action);
-
- // TODO: What else?
}
}
diff --git a/src/Umbraco.Core/HealthCheck/HealthCheckAction.cs b/src/Umbraco.Core/HealthCheck/HealthCheckAction.cs
index b64eb6746a..e1771a4262 100644
--- a/src/Umbraco.Core/HealthCheck/HealthCheckAction.cs
+++ b/src/Umbraco.Core/HealthCheck/HealthCheckAction.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Core.HealthCheck
{
[DataContract(Name = "healthCheckAction", Namespace = "")]
public class HealthCheckAction
diff --git a/src/Umbraco.Core/HealthCheck/HealthCheckAttribute.cs b/src/Umbraco.Core/HealthCheck/HealthCheckAttribute.cs
index fe206f3186..bd8c10f899 100644
--- a/src/Umbraco.Core/HealthCheck/HealthCheckAttribute.cs
+++ b/src/Umbraco.Core/HealthCheck/HealthCheckAttribute.cs
@@ -1,6 +1,6 @@
using System;
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Core.HealthCheck
{
///
/// Metadata attribute for Health checks
diff --git a/src/Umbraco.Core/HealthCheck/HealthCheckCollection.cs b/src/Umbraco.Core/HealthCheck/HealthCheckCollection.cs
index 6de442b765..fc8d5dff25 100644
--- a/src/Umbraco.Core/HealthCheck/HealthCheckCollection.cs
+++ b/src/Umbraco.Core/HealthCheck/HealthCheckCollection.cs
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using Umbraco.Core.Composing;
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Core.HealthCheck
{
- public class HealthCheckCollection : BuilderCollectionBase
+ public class HealthCheckCollection : BuilderCollectionBase
{
- public HealthCheckCollection(IEnumerable items)
+ public HealthCheckCollection(IEnumerable items)
: base(items)
{ }
}
diff --git a/src/Umbraco.Core/HealthCheck/HealthCheckGroup.cs b/src/Umbraco.Core/HealthCheck/HealthCheckGroup.cs
index f01c65f854..2cd1040896 100644
--- a/src/Umbraco.Core/HealthCheck/HealthCheckGroup.cs
+++ b/src/Umbraco.Core/HealthCheck/HealthCheckGroup.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Core.HealthCheck
{
[DataContract(Name = "healthCheckGroup", Namespace = "")]
public class HealthCheckGroup
diff --git a/src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodAttribute.cs b/src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodAttribute.cs
index d9da271d58..f78df14942 100644
--- a/src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodAttribute.cs
+++ b/src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodAttribute.cs
@@ -1,6 +1,6 @@
using System;
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Core.HealthCheck
{
///
/// Metadata attribute for health check notification methods
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationVerbosity.cs b/src/Umbraco.Core/HealthCheck/HealthCheckNotificationVerbosity.cs
similarity index 52%
rename from src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationVerbosity.cs
rename to src/Umbraco.Core/HealthCheck/HealthCheckNotificationVerbosity.cs
index 95e5ca8e03..74cd4eb93b 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationVerbosity.cs
+++ b/src/Umbraco.Core/HealthCheck/HealthCheckNotificationVerbosity.cs
@@ -1,6 +1,4 @@
-using System.Runtime.Serialization;
-
-namespace Umbraco.Core.Configuration.HealthChecks
+namespace Umbraco.Core.HealthCheck
{
public enum HealthCheckNotificationVerbosity
{
diff --git a/src/Umbraco.Core/HealthCheck/HealthCheckStatus.cs b/src/Umbraco.Core/HealthCheck/HealthCheckStatus.cs
index 245267ff8e..2eb873603f 100644
--- a/src/Umbraco.Core/HealthCheck/HealthCheckStatus.cs
+++ b/src/Umbraco.Core/HealthCheck/HealthCheckStatus.cs
@@ -2,7 +2,7 @@
using System.Linq;
using System.Runtime.Serialization;
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Core.HealthCheck
{
///
/// The status returned for a health check when it performs it check
diff --git a/src/Umbraco.Core/HealthCheck/HeathCheckCollectionBuilder.cs b/src/Umbraco.Core/HealthCheck/HeathCheckCollectionBuilder.cs
index e616ba49ae..0894cb1912 100644
--- a/src/Umbraco.Core/HealthCheck/HeathCheckCollectionBuilder.cs
+++ b/src/Umbraco.Core/HealthCheck/HeathCheckCollectionBuilder.cs
@@ -1,6 +1,6 @@
using Umbraco.Core.Composing;
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Core.HealthCheck
{
public class HealthCheckCollectionBuilder : LazyCollectionBuilderBase
{
diff --git a/src/Umbraco.Core/HealthCheck/IConfigurationService.cs b/src/Umbraco.Core/HealthCheck/IConfigurationService.cs
new file mode 100644
index 0000000000..dc513bb765
--- /dev/null
+++ b/src/Umbraco.Core/HealthCheck/IConfigurationService.cs
@@ -0,0 +1,7 @@
+namespace Umbraco.Core.HealthCheck
+{
+ public interface IConfigurationService
+ {
+ ConfigurationServiceResult UpdateConfigFile(string value, string itemPath);
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/INotificationMethod.cs b/src/Umbraco.Core/HealthCheck/INotificationMethod.cs
similarity index 86%
rename from src/Umbraco.Core/Configuration/HealthChecks/INotificationMethod.cs
rename to src/Umbraco.Core/HealthCheck/INotificationMethod.cs
index 84bf55e160..9c4ec70cfe 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/INotificationMethod.cs
+++ b/src/Umbraco.Core/HealthCheck/INotificationMethod.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
-namespace Umbraco.Core.Configuration.HealthChecks
+namespace Umbraco.Core.HealthCheck
{
public interface INotificationMethod
{
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/INotificationMethodSettings.cs b/src/Umbraco.Core/HealthCheck/INotificationMethodSettings.cs
similarity index 69%
rename from src/Umbraco.Core/Configuration/HealthChecks/INotificationMethodSettings.cs
rename to src/Umbraco.Core/HealthCheck/INotificationMethodSettings.cs
index e41c82b393..01ad667d94 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/INotificationMethodSettings.cs
+++ b/src/Umbraco.Core/HealthCheck/INotificationMethodSettings.cs
@@ -1,4 +1,4 @@
-namespace Umbraco.Core.Configuration.HealthChecks
+namespace Umbraco.Core.HealthCheck
{
public interface INotificationMethodSettings
{
diff --git a/src/Umbraco.Core/HealthCheck/StatusResultType.cs b/src/Umbraco.Core/HealthCheck/StatusResultType.cs
index c6bd50f247..3f2c392933 100644
--- a/src/Umbraco.Core/HealthCheck/StatusResultType.cs
+++ b/src/Umbraco.Core/HealthCheck/StatusResultType.cs
@@ -1,4 +1,4 @@
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Core.HealthCheck
{
public enum StatusResultType
{
diff --git a/src/Umbraco.Core/Configuration/HealthChecks/ValueComparisonType.cs b/src/Umbraco.Core/HealthCheck/ValueComparisonType.cs
similarity index 65%
rename from src/Umbraco.Core/Configuration/HealthChecks/ValueComparisonType.cs
rename to src/Umbraco.Core/HealthCheck/ValueComparisonType.cs
index 8df40da9f9..c5dd6517a8 100644
--- a/src/Umbraco.Core/Configuration/HealthChecks/ValueComparisonType.cs
+++ b/src/Umbraco.Core/HealthCheck/ValueComparisonType.cs
@@ -1,4 +1,4 @@
-namespace Umbraco.Web.HealthCheck.Checks.Config
+namespace Umbraco.Core.HealthCheck
{
public enum ValueComparisonType
{
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 07dea8d299..2b3efc9349 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -15,6 +15,7 @@
+
diff --git a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs b/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs
index 7eebf61b22..1561645be9 100644
--- a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs
+++ b/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs
@@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using HeyRed.MarkdownSharp;
-using Umbraco.Composing;
-using Umbraco.Core.Configuration.HealthChecks;
using Microsoft.Extensions.Logging;
+using Umbraco.Composing;
+using Umbraco.Core.HealthCheck;
-namespace Umbraco.Web.HealthCheck
+namespace Umbraco.Infrastructure.HealthCheck
{
public class HealthCheckResults
{
@@ -16,7 +16,7 @@ namespace Umbraco.Web.HealthCheck
private ILogger Logger => Current.Logger; // TODO: inject
- public HealthCheckResults(IEnumerable checks)
+ public HealthCheckResults(IEnumerable checks)
{
_results = checks.ToDictionary(
t => t.Name,
diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs
index 480654eade..8060e7c257 100644
--- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs
+++ b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs
@@ -5,9 +5,10 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Umbraco.Core;
using Umbraco.Core.Configuration;
-using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Configuration.Models;
+using Umbraco.Core.HealthCheck;
using Umbraco.Core.Services;
+using Umbraco.Infrastructure.HealthCheck;
namespace Umbraco.Web.HealthCheck.NotificationMethods
{
diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs
index f6e8f1d1c5..fdf72251be 100644
--- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs
+++ b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs
@@ -1,6 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using Umbraco.Core.Composing;
+using Umbraco.Infrastructure.HealthCheck;
namespace Umbraco.Web.HealthCheck.NotificationMethods
{
diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs
index 2c0c5bcc1f..39025df2ab 100644
--- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs
+++ b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs
@@ -3,8 +3,10 @@ using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
-using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Configuration.Models;
+using Umbraco.Core.HealthCheck;
+using Umbraco.Core.HealthCheck.Checks;
+using Umbraco.Infrastructure.HealthCheck;
namespace Umbraco.Web.HealthCheck.NotificationMethods
{
diff --git a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
index 0a57954c62..f3357b19bb 100644
--- a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
+++ b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
@@ -58,7 +58,9 @@ using Umbraco.Web.Trees;
using IntegerValidator = Umbraco.Core.PropertyEditors.Validators.IntegerValidator;
using TextStringValueConverter = Umbraco.Core.PropertyEditors.ValueConverters.TextStringValueConverter;
using Microsoft.Extensions.Logging;
-
+using Umbraco.Core.Configuration.HealthChecks;
+using Umbraco.Core.HealthCheck;
+using Umbraco.Core.HealthCheck.Checks;
namespace Umbraco.Core.Runtime
{
@@ -205,7 +207,7 @@ namespace Umbraco.Core.Runtime
// Config manipulator
composition.RegisterUnique();
-
+
// register the umbraco context factory
// composition.RegisterUnique();
composition.RegisterUnique();
@@ -298,7 +300,7 @@ namespace Umbraco.Core.Runtime
// register *all* checks, except those marked [HideFromTypeFinder] of course
composition.HealthChecks()
- .Add(() => composition.TypeLoader.GetTypes());
+ .Add(() => composition.TypeLoader.GetTypes());
composition.WithCollectionBuilder()
diff --git a/src/Umbraco.Infrastructure/Scheduling/HealthCheckNotifier.cs b/src/Umbraco.Infrastructure/Scheduling/HealthCheckNotifier.cs
index 6198e7845d..33eff2c949 100644
--- a/src/Umbraco.Infrastructure/Scheduling/HealthCheckNotifier.cs
+++ b/src/Umbraco.Infrastructure/Scheduling/HealthCheckNotifier.cs
@@ -3,11 +3,13 @@ using System.Threading;
using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Core.Configuration.Models;
+using Umbraco.Core.HealthCheck;
using Umbraco.Core.Logging;
using Umbraco.Core.Scoping;
using Umbraco.Core.Sync;
using Umbraco.Web.HealthCheck;
using Microsoft.Extensions.Logging;
+using Umbraco.Infrastructure.HealthCheck;
namespace Umbraco.Web.Scheduling
{
diff --git a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs
index d1dea43469..05dcbec793 100644
--- a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs
+++ b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs
@@ -7,8 +7,8 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Core;
using Umbraco.Core.Composing;
-using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Configuration.Models;
+using Umbraco.Core.HealthCheck;
using Umbraco.Core.Hosting;
using Umbraco.Core.Logging;
using Umbraco.Core.Scoping;
diff --git a/src/Umbraco.Infrastructure/Services/Implement/PropertyValidationService.cs b/src/Umbraco.Infrastructure/Services/Implement/PropertyValidationService.cs
index a17cdb034d..c08c1322d3 100644
--- a/src/Umbraco.Infrastructure/Services/Implement/PropertyValidationService.cs
+++ b/src/Umbraco.Infrastructure/Services/Implement/PropertyValidationService.cs
@@ -21,7 +21,6 @@ namespace Umbraco.Core.Services
_textService = textService;
}
-
public IEnumerable ValidatePropertyValue(
IPropertyType propertyType,
object postedValue)
diff --git a/src/Umbraco.Tests.Common/Builders/ContentBuilder.cs b/src/Umbraco.Tests.Common/Builders/ContentBuilder.cs
index 9f30005c55..283b2b6c04 100644
--- a/src/Umbraco.Tests.Common/Builders/ContentBuilder.cs
+++ b/src/Umbraco.Tests.Common/Builders/ContentBuilder.cs
@@ -30,6 +30,7 @@ namespace Umbraco.Tests.Common.Builders
private GenericDictionaryBuilder _propertyDataBuilder;
private int? _id;
+ private int? _versionId;
private Guid? _key;
private DateTime? _createDate;
private DateTime? _updateDate;
@@ -48,12 +49,10 @@ namespace Umbraco.Tests.Common.Builders
private string _propertyValuesCulture;
private string _propertyValuesSegment;
- public ContentTypeBuilder AddContentType()
+ public ContentBuilder WithVersionId(int versionId)
{
- _contentType = null;
- var builder = new ContentTypeBuilder(this);
- _contentTypeBuilder = builder;
- return builder;
+ _versionId = versionId;
+ return this;
}
public ContentBuilder WithParent(IContent parent)
@@ -87,6 +86,14 @@ namespace Umbraco.Tests.Common.Builders
return this;
}
+ public ContentTypeBuilder AddContentType()
+ {
+ _contentType = null;
+ var builder = new ContentTypeBuilder(this);
+ _contentTypeBuilder = builder;
+ return builder;
+ }
+
public GenericDictionaryBuilder AddPropertyData()
{
var builder = new GenericDictionaryBuilder(this);
@@ -97,6 +104,7 @@ namespace Umbraco.Tests.Common.Builders
public override Content Build()
{
var id = _id ?? 0;
+ var versionId = _versionId ?? 0;
var key = _key ?? Guid.NewGuid();
var parentId = _parentId ?? -1;
var parent = _parent ?? null;
@@ -131,6 +139,7 @@ namespace Umbraco.Tests.Common.Builders
}
content.Id = id;
+ content.VersionId = versionId;
content.Key = key;
content.CreateDate = createDate;
content.UpdateDate = updateDate;
diff --git a/src/Umbraco.Tests.Common/Builders/ContentTypeBuilder.cs b/src/Umbraco.Tests.Common/Builders/ContentTypeBuilder.cs
index eb4192364f..fca148f542 100644
--- a/src/Umbraco.Tests.Common/Builders/ContentTypeBuilder.cs
+++ b/src/Umbraco.Tests.Common/Builders/ContentTypeBuilder.cs
@@ -20,6 +20,7 @@ namespace Umbraco.Tests.Common.Builders
private int? _propertyTypeIdsIncrementingFrom;
private int? _defaultTemplateId;
private ContentVariation? _contentVariation;
+ private PropertyTypeCollection _propertyTypeCollection;
public ContentTypeBuilder() : base(null)
{
@@ -41,6 +42,12 @@ namespace Umbraco.Tests.Common.Builders
return this;
}
+ public ContentTypeBuilder WithPropertyTypeCollection(PropertyTypeCollection propertyTypeCollection)
+ {
+ _propertyTypeCollection = propertyTypeCollection;
+ return this;
+ }
+
public PropertyGroupBuilder AddPropertyGroup()
{
var builder = new PropertyGroupBuilder(this);
@@ -104,9 +111,21 @@ namespace Umbraco.Tests.Common.Builders
contentType.Variations = contentVariation;
- contentType.NoGroupPropertyTypes = _noGroupPropertyTypeBuilders.Select(x => x.Build());
- BuildPropertyGroups(contentType, _propertyGroupBuilders.Select(x => x.Build()));
- BuildPropertyTypeIds(contentType, _propertyTypeIdsIncrementingFrom);
+ if (_propertyTypeCollection != null)
+ {
+ var propertyGroup = new PropertyGroupBuilder()
+ .WithName("Content")
+ .WithSortOrder(1)
+ .WithPropertyTypeCollection(_propertyTypeCollection)
+ .Build();
+ contentType.PropertyGroups.Add(propertyGroup);
+ }
+ else
+ {
+ contentType.NoGroupPropertyTypes = _noGroupPropertyTypeBuilders.Select(x => x.Build());
+ BuildPropertyGroups(contentType, _propertyGroupBuilders.Select(x => x.Build()));
+ BuildPropertyTypeIds(contentType, _propertyTypeIdsIncrementingFrom);
+ }
contentType.AllowedContentTypes = _allowedContentTypeBuilders.Select(x => x.Build());
@@ -134,7 +153,7 @@ namespace Umbraco.Tests.Common.Builders
public static ContentType CreateSimpleContentType2(string alias, string name, IContentType parent = null, bool randomizeAliases = false, string propertyGroupName = "Content")
{
- var builder = CreateSimpleContentTypeHelper(alias, name, parent, randomizeAliases, propertyGroupName);
+ var builder = CreateSimpleContentTypeHelper(alias, name, parent, randomizeAliases: randomizeAliases, propertyGroupName: propertyGroupName);
builder.AddPropertyType()
.WithAlias(RandomAlias("gen", randomizeAliases))
@@ -146,54 +165,70 @@ namespace Umbraco.Tests.Common.Builders
.Done();
return (ContentType)builder.Build();
- }public static ContentType CreateSimpleContentType(string alias = null, string name = null, IContentType parent = null, bool randomizeAliases = false, string propertyGroupName = "Content", bool mandatoryProperties = false, int defaultTemplateId = 0)
- {
- return (ContentType)CreateSimpleContentTypeHelper(alias, name, parent, randomizeAliases, propertyGroupName, mandatoryProperties, defaultTemplateId).Build();
}
- public static ContentTypeBuilder CreateSimpleContentTypeHelper(string alias = null, string name = null, IContentType parent = null, bool randomizeAliases = false, string propertyGroupName = "Content", bool mandatoryProperties = false, int defaultTemplateId = 0)
+ public static ContentType CreateSimpleContentType(string alias = null, string name = null, IContentType parent = null, PropertyTypeCollection propertyTypeCollection = null, bool randomizeAliases = false, string propertyGroupName = "Content", bool mandatoryProperties = false, int defaultTemplateId = 0)
{
- return new ContentTypeBuilder()
+ return (ContentType)CreateSimpleContentTypeHelper(alias, name, parent, propertyTypeCollection, randomizeAliases, propertyGroupName, mandatoryProperties, defaultTemplateId).Build();
+ }
+
+ public static ContentTypeBuilder CreateSimpleContentTypeHelper(string alias = null, string name = null, IContentType parent = null, PropertyTypeCollection propertyTypeCollection = null, bool randomizeAliases = false, string propertyGroupName = "Content", bool mandatoryProperties = false, int defaultTemplateId = 0)
+ {
+ var builder = new ContentTypeBuilder()
.WithAlias(alias ?? "simple")
.WithName(name ?? "Simple Page")
- .WithParentContentType(parent)
- .AddPropertyGroup()
- .WithName(propertyGroupName)
- .WithSortOrder(1)
- .WithSupportsPublishing(true)
- .AddPropertyType()
- .WithAlias(RandomAlias("title", randomizeAliases))
- .WithName("Title")
+ .WithParentContentType(parent);
+
+ if (propertyTypeCollection != null)
+ {
+ builder = builder
+ .WithPropertyTypeCollection(propertyTypeCollection);
+ }
+ else
+ {
+ builder = builder
+ .AddPropertyGroup()
+ .WithName(propertyGroupName)
.WithSortOrder(1)
- .WithMandatory(mandatoryProperties)
- .Done()
- .AddPropertyType()
- .WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TinyMce)
- .WithValueStorageType(ValueStorageType.Ntext)
- .WithAlias(RandomAlias("bodyText", randomizeAliases))
- .WithName("Body text")
- .WithSortOrder(2)
- .WithDataTypeId(Constants.DataTypes.RichtextEditor)
- .WithMandatory(mandatoryProperties)
- .Done()
- .AddPropertyType()
- .WithAlias(RandomAlias("author", randomizeAliases))
- .WithName("Author")
- .WithSortOrder(3)
- .WithMandatory(mandatoryProperties)
- .Done()
+ .WithSupportsPublishing(true)
+ .AddPropertyType()
+ .WithAlias(RandomAlias("title", randomizeAliases))
+ .WithName("Title")
+ .WithSortOrder(1)
+ .WithMandatory(mandatoryProperties)
+ .Done()
+ .AddPropertyType()
+ .WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.TinyMce)
+ .WithValueStorageType(ValueStorageType.Ntext)
+ .WithAlias(RandomAlias("bodyText", randomizeAliases))
+ .WithName("Body text")
+ .WithSortOrder(2)
+ .WithDataTypeId(Constants.DataTypes.RichtextEditor)
+ .WithMandatory(mandatoryProperties)
+ .Done()
+ .AddPropertyType()
+ .WithAlias(RandomAlias("author", randomizeAliases))
+ .WithName("Author")
+ .WithSortOrder(3)
+ .WithMandatory(mandatoryProperties)
+ .Done()
+ .Done();
+ }
+
+ builder = builder
+ .AddAllowedTemplate()
+ .WithId(defaultTemplateId)
+ .WithAlias("textPage")
+ .WithName("Textpage")
.Done()
- .AddAllowedTemplate()
- .WithId(defaultTemplateId)
- .WithAlias("textPage")
- .WithName("Textpage")
- .Done()
- .WithDefaultTemplateId(defaultTemplateId);
+ .WithDefaultTemplateId(defaultTemplateId);
+
+ return builder;
}
public static ContentType CreateSimpleTagsContentType(string alias, string name, IContentType parent = null, bool randomizeAliases = false, string propertyGroupName = "Content", int defaultTemplateId = 1)
{
- var contentType = CreateSimpleContentType(alias, name, parent, randomizeAliases, propertyGroupName, defaultTemplateId: defaultTemplateId);
+ var contentType = CreateSimpleContentType(alias, name, parent, randomizeAliases: randomizeAliases, propertyGroupName: propertyGroupName, defaultTemplateId: defaultTemplateId);
var propertyType = new PropertyTypeBuilder()
.WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.Tags)
@@ -215,7 +250,6 @@ namespace Umbraco.Tests.Common.Builders
.WithAlias(alias)
.WithName(name)
.AddPropertyGroup()
- .WithId(1)
.WithName("Content")
.WithSortOrder(1)
.WithSupportsPublishing(true)
@@ -234,7 +268,6 @@ namespace Umbraco.Tests.Common.Builders
.Done()
.Done()
.AddPropertyGroup()
- .WithId(2)
.WithName("Meta")
.WithSortOrder(2)
.WithSupportsPublishing(true)
diff --git a/src/Umbraco.Tests.Common/Builders/PropertyBuilder.cs b/src/Umbraco.Tests.Common/Builders/PropertyBuilder.cs
index 6cb7a431f2..a79141b11c 100644
--- a/src/Umbraco.Tests.Common/Builders/PropertyBuilder.cs
+++ b/src/Umbraco.Tests.Common/Builders/PropertyBuilder.cs
@@ -18,9 +18,18 @@ namespace Umbraco.Tests.Common.Builders
private Guid? _key;
private DateTime? _createDate;
private DateTime? _updateDate;
+ private IPropertyType _propertyType;
+
+ public PropertyBuilder WithPropertyType(IPropertyType propertyType)
+ {
+ _propertyTypeBuilder = null;
+ _propertyType = propertyType;
+ return this;
+ }
public PropertyTypeBuilder AddPropertyType()
{
+ _propertyType = null;
var builder = new PropertyTypeBuilder(this);
_propertyTypeBuilder = builder;
return builder;
@@ -33,8 +42,15 @@ namespace Umbraco.Tests.Common.Builders
var createDate = _createDate ?? DateTime.Now;
var updateDate = _updateDate ?? DateTime.Now;
+ if (_propertyTypeBuilder is null && _propertyType is null)
+ {
+ throw new InvalidOperationException("A property cannot be constructed without providing a property type. Use AddPropertyType() or WithPropertyType().");
+ }
+
+ var propertyType = _propertyType ?? _propertyTypeBuilder.Build();
+
// Needs to be within collection to support publishing.
- var propertyTypeCollection = new PropertyTypeCollection(true, new[] { _propertyTypeBuilder.Build() });
+ var propertyTypeCollection = new PropertyTypeCollection(true, new[] { propertyType });
return new Property(id, propertyTypeCollection[0])
{
diff --git a/src/Umbraco.Tests.Common/Builders/PropertyGroupBuilder.cs b/src/Umbraco.Tests.Common/Builders/PropertyGroupBuilder.cs
index f153283764..8fe6e1463d 100644
--- a/src/Umbraco.Tests.Common/Builders/PropertyGroupBuilder.cs
+++ b/src/Umbraco.Tests.Common/Builders/PropertyGroupBuilder.cs
@@ -37,11 +37,18 @@ namespace Umbraco.Tests.Common.Builders
private string _name;
private int? _sortOrder;
private bool? _supportsPublishing;
+ private PropertyTypeCollection _propertyTypeCollection;
public PropertyGroupBuilder(TParent parentBuilder) : base(parentBuilder)
{
}
+ public PropertyGroupBuilder WithPropertyTypeCollection(PropertyTypeCollection propertyTypeCollection)
+ {
+ _propertyTypeCollection = propertyTypeCollection;
+ return this;
+ }
+
public PropertyTypeBuilder> AddPropertyType()
{
var builder = new PropertyTypeBuilder>(this);
@@ -51,7 +58,7 @@ namespace Umbraco.Tests.Common.Builders
public override PropertyGroup Build()
{
- var id = _id ?? 1;
+ var id = _id ?? 0;
var key = _key ?? Guid.NewGuid();
var createDate = _createDate ?? DateTime.Now;
var updateDate = _updateDate ?? DateTime.Now;
@@ -59,13 +66,21 @@ namespace Umbraco.Tests.Common.Builders
var sortOrder = _sortOrder ?? 0;
var supportsPublishing = _supportsPublishing ?? false;
- var properties = new PropertyTypeCollection(supportsPublishing);
- foreach (var propertyType in _propertyTypeBuilders.Select(x => x.Build()))
+ PropertyTypeCollection propertyTypeCollection;
+ if (_propertyTypeCollection != null)
{
- properties.Add(propertyType);
+ propertyTypeCollection = _propertyTypeCollection;
+ }
+ else
+ {
+ propertyTypeCollection = new PropertyTypeCollection(supportsPublishing);
+ foreach (var propertyType in _propertyTypeBuilders.Select(x => x.Build()))
+ {
+ propertyTypeCollection.Add(propertyType);
+ }
}
- return new PropertyGroup(properties)
+ return new PropertyGroup(propertyTypeCollection)
{
Id = id,
Key = key,
diff --git a/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs b/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs
index 954dedd3b4..78aa0c7bc6 100644
--- a/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs
+++ b/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs
@@ -1,4 +1,4 @@
-using Moq;
+using Moq;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
diff --git a/src/Umbraco.Tests.Common/Testing/UmbracoTestAttribute.cs b/src/Umbraco.Tests.Common/Testing/UmbracoTestAttribute.cs
index 3a0ce39493..9248a45d78 100644
--- a/src/Umbraco.Tests.Common/Testing/UmbracoTestAttribute.cs
+++ b/src/Umbraco.Tests.Common/Testing/UmbracoTestAttribute.cs
@@ -50,7 +50,7 @@ namespace Umbraco.Tests.Testing
///
/// Default is to use the global tests plugin manager.
public UmbracoTestOptions.TypeLoader TypeLoader { get => _typeLoader.ValueOrDefault(UmbracoTestOptions.TypeLoader.Default); set => _typeLoader.Set(value); }
- public bool Boot { get => _boot.ValueOrDefault(true); set => _boot.Set(value); }
+ public bool Boot { get => _boot.ValueOrDefault(false); set => _boot.Set(value); }
private readonly Settable _boot = new Settable();
diff --git a/src/Umbraco.Tests/Logging/LogviewerTests.cs b/src/Umbraco.Tests.Integration/Logging/LogviewerTests.cs
similarity index 97%
rename from src/Umbraco.Tests/Logging/LogviewerTests.cs
rename to src/Umbraco.Tests.Integration/Logging/LogviewerTests.cs
index 04d0150f75..fd861eca2e 100644
--- a/src/Umbraco.Tests/Logging/LogviewerTests.cs
+++ b/src/Umbraco.Tests.Integration/Logging/LogviewerTests.cs
@@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
using Umbraco.Core;
using Umbraco.Core.Logging.Viewer;
using Umbraco.Tests.TestHelpers;
+using Umbraco.Tests.Integration.Implementations;
namespace Umbraco.Tests.Logging
{
@@ -34,10 +35,11 @@ namespace Umbraco.Tests.Logging
{
//Create an example JSON log file to check results
//As a one time setup for all tets in this class/fixture
- var ioHelper = TestHelper.IOHelper;
- var hostingEnv = TestHelper.GetHostingEnvironment();
+ var testHelper = new TestHelper();
+ var ioHelper = testHelper.IOHelper;
+ var hostingEnv = testHelper.GetHostingEnvironment();
- var loggingConfiguration = TestHelper.GetLoggingConfiguration(hostingEnv);
+ var loggingConfiguration = testHelper.GetLoggingConfiguration(hostingEnv);
var exampleLogfilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"Logging\", _logfileName);
_newLogfileDirPath = loggingConfiguration.LogDirectory;
diff --git a/src/Umbraco.Tests/Logging/UmbracoTraceLog.UNITTEST.20181112.json b/src/Umbraco.Tests.Integration/Logging/UmbracoTraceLog.UNITTEST.20181112.json
similarity index 100%
rename from src/Umbraco.Tests/Logging/UmbracoTraceLog.UNITTEST.20181112.json
rename to src/Umbraco.Tests.Integration/Logging/UmbracoTraceLog.UNITTEST.20181112.json
diff --git a/src/Umbraco.Tests/Logging/logviewer.searches.config.js b/src/Umbraco.Tests.Integration/Logging/logviewer.searches.config.js
similarity index 100%
rename from src/Umbraco.Tests/Logging/logviewer.searches.config.js
rename to src/Umbraco.Tests.Integration/Logging/logviewer.searches.config.js
diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
index c50d292c97..ab1d577563 100644
--- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
+++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
@@ -92,7 +92,8 @@ namespace Umbraco.Tests.Integration.Testing
var host = hostBuilder.StartAsync().GetAwaiter().GetResult();
Services = host.Services;
var app = new ApplicationBuilder(host.Services);
- Configure(app);
+ Configure(app); //Takes around 200 ms
+
OnFixtureTearDown(() => host.Dispose());
}
@@ -274,14 +275,13 @@ namespace Umbraco.Tests.Integration.Testing
public virtual void Configure(IApplicationBuilder app)
{
- Services.GetRequiredService().EnsureBackOfficeSecurity();
- Services.GetRequiredService().EnsureUmbracoContext();
-
- // get the currently set options
+ //get the currently set options
var testOptions = TestOptionAttributeBase.GetTestOptions();
if (testOptions.Boot)
{
- app.UseUmbracoCore();
+ Services.GetRequiredService().EnsureBackOfficeSecurity();
+ Services.GetRequiredService().EnsureUmbracoContext();
+ app.UseUmbracoCore(); // Takes 200 ms
}
}
@@ -448,7 +448,7 @@ namespace Umbraco.Tests.Integration.Testing
public TestHelper TestHelper = new TestHelper();
- protected string TestDBConnectionString { get; private set; }
+ protected virtual string TestDBConnectionString { get; private set; }
protected virtual Action CustomTestSetup => services => { };
diff --git a/src/Umbraco.Tests.Integration/Mapping/ContentTypeModelMappingTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Core/Mapping/ContentTypeModelMappingTests.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Mapping/ContentTypeModelMappingTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Core/Mapping/ContentTypeModelMappingTests.cs
index 96e49e79e9..03e8f04cfc 100644
--- a/src/Umbraco.Tests.Integration/Mapping/ContentTypeModelMappingTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Core/Mapping/ContentTypeModelMappingTests.cs
@@ -13,7 +13,7 @@ using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Umbraco.Web.Models.ContentEditing;
-namespace Umbraco.Tests.Models.Mapping
+namespace Umbraco.Tests.Integration.Umbraco.Core.Mapping
{
[TestFixture]
[UmbracoTest(Mapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
@@ -756,7 +756,7 @@ namespace Umbraco.Tests.Models.Mapping
Alias = "umbracoUrlName", Name = "Slug", Description = "", Mandatory = false, SortOrder = 1, DataTypeId = -88
});
ContentTypeBuilder.EnsureAllIds(ctMain, 8888);
- var ctChild1 = ContentTypeBuilder.CreateSimpleContentType("child1", "Child 1", ctMain, true);
+ var ctChild1 = ContentTypeBuilder.CreateSimpleContentType("child1", "Child 1", ctMain, randomizeAliases: true);
ctChild1.AddPropertyType(new PropertyType(ShortStringHelper, Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Ntext)
{
Alias = "someProperty",
@@ -767,7 +767,7 @@ namespace Umbraco.Tests.Models.Mapping
DataTypeId = -88
}, "Another tab");
ContentTypeBuilder.EnsureAllIds(ctChild1, 7777);
- var contentType = ContentTypeBuilder.CreateSimpleContentType("child2", "Child 2", ctChild1, true, "CustomGroup");
+ var contentType = ContentTypeBuilder.CreateSimpleContentType("child2", "Child 2", ctChild1, randomizeAliases: true, propertyGroupName: "CustomGroup");
//not assigned to tab
contentType.AddPropertyType(new PropertyType(ShortStringHelper, Constants.PropertyEditors.Aliases.TextBox, ValueStorageType.Ntext)
{
diff --git a/src/Umbraco.Tests.Integration/Mapping/UmbracoMapperTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Core/Mapping/UmbracoMapperTests.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Mapping/UmbracoMapperTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Core/Mapping/UmbracoMapperTests.cs
index 2b26c862f0..4028889b01 100644
--- a/src/Umbraco.Tests.Integration/Mapping/UmbracoMapperTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Core/Mapping/UmbracoMapperTests.cs
@@ -13,7 +13,7 @@ using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Umbraco.Web.Models.ContentEditing;
-namespace Umbraco.Tests.Integration.Mapping
+namespace Umbraco.Tests.Integration.Umbraco.Core.Mapping
{
[TestFixture]
[UmbracoTest(Mapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Mapping/UserModelMapperTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Core/Mapping/UserModelMapperTests.cs
similarity index 97%
rename from src/Umbraco.Tests.Integration/Mapping/UserModelMapperTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Core/Mapping/UserModelMapperTests.cs
index e24a8a74bc..f8c276d429 100644
--- a/src/Umbraco.Tests.Integration/Mapping/UserModelMapperTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Core/Mapping/UserModelMapperTests.cs
@@ -8,7 +8,7 @@ using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Umbraco.Web.Models.ContentEditing;
-namespace Umbraco.Tests.Models.Mapping
+namespace Umbraco.Tests.Integration.Umbraco.Core.Mapping
{
[TestFixture]
[UmbracoTest(Mapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Packaging/CreatedPackagesRepositoryTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Core/Packaging/CreatedPackagesRepositoryTests.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Packaging/CreatedPackagesRepositoryTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Core/Packaging/CreatedPackagesRepositoryTests.cs
index 2500dd97a4..6f3702765e 100644
--- a/src/Umbraco.Tests.Integration/Packaging/CreatedPackagesRepositoryTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Core/Packaging/CreatedPackagesRepositoryTests.cs
@@ -15,7 +15,7 @@ using Umbraco.Core.Services;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Packaging
+namespace Umbraco.Tests.Integration.Umbraco.Core.Packaging
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
diff --git a/src/Umbraco.Tests.Integration/Packaging/Packages/Document_Type_Picker_1.1.umb b/src/Umbraco.Tests.Integration/Umbraco.Core/Packaging/Packages/Document_Type_Picker_1.1.umb
similarity index 100%
rename from src/Umbraco.Tests.Integration/Packaging/Packages/Document_Type_Picker_1.1.umb
rename to src/Umbraco.Tests.Integration/Umbraco.Core/Packaging/Packages/Document_Type_Picker_1.1.umb
diff --git a/src/Umbraco.Tests.Integration/Services/SectionServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Core/Services/SectionServiceTests.cs
similarity index 97%
rename from src/Umbraco.Tests.Integration/Services/SectionServiceTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Core/Services/SectionServiceTests.cs
index f34ea32cff..24a4e8d772 100644
--- a/src/Umbraco.Tests.Integration/Services/SectionServiceTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Core/Services/SectionServiceTests.cs
@@ -8,7 +8,7 @@ using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Umbraco.Web.Services;
-namespace Umbraco.Tests.Integration.Services
+namespace Umbraco.Tests.Integration.Umbraco.Core.Services
{
///
/// Tests covering the SectionService
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/AuditRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/AuditRepositoryTest.cs
similarity index 98%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/AuditRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/AuditRepositoryTest.cs
index 24316eb931..d62e0623b1 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/AuditRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/AuditRepositoryTest.cs
@@ -10,7 +10,7 @@ using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Microsoft.Extensions.Logging;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/ContentTypeRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ContentTypeRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/ContentTypeRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ContentTypeRepositoryTest.cs
index f265519e28..757e79eef3 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/ContentTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ContentTypeRepositoryTest.cs
@@ -24,7 +24,7 @@ using Umbraco.Tests.TestHelpers.Entities;
using Umbraco.Tests.Testing;
using Umbraco.Web.Models.ContentEditing;
-namespace Umbraco.Tests.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Mapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
@@ -519,8 +519,8 @@ namespace Umbraco.Tests.Persistence.Repositories
{
var repository = ContentTypeRepository;
var ctMain = ContentTypeBuilder.CreateSimpleContentType(defaultTemplateId:0);
- var ctChild1 = ContentTypeBuilder.CreateSimpleContentType("child1", "Child 1", ctMain, true, defaultTemplateId:0);
- var ctChild2 = ContentTypeBuilder.CreateSimpleContentType("child2", "Child 2", ctChild1, true, defaultTemplateId:0);
+ var ctChild1 = ContentTypeBuilder.CreateSimpleContentType("child1", "Child 1", ctMain, randomizeAliases: true, defaultTemplateId: 0);
+ var ctChild2 = ContentTypeBuilder.CreateSimpleContentType("child2", "Child 2", ctChild1, randomizeAliases: true, defaultTemplateId: 0);
repository.Save(ctMain);
repository.Save(ctChild1);
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
index 6d991117a1..5b39eb9864 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
@@ -9,7 +9,7 @@ using Umbraco.Core.Services;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Web.PropertyEditors;
-namespace Umbraco.Tests.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/DictionaryRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DictionaryRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/DictionaryRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DictionaryRepositoryTest.cs
index 4d5bdac6b4..105d7520fd 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/DictionaryRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DictionaryRepositoryTest.cs
@@ -9,7 +9,7 @@ using Umbraco.Core.Services;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/DocumentRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/DocumentRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentRepositoryTest.cs
index 7dff775c8f..5cf402be26 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/DocumentRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentRepositoryTest.cs
@@ -5,22 +5,20 @@ using Microsoft.Extensions.Logging;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
+using Umbraco.Core.Configuration.Models;
+using Umbraco.Core.IO;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
-using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Scoping;
using Umbraco.Core.Services;
-using Umbraco.Tests.Testing;
-using Umbraco.Web.PropertyEditors;
-using Umbraco.Core.Configuration.Models;
-using Umbraco.Core.IO;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Testing;
+using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
@@ -36,8 +34,6 @@ namespace Umbraco.Tests.Persistence.Repositories
private IContentTypeService ContentTypeService => GetRequiredService();
private IFileService FileService => GetRequiredService();
private IDataTypeService DataTypeService => GetRequiredService();
- private ILocalizedTextService LocalizedTextService => GetRequiredService();
- private ILocalizationService LocalizationService => GetRequiredService();
private IFileSystems FileSystems => GetRequiredService();
[SetUp]
@@ -45,6 +41,9 @@ namespace Umbraco.Tests.Persistence.Repositories
{
CreateTestData();
+ // TODO: remove this once IPublishedSnapShotService has been implemented with nucache.
+ global::Umbraco.Core.Services.Implement.ContentTypeService.ClearScopeEvents();
+
ContentRepositoryBase.ThrowOnWarning = true;
}
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/EntityRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/EntityRepositoryTest.cs
similarity index 97%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/EntityRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/EntityRepositoryTest.cs
index c0da3ec8cd..3fb518661c 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/EntityRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/EntityRepositoryTest.cs
@@ -11,7 +11,7 @@ using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Mapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/KeyValueRepositoryTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/KeyValueRepositoryTests.cs
similarity index 96%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/KeyValueRepositoryTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/KeyValueRepositoryTests.cs
index 1b5b40cf3c..93b6ee43f5 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/KeyValueRepositoryTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/KeyValueRepositoryTests.cs
@@ -8,7 +8,7 @@ using Umbraco.Core.Scoping;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/LanguageRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/LanguageRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/LanguageRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/LanguageRepositoryTest.cs
index 0b699823cb..aa9c0ddc86 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/LanguageRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/LanguageRepositoryTest.cs
@@ -13,7 +13,7 @@ using Umbraco.Core.Services;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/MacroRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/MacroRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/MacroRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/MacroRepositoryTest.cs
index 901d905686..e68f9584fb 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/MacroRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/MacroRepositoryTest.cs
@@ -10,7 +10,7 @@ using Umbraco.Core.Scoping;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/NotificationsRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/NotificationsRepositoryTest.cs
similarity index 98%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/NotificationsRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/NotificationsRepositoryTest.cs
index 2735f869c0..f784390ced 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/NotificationsRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/NotificationsRepositoryTest.cs
@@ -12,7 +12,7 @@ using Umbraco.Core.Scoping;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/RedirectUrlRepositoryTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/RedirectUrlRepositoryTests.cs
similarity index 98%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/RedirectUrlRepositoryTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/RedirectUrlRepositoryTests.cs
index ea1a7ed8db..8ae792b92f 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/RedirectUrlRepositoryTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/RedirectUrlRepositoryTests.cs
@@ -11,7 +11,7 @@ using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/RelationRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/RelationRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/RelationRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/RelationRepositoryTest.cs
index 63e4ada345..1989478186 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/RelationRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/RelationRepositoryTest.cs
@@ -19,7 +19,7 @@ using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/RelationTypeRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/RelationTypeRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/RelationTypeRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/RelationTypeRepositoryTest.cs
index 6a93d73713..8d436eeeed 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/RelationTypeRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/RelationTypeRepositoryTest.cs
@@ -9,7 +9,7 @@ using Umbraco.Core.Scoping;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/ServerRegistrationRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ServerRegistrationRepositoryTest.cs
similarity index 98%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/ServerRegistrationRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ServerRegistrationRepositoryTest.cs
index 3107770672..e5304e1e31 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/ServerRegistrationRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ServerRegistrationRepositoryTest.cs
@@ -10,7 +10,7 @@ using Umbraco.Core.Scoping;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/SimilarNodeNameTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/SimilarNodeNameTests.cs
similarity index 98%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/SimilarNodeNameTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/SimilarNodeNameTests.cs
index b60709c8bf..8d8bae2e61 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/SimilarNodeNameTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/SimilarNodeNameTests.cs
@@ -2,7 +2,7 @@
using NUnit.Framework;
using Umbraco.Core.Persistence.Repositories.Implement;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
public class SimilarNodeNameTests
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/TemplateRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/TemplateRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/TemplateRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/TemplateRepositoryTest.cs
index a7894b9dc6..3452ab22ae 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/TemplateRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/TemplateRepositoryTest.cs
@@ -21,7 +21,7 @@ using Umbraco.Tests.Integration.Implementations;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/UserGroupRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/UserGroupRepositoryTest.cs
similarity index 97%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/UserGroupRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/UserGroupRepositoryTest.cs
index f6444fef00..e67b9f9b60 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/UserGroupRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/UserGroupRepositoryTest.cs
@@ -9,7 +9,7 @@ using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
@@ -17,7 +17,7 @@ namespace Umbraco.Tests.Integration.Persistence.Repositories
{
private UserGroupRepository CreateRepository(IScopeProvider provider)
{
- return new UserGroupRepository((IScopeAccessor) provider, Core.Cache.AppCaches.Disabled, LoggerFactory.CreateLogger(), LoggerFactory, ShortStringHelper);
+ return new UserGroupRepository((IScopeAccessor) provider, global::Umbraco.Core.Cache.AppCaches.Disabled, LoggerFactory.CreateLogger(), LoggerFactory, ShortStringHelper);
}
[Test]
@@ -128,7 +128,7 @@ namespace Umbraco.Tests.Integration.Persistence.Repositories
var id = userGroup.Id;
- var repository2 = new UserGroupRepository((IScopeAccessor) provider, Core.Cache.AppCaches.Disabled, LoggerFactory.CreateLogger(), LoggerFactory, ShortStringHelper);
+ var repository2 = new UserGroupRepository((IScopeAccessor) provider, global::Umbraco.Core.Cache.AppCaches.Disabled, LoggerFactory.CreateLogger(), LoggerFactory, ShortStringHelper);
repository2.Delete(userGroup);
scope.Complete();
diff --git a/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/UserRepositoryTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/UserRepositoryTest.cs
index 0df619544d..b38d326b62 100644
--- a/src/Umbraco.Tests.Integration/Persistence/Repositories/UserRepositoryTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/UserRepositoryTest.cs
@@ -18,7 +18,7 @@ using Umbraco.Tests.Common.Builders.Extensions;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Persistence.Repositories
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, WithApplication = true, Logger = UmbracoTestOptions.Logger.Console)]
diff --git a/src/Umbraco.Tests.Integration/Services/AuditServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/AuditServiceTests.cs
similarity index 98%
rename from src/Umbraco.Tests.Integration/Services/AuditServiceTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/AuditServiceTests.cs
index 474229372c..d7385a7acf 100644
--- a/src/Umbraco.Tests.Integration/Services/AuditServiceTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/AuditServiceTests.cs
@@ -9,7 +9,7 @@ using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs
similarity index 96%
rename from src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs
index a5b89dc2cf..89a3cdafb1 100644
--- a/src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs
@@ -6,7 +6,7 @@ using Umbraco.Core.Services;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
///
/// Tests covering the DataTypeService with cache enabled
diff --git a/src/Umbraco.Tests.Integration/Services/ConsentServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ConsentServiceTests.cs
similarity index 98%
rename from src/Umbraco.Tests.Integration/Services/ConsentServiceTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ConsentServiceTests.cs
index 3cc8666099..905697159d 100644
--- a/src/Umbraco.Tests.Integration/Services/ConsentServiceTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ConsentServiceTests.cs
@@ -6,7 +6,7 @@ using Umbraco.Core.Services;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
diff --git a/src/Umbraco.Tests.Integration/Services/ContentEventsTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEventsTests.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Services/ContentEventsTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEventsTests.cs
index 913ed6dd00..45b0eb0660 100644
--- a/src/Umbraco.Tests.Integration/Services/ContentEventsTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEventsTests.cs
@@ -15,7 +15,7 @@ using Umbraco.Tests.Testing;
using Umbraco.Web;
using Umbraco.Web.Cache;
-namespace Umbraco.Tests.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Services/ContentServiceEventTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceEventTests.cs
similarity index 98%
rename from src/Umbraco.Tests.Integration/Services/ContentServiceEventTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceEventTests.cs
index 74e71351af..9e1f6a6c6c 100644
--- a/src/Umbraco.Tests.Integration/Services/ContentServiceEventTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceEventTests.cs
@@ -11,7 +11,7 @@ using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest,
@@ -34,7 +34,7 @@ namespace Umbraco.Tests.Integration.Services
ContentRepositoryBase.ThrowOnWarning = true;
_globalSettings = new GlobalSettings();
// TODO: remove this once IPublishedSnapShotService has been implemented with nucache.
- Umbraco.Core.Services.Implement.ContentTypeService.ClearScopeEvents();
+ global::Umbraco.Core.Services.Implement.ContentTypeService.ClearScopeEvents();
CreateTestData();
}
diff --git a/src/Umbraco.Tests.Integration/Services/ContentServicePerformanceTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServicePerformanceTest.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Services/ContentServicePerformanceTest.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServicePerformanceTest.cs
index 273a24337a..0ac59e240c 100644
--- a/src/Umbraco.Tests.Integration/Services/ContentServicePerformanceTest.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServicePerformanceTest.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
-using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using NUnit.Framework;
@@ -17,7 +16,7 @@ using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.TestHelpers.Stubs;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
diff --git a/src/Umbraco.Tests.Integration/Services/ContentServicePublishBranchTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServicePublishBranchTests.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Services/ContentServicePublishBranchTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServicePublishBranchTests.cs
index 54103af6f1..fccd708286 100644
--- a/src/Umbraco.Tests.Integration/Services/ContentServicePublishBranchTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServicePublishBranchTests.cs
@@ -11,7 +11,7 @@ using Umbraco.Tests.Testing;
// ReSharper disable CommentTypo
// ReSharper disable StringLiteralTypo
-namespace Umbraco.Tests.Integration.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true, WithApplication = true)]
diff --git a/src/Umbraco.Tests.Integration/Services/ContentServiceTagsTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTagsTests.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Services/ContentServiceTagsTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTagsTests.cs
index 3cf02f6b10..6473b69d3c 100644
--- a/src/Umbraco.Tests.Integration/Services/ContentServiceTagsTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTagsTests.cs
@@ -11,7 +11,7 @@ using Umbraco.Tests.Common.Builders.Extensions;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest,
diff --git a/src/Umbraco.Tests.Integration/Services/ContentServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTests.cs
similarity index 99%
rename from src/Umbraco.Tests.Integration/Services/ContentServiceTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTests.cs
index c4ae836bec..36b5e91f34 100644
--- a/src/Umbraco.Tests.Integration/Services/ContentServiceTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTests.cs
@@ -3,21 +3,15 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
-using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
-using Umbraco.Core.Cache;
-using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Events;
-using Umbraco.Core.IO;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
-using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Core.PropertyEditors;
-using Umbraco.Core.Scoping;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Tests.Common.Builders;
@@ -25,7 +19,7 @@ using Umbraco.Tests.Common.Builders.Extensions;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
///
/// Tests covering all methods in the ContentService class.
diff --git a/src/Umbraco.Tests.Integration/Services/ContentTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceTests.cs
similarity index 96%
rename from src/Umbraco.Tests.Integration/Services/ContentTypeServiceTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceTests.cs
index e7a3f9d066..e5234205c4 100644
--- a/src/Umbraco.Tests.Integration/Services/ContentTypeServiceTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceTests.cs
@@ -13,7 +13,7 @@ using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
-namespace Umbraco.Tests.Integration.Services
+namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)]
@@ -358,13 +358,13 @@ namespace Umbraco.Tests.Integration.Services
var global = ContentTypeBuilder.CreateSimpleContentType("global", "Global", defaultTemplateId: template.Id);
ContentTypeService.Save(global);
- var components = ContentTypeBuilder.CreateSimpleContentType("components", "Components", global, true, defaultTemplateId: template.Id);
+ var components = ContentTypeBuilder.CreateSimpleContentType("components", "Components", global, randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(components);
- var component = ContentTypeBuilder.CreateSimpleContentType("component", "Component", components, true, defaultTemplateId: template.Id);
+ var component = ContentTypeBuilder.CreateSimpleContentType("component", "Component", components, randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(component);
- var category = ContentTypeBuilder.CreateSimpleContentType("category", "Category", global, true, defaultTemplateId: template.Id);
+ var category = ContentTypeBuilder.CreateSimpleContentType("category", "Category", global, randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(category);
var success = category.AddContentType(component);
@@ -378,10 +378,10 @@ namespace Umbraco.Tests.Integration.Services
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template);
- var contentType = ContentTypeBuilder.CreateSimpleContentType("page", "Page", null, true, defaultTemplateId: template.Id);
+ var contentType = ContentTypeBuilder.CreateSimpleContentType("page", "Page", randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(contentType);
- var childContentType = ContentTypeBuilder.CreateSimpleContentType("childPage", "Child Page", contentType, true, "Child Content", defaultTemplateId: template.Id);
+ var childContentType = ContentTypeBuilder.CreateSimpleContentType("childPage", "Child Page", contentType, randomizeAliases: true, propertyGroupName: "Child Content", defaultTemplateId: template.Id);
ContentTypeService.Save(childContentType);
var content = ContentService.Create("Page 1", -1, childContentType.Alias);
ContentService.Save(content);
@@ -593,10 +593,10 @@ namespace Umbraco.Tests.Integration.Services
var parentContentType1 = ContentTypeBuilder.CreateSimpleContentType("parent1", "Parent1", defaultTemplateId: template.Id);
ContentTypeService.Save(parentContentType1);
- var parentContentType2 = ContentTypeBuilder.CreateSimpleContentType("parent2", "Parent2", null, true, defaultTemplateId: template.Id);
+ var parentContentType2 = ContentTypeBuilder.CreateSimpleContentType("parent2", "Parent2", randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(parentContentType2);
- var simpleContentType = ContentTypeBuilder.CreateSimpleContentType("category", "Category", parentContentType1, true, defaultTemplateId: template.Id) as IContentType;
+ var simpleContentType = ContentTypeBuilder.CreateSimpleContentType("category", "Category", parentContentType1, randomizeAliases: true, defaultTemplateId: template.Id) as IContentType;
ContentTypeService.Save(simpleContentType);
// Act
@@ -690,10 +690,10 @@ namespace Umbraco.Tests.Integration.Services
var parentContentType1 = ContentTypeBuilder.CreateSimpleContentType("parent1", "Parent1", defaultTemplateId: template.Id);
ContentTypeService.Save(parentContentType1);
- var parentContentType2 = ContentTypeBuilder.CreateSimpleContentType("parent2", "Parent2", null, true, defaultTemplateId: template.Id);
+ var parentContentType2 = ContentTypeBuilder.CreateSimpleContentType("parent2", "Parent2", randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(parentContentType2);
- var simpleContentType = ContentTypeBuilder.CreateSimpleContentType("category", "Category", parentContentType1, true, defaultTemplateId: template.Id);
+ var simpleContentType = ContentTypeBuilder.CreateSimpleContentType("category", "Category", parentContentType1, randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(simpleContentType);
// Act
@@ -733,7 +733,7 @@ namespace Umbraco.Tests.Integration.Services
var parent = ContentTypeBuilder.CreateSimpleContentType(defaultTemplateId: template.Id);
ContentTypeService.Save(parent);
- var child = ContentTypeBuilder.CreateSimpleContentType("simpleChildPage", "Simple Child Page", parent, true, defaultTemplateId: template.Id);
+ var child = ContentTypeBuilder.CreateSimpleContentType("simpleChildPage", "Simple Child Page", parent, randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(child);
var composition = ContentTypeBuilder.CreateMetaContentType();
ContentTypeService.Save(composition);
@@ -762,11 +762,11 @@ namespace Umbraco.Tests.Integration.Services
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template);
- var basePage = ContentTypeBuilder.CreateSimpleContentType("basePage", "Base Page", null, true, defaultTemplateId: template.Id);
+ var basePage = ContentTypeBuilder.CreateSimpleContentType("basePage", "Base Page", randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(basePage);
var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", basePage, defaultTemplateId: template.Id);
ContentTypeService.Save(contentPage);
- var advancedPage = ContentTypeBuilder.CreateSimpleContentType("advancedPage", "Advanced Page", contentPage, true, defaultTemplateId: template.Id);
+ var advancedPage = ContentTypeBuilder.CreateSimpleContentType("advancedPage", "Advanced Page", contentPage, randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(advancedPage);
var metaComposition = ContentTypeBuilder.CreateMetaContentType();
@@ -1048,11 +1048,11 @@ namespace Umbraco.Tests.Integration.Services
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template);
- var page = ContentTypeBuilder.CreateSimpleContentType("page", "Page", null, true, "Content", defaultTemplateId: template.Id);
+ var page = ContentTypeBuilder.CreateSimpleContentType("page", "Page", randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(page);
- var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", page, true, "Content_", defaultTemplateId: template.Id);
+ var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", page, randomizeAliases: true, propertyGroupName: "Content_", defaultTemplateId: template.Id);
ContentTypeService.Save(contentPage);
- var advancedPage = ContentTypeBuilder.CreateSimpleContentType("advancedPage", "Advanced Page", contentPage, true, "Details", defaultTemplateId: template.Id);
+ var advancedPage = ContentTypeBuilder.CreateSimpleContentType("advancedPage", "Advanced Page", contentPage, randomizeAliases: true, propertyGroupName: "Details", defaultTemplateId: template.Id);
ContentTypeService.Save(advancedPage);
var contentMetaComposition = ContentTypeBuilder.CreateContentMetaContentType();
@@ -1157,11 +1157,11 @@ namespace Umbraco.Tests.Integration.Services
// Arrange
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template);
- var basePage = ContentTypeBuilder.CreateSimpleContentType("basePage", "Base Page", null, true, defaultTemplateId: template.Id);
+ var basePage = ContentTypeBuilder.CreateSimpleContentType("basePage", "Base Page", randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(basePage);
- var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", basePage, true, defaultTemplateId: template.Id);
+ var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", basePage, randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(contentPage);
- var advancedPage = ContentTypeBuilder.CreateSimpleContentType("advancedPage", "Advanced Page", contentPage, true, defaultTemplateId: template.Id);
+ var advancedPage = ContentTypeBuilder.CreateSimpleContentType("advancedPage", "Advanced Page", contentPage, randomizeAliases: true, defaultTemplateId: template.Id);
ContentTypeService.Save(advancedPage);
var metaComposition = ContentTypeBuilder.CreateMetaContentType();
@@ -1200,7 +1200,7 @@ namespace Umbraco.Tests.Integration.Services
// create 'page' content type with a 'Content_' group
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template);
- var page = ContentTypeBuilder.CreateSimpleContentType("page", "Page", null, false, "Content_", defaultTemplateId: template.Id);
+ var page = ContentTypeBuilder.CreateSimpleContentType("page", "Page", propertyGroupName: "Content_", defaultTemplateId: template.Id);
Assert.AreEqual(1, page.PropertyGroups.Count);
Assert.AreEqual("Content_", page.PropertyGroups.First().Name);
Assert.AreEqual(3, page.PropertyTypes.Count());
@@ -1210,7 +1210,7 @@ namespace Umbraco.Tests.Integration.Services
ContentTypeService.Save(page);
// create 'contentPage' content type as a child of 'page'
- var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", page, true, defaultTemplateId: template.Id);
+ var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", page, randomizeAliases: true, defaultTemplateId: template.Id);
Assert.AreEqual(1, page.PropertyGroups.Count);
Assert.AreEqual("Content_", page.PropertyGroups.First().Name);
Assert.AreEqual(3, contentPage.PropertyTypes.Count());
@@ -1281,11 +1281,11 @@ namespace Umbraco.Tests.Integration.Services
// Arrange
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template);
- var page = ContentTypeBuilder.CreateSimpleContentType("page", "Page", null, true, "Content_", defaultTemplateId: template.Id);
+ var page = ContentTypeBuilder.CreateSimpleContentType("page", "Page", randomizeAliases: true, propertyGroupName: "Content_", defaultTemplateId: template.Id);
ContentTypeService.Save(page);
- var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", page, true, "Contentx", defaultTemplateId: template.Id);
+ var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", page, randomizeAliases: true, propertyGroupName: "Contentx", defaultTemplateId: template.Id);
ContentTypeService.Save(contentPage);
- var advancedPage = ContentTypeBuilder.CreateSimpleContentType("advancedPage", "Advanced Page", contentPage, true, "Contenty", defaultTemplateId: template.Id);
+ var advancedPage = ContentTypeBuilder.CreateSimpleContentType("advancedPage", "Advanced Page", contentPage, randomizeAliases: true, propertyGroupName: "Contenty", defaultTemplateId: template.Id);
ContentTypeService.Save(advancedPage);
var contentMetaComposition = ContentTypeBuilder.CreateContentMetaContentType();
@@ -1355,9 +1355,9 @@ namespace Umbraco.Tests.Integration.Services
// Arrange
var template = TemplateBuilder.CreateTextPageTemplate();
FileService.SaveTemplate(template);
- var page = ContentTypeBuilder.CreateSimpleContentType("page", "Page", null, true, "Content_", defaultTemplateId: template.Id);
+ var page = ContentTypeBuilder.CreateSimpleContentType("page", "Page", randomizeAliases: true, propertyGroupName: "Content_", defaultTemplateId: template.Id);
ContentTypeService.Save(page);
- var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", page, true, "Content", defaultTemplateId: template.Id);
+ var contentPage = ContentTypeBuilder.CreateSimpleContentType("contentPage", "Content Page", page, randomizeAliases: true, propertyGroupName: "Content", defaultTemplateId: template.Id);
ContentTypeService.Save(contentPage);
var contentMetaComposition = ContentTypeBuilder.CreateContentMetaContentType();
@@ -1589,11 +1589,11 @@ namespace Umbraco.Tests.Integration.Services
typeA.PropertyTypes.First(x => x.Alias.InvariantEquals("title")).Variations = ContentVariation.Culture; // with a variant property
ContentTypeService.Save(typeA);
- var typeB = ContentTypeBuilder.CreateSimpleContentType("b", "B", typeA, true, defaultTemplateId: template.Id);
+ var typeB = ContentTypeBuilder.CreateSimpleContentType("b", "B", typeA, randomizeAliases: true, defaultTemplateId: template.Id);
typeB.Variations = ContentVariation.Nothing; // make it invariant
ContentTypeService.Save(typeB);
- var typeC = ContentTypeBuilder.CreateSimpleContentType("c", "C", typeA, true, defaultTemplateId: template.Id);
+ var typeC = ContentTypeBuilder.CreateSimpleContentType("c", "C", typeA, randomizeAliases: true, defaultTemplateId: template.Id);
typeC.Variations = ContentVariation.Culture; // make it variant
ContentTypeService.Save(typeC);
@@ -1705,7 +1705,7 @@ namespace Umbraco.Tests.Integration.Services
{
var contentType = ContentTypeBuilder.CreateSimpleContentType("childType" + i, "ChildType" + i,
//make the last entry in the list, this one's parent
- list.Last(), true, defaultTemplateId: template.Id);
+ list.Last(), randomizeAliases: true, defaultTemplateId: template.Id);
list.Add(contentType);
}
diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs
similarity index 76%
rename from src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs
index 30d68d92e0..7552ff4c41 100644
--- a/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs
@@ -2,99 +2,31 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Logging.Abstractions;
-using Moq;
using NUnit.Framework;
-using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration.Models;
-using Umbraco.Core.Hosting;
using Umbraco.Core.Models;
-using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Dtos;
-using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Services;
-using Umbraco.Core.Strings;
using Umbraco.Core.Sync;
-using Umbraco.Tests.TestHelpers;
-using Umbraco.Tests.TestHelpers.Entities;
+using Umbraco.Tests.Common.Builders;
+using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
using Umbraco.Web.PublishedCache;
-using Umbraco.Web.PublishedCache.NuCache;
-using Umbraco.Web.PublishedCache.NuCache.DataSource;
namespace Umbraco.Tests.Services
{
[TestFixture]
[Apartment(ApartmentState.STA)]
- [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true, WithApplication = true)]
- public class ContentTypeServiceVariantsTests : TestWithSomeContentBase
+ [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)]
+ public class ContentTypeServiceVariantsTests : UmbracoIntegrationTest
{
- protected override void Compose()
- {
- base.Compose();
-
- // pfew - see note in ScopedNuCacheTests?
- Composition.RegisterUnique();
- Composition.RegisterUnique(f => Mock.Of());
- Composition.WithCollectionBuilder()
- .Add(() => Composition.TypeLoader.GetCacheRefreshers());
- }
-
- protected override IPublishedSnapshotService CreatePublishedSnapshotService(GlobalSettings globalSettings = null)
- {
- var options = new PublishedSnapshotServiceOptions { IgnoreLocalDb = true };
- var publishedSnapshotAccessor = new UmbracoContextPublishedSnapshotAccessor(Umbraco.Web.Composing.Current.UmbracoContextAccessor);
- var runtimeStateMock = new Mock();
- runtimeStateMock.Setup(x => x.Level).Returns(() => RuntimeLevel.Run);
-
- var contentTypeFactory = Factory.GetInstance();
- var documentRepository = Factory.GetInstance();
- var mediaRepository = Mock.Of();
- var memberRepository = Mock.Of();
- var hostingEnvironment = Mock.Of();
-
- var typeFinder = TestHelper.GetTypeFinder();
-
- var nuCacheSettings = new NuCacheSettings();
-
- return new PublishedSnapshotService(
- options,
- null,
- runtimeStateMock.Object,
- ServiceContext,
- contentTypeFactory,
- publishedSnapshotAccessor,
- Mock.Of(),
- ProfilingLogger,
- NullLoggerFactory.Instance,
- ScopeProvider,
- documentRepository, mediaRepository, memberRepository,
- DefaultCultureAccessor,
- new DatabaseDataSource(Mock.Of>()),
- Microsoft.Extensions.Options.Options.Create(globalSettings ?? new GlobalSettings()),
- Factory.GetInstance(),
- Mock.Of(),
- new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider(ShortStringHelper) }),
- hostingEnvironment,
- Mock.Of(),
- IOHelper,
- Microsoft.Extensions.Options.Options.Create(nuCacheSettings));
- }
-
- public class LocalServerMessenger : ServerMessengerBase
- {
- public LocalServerMessenger()
- : base(false)
- { }
-
- protected override void DeliverRemote(ICacheRefresher refresher, MessageType messageType, IEnumerable