diff --git a/src/Umbraco.Core/Composing/Composition.cs b/src/Umbraco.Core/Composing/Composition.cs
index c7842565f0..998f42a2dc 100644
--- a/src/Umbraco.Core/Composing/Composition.cs
+++ b/src/Umbraco.Core/Composing/Composition.cs
@@ -31,13 +31,12 @@ namespace Umbraco.Core.Composing
/// Optional configs.
/// An IOHelper
///
- public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs, IIOHelper ioHelper, AppCaches appCaches)
+ public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, IIOHelper ioHelper, AppCaches appCaches)
{
_register = register ?? throw new ArgumentNullException(nameof(register));
TypeLoader = typeLoader ?? throw new ArgumentNullException(nameof(typeLoader));
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
RuntimeState = runtimeState ?? throw new ArgumentNullException(nameof(runtimeState));
- Configs = configs ?? throw new ArgumentNullException(nameof(configs));
IOHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
AppCaches = appCaches ?? throw new ArgumentNullException(nameof(appCaches));
}
@@ -62,12 +61,6 @@ namespace Umbraco.Core.Composing
///
public IRuntimeState RuntimeState { get; }
- // TODO: remove this once no longer required for functionality in Umbraco.Web.
- ///
- /// Gets the configurations.
- ///
- public Configs Configs { get; }
-
#endregion
#region IRegister
@@ -136,8 +129,6 @@ namespace Umbraco.Core.Composing
IFactory factory = null;
- Configs.RegisterWith(_register);
-
// ReSharper disable once AccessToModifiedClosure -- on purpose
_register.Register(_ => factory, Lifetime.Singleton);
factory = _register.CreateFactory();
diff --git a/src/Umbraco.Core/Composing/Current.cs b/src/Umbraco.Core/Composing/Current.cs
index 055a29228a..856be9f414 100644
--- a/src/Umbraco.Core/Composing/Current.cs
+++ b/src/Umbraco.Core/Composing/Current.cs
@@ -1,7 +1,9 @@
using System;
using System.Runtime.CompilerServices;
+using Microsoft.Extensions.Options;
using Umbraco.Core;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
@@ -11,18 +13,21 @@ namespace Umbraco.Composing
public static class Current
{
private static ILogger _logger = new NullLogger();
- private static Configs _configs;
private static IIOHelper _ioHelper;
private static IHostingEnvironment _hostingEnvironment;
private static IBackOfficeInfo _backOfficeInfo;
private static IProfiler _profiler;
+ private static SecuritySettings _securitySettings;
+ private static GlobalSettings _globalSettings;
public static ILogger Logger => EnsureInitialized(_logger);
- public static Configs Configs => EnsureInitialized(_configs);
+
public static IIOHelper IOHelper => EnsureInitialized(_ioHelper);
public static IHostingEnvironment HostingEnvironment => EnsureInitialized(_hostingEnvironment);
public static IBackOfficeInfo BackOfficeInfo => EnsureInitialized(_backOfficeInfo);
public static IProfiler Profiler => EnsureInitialized(_profiler);
+ public static SecuritySettings SecuritySettings => EnsureInitialized(_securitySettings);
+ public static GlobalSettings GlobalSettings => EnsureInitialized(_globalSettings);
public static bool IsInitialized { get; internal set; }
@@ -37,7 +42,8 @@ namespace Umbraco.Composing
public static void Initialize(
ILogger logger,
- Configs configs,
+ SecuritySettings securitySettings,
+ GlobalSettings globalSettings,
IIOHelper ioHelper,
IHostingEnvironment hostingEnvironment,
IBackOfficeInfo backOfficeInfo,
@@ -49,13 +55,15 @@ namespace Umbraco.Composing
}
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
- _configs = configs ?? throw new ArgumentNullException(nameof(configs));
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
_hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
_backOfficeInfo = backOfficeInfo ?? throw new ArgumentNullException(nameof(backOfficeInfo));
_profiler = profiler ?? throw new ArgumentNullException(nameof(profiler));
+ _securitySettings = securitySettings ?? throw new ArgumentNullException(nameof(securitySettings));
+ _globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));
IsInitialized = true;
}
+
}
}
diff --git a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs
index a4bdb5c55f..0f63903320 100644
--- a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs
+++ b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs
@@ -11,42 +11,18 @@ namespace Umbraco.Core
public static class ConfigsExtensions
{
- public static IImagingSettings Imaging(this Configs configs)
- => configs.GetConfig();
public static IGlobalSettings Global(this Configs configs)
=> configs.GetConfig();
- public static IHostingSettings Hosting(this Configs configs)
- => configs.GetConfig();
public static IConnectionStrings ConnectionStrings(this Configs configs)
=> configs.GetConfig();
- public static IContentSettings Content(this Configs configs)
- => configs.GetConfig();
-
public static ISecuritySettings Security(this Configs configs)
=> configs.GetConfig();
- public static ITypeFinderSettings TypeFinder(this Configs configs)
- => configs.GetConfig();
-
-
- public static IUserPasswordConfiguration UserPasswordConfiguration(this Configs configs)
- => configs.GetConfig();
- public static IMemberPasswordConfiguration MemberPasswordConfiguration(this Configs configs)
- => configs.GetConfig();
-
- public static IRequestHandlerSettings RequestHandler(this Configs configs)
- => configs.GetConfig();
-
public static IWebRoutingSettings WebRouting(this Configs configs)
=> configs.GetConfig();
- public static IHealthChecksSettings HealthChecks(this Configs configs)
- => configs.GetConfig();
- public static ICoreDebugSettings CoreDebug(this Configs configs)
- => configs.GetConfig();
-
}
}
diff --git a/src/Umbraco.Infrastructure/Composing/UmbracoServiceProviderFactory.cs b/src/Umbraco.Infrastructure/Composing/UmbracoServiceProviderFactory.cs
index 56a972a64b..51bd5e7b14 100644
--- a/src/Umbraco.Infrastructure/Composing/UmbracoServiceProviderFactory.cs
+++ b/src/Umbraco.Infrastructure/Composing/UmbracoServiceProviderFactory.cs
@@ -2,9 +2,11 @@
using LightInject.Microsoft.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using System;
+using Microsoft.Extensions.Options;
using Umbraco.Composing;
using Umbraco.Core.Composing.LightInject;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
namespace Umbraco.Core.Composing
@@ -86,7 +88,8 @@ namespace Umbraco.Core.Composing
// after cross wiring, configure "Current"
Current.Initialize(
_container.GetInstance(),
- _container.GetInstance(),
+ _container.GetInstance(),
+ _container.GetInstance(),
_container.GetInstance(),
_container.GetInstance(),
_container.GetInstance(),
diff --git a/src/Umbraco.Infrastructure/Configuration/ConfigModelConversionsFromLegacy.cs b/src/Umbraco.Infrastructure/Configuration/ConfigModelConversionsFromLegacy.cs
index 44223f68a4..d4a34d72d8 100644
--- a/src/Umbraco.Infrastructure/Configuration/ConfigModelConversionsFromLegacy.cs
+++ b/src/Umbraco.Infrastructure/Configuration/ConfigModelConversionsFromLegacy.cs
@@ -1,6 +1,7 @@
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
+using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Infrastructure.Configuration
{
@@ -69,5 +70,20 @@ namespace Umbraco.Infrastructure.Configuration
RequireUppercase = passwordConfiguration.RequireUppercase,
};
}
+
+ public static SecuritySettings ConvertSecuritySettings(ISecuritySettings securitySettings)
+ {
+ return new SecuritySettings
+ {
+ MemberPassword = new MemberPasswordConfigurationSettings(),
+ UserPassword = new UserPasswordConfigurationSettings(),
+ AllowPasswordReset = securitySettings.AllowPasswordReset,
+ AuthCookieDomain = securitySettings.AuthCookieDomain,
+ AuthCookieName = securitySettings.AuthCookieDomain,
+ UsernameIsEmail = securitySettings.UsernameIsEmail,
+ KeepUserLoggedIn = securitySettings.KeepUserLoggedIn,
+ HideDisabledUsersInBackoffice = securitySettings.HideDisabledUsersInBackoffice,
+ };
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Models/ContentEditing/UserInvite.cs b/src/Umbraco.Infrastructure/Models/ContentEditing/UserInvite.cs
index 428f85937b..68a7a9bd3f 100644
--- a/src/Umbraco.Infrastructure/Models/ContentEditing/UserInvite.cs
+++ b/src/Umbraco.Infrastructure/Models/ContentEditing/UserInvite.cs
@@ -34,7 +34,7 @@ namespace Umbraco.Web.Models.ContentEditing
yield return new ValidationResult("A user must be assigned to at least one group", new[] { nameof(UserGroups) });
// TODO: this will need another way of retrieving this setting if and when Configs are removed from Current.
- if (Current.Configs.Security().UsernameIsEmail == false && Username.IsNullOrWhiteSpace())
+ if (Current.SecuritySettings.UsernameIsEmail == false && Username.IsNullOrWhiteSpace())
yield return new ValidationResult("A username cannot be empty", new[] { nameof(Username) });
}
}
diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs
index 7d02152a57..e4b724089c 100644
--- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs
+++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs
@@ -29,12 +29,10 @@ namespace Umbraco.Core.Runtime
// runtime state, this instance will get replaced again once the essential services are available to run the check
private RuntimeState _state = RuntimeState.Booting();
private readonly IUmbracoBootPermissionChecker _umbracoBootPermissionChecker;
- private readonly Configs _configs;
private readonly GlobalSettings _globalSettings;
private readonly ConnectionStrings _connectionStrings;
public CoreRuntime(
- Configs configs, // TODO: remove this parameter with legacy configuraiton no longer needed in Umbraco.Web and Umbraco.Tests
GlobalSettings globalSettings,
ConnectionStrings connectionStrings,
IUmbracoVersion umbracoVersion,
@@ -49,7 +47,6 @@ namespace Umbraco.Core.Runtime
ITypeFinder typeFinder,
AppCaches appCaches)
{
- _configs = configs;
_globalSettings = globalSettings;
_connectionStrings = connectionStrings;
@@ -179,7 +176,7 @@ namespace Umbraco.Core.Runtime
_state = new RuntimeState(_globalSettings, UmbracoVersion, databaseFactory, Logger);
// create the composition
- composition = new Composition(register, typeLoader, ProfilingLogger, _state, _configs, IOHelper, AppCaches);
+ composition = new Composition(register, typeLoader, ProfilingLogger, _state, IOHelper, AppCaches);
composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, MainDom, AppCaches, databaseFactory, typeLoader, _state, TypeFinder, IOHelper, UmbracoVersion, DbProviderFactoryCreator, HostingEnvironment, BackOfficeInfo);
diff --git a/src/Umbraco.Infrastructure/Trees/TreeNode.cs b/src/Umbraco.Infrastructure/Trees/TreeNode.cs
index 585929c0e1..5cf1054fc8 100644
--- a/src/Umbraco.Infrastructure/Trees/TreeNode.cs
+++ b/src/Umbraco.Infrastructure/Trees/TreeNode.cs
@@ -116,8 +116,8 @@ namespace Umbraco.Web.Models.Trees
//legacy icon path
// TODO: replace this when we have something other than Current.Configs available
- //var backOfficePath = Current.Configs.Global().GetUmbracoMvcArea(Current.HostingEnvironment);
- var backOfficePath = new GlobalSettings().GetUmbracoMvcArea(Current.HostingEnvironment);
+ var backOfficePath = Current.GlobalSettings.GetUmbracoMvcArea(Current.HostingEnvironment);
+
return string.Format("{0}images/umbraco/{1}", backOfficePath.EnsureEndsWith("/"), Icon);
}
diff --git a/src/Umbraco.Tests.Integration/ContainerTests.cs b/src/Umbraco.Tests.Integration/ContainerTests.cs
index 3ba3c31d03..00d6c14be3 100644
--- a/src/Umbraco.Tests.Integration/ContainerTests.cs
+++ b/src/Umbraco.Tests.Integration/ContainerTests.cs
@@ -36,15 +36,15 @@ namespace Umbraco.Tests.Integration
serviceProviderFactory.CreateBuilder(services); // called during Host Builder, needed to capture services
// Dependencies needed for creating composition/register essentials
- var testHelper = new TestHelper();
+ var testHelper = new TestHelper();
var runtimeState = Mock.Of();
var umbracoDatabaseFactory = Mock.Of();
- var dbProviderFactoryCreator = Mock.Of();
+ var dbProviderFactoryCreator = Mock.Of();
var typeLoader = testHelper.GetMockedTypeLoader();
// Register in the container
var composition = new Composition(umbracoContainer, typeLoader,
- testHelper.Logger, runtimeState, testHelper.GetConfigs(), testHelper.IOHelper, testHelper.AppCaches);
+ testHelper.Logger, runtimeState, testHelper.IOHelper, testHelper.AppCaches);
composition.RegisterEssentials(testHelper.Logger, testHelper.Profiler, testHelper.Logger, testHelper.MainDom,
testHelper.AppCaches, umbracoDatabaseFactory, typeLoader, runtimeState, testHelper.GetTypeFinder(),
testHelper.IOHelper, testHelper.GetUmbracoVersion(), dbProviderFactoryCreator,
diff --git a/src/Umbraco.Tests.Integration/RuntimeTests.cs b/src/Umbraco.Tests.Integration/RuntimeTests.cs
index c081caedc1..a5b421fcd3 100644
--- a/src/Umbraco.Tests.Integration/RuntimeTests.cs
+++ b/src/Umbraco.Tests.Integration/RuntimeTests.cs
@@ -56,12 +56,11 @@ namespace Umbraco.Tests.Integration
var testHelper = new TestHelper();
- var configs = testHelper.GetConfigs();
var globalSettings = new GlobalSettingsBuilder().Build();
var connectionStrings = new ConnectionStringsBuilder().Build();
// Create the core runtime
- var coreRuntime = new CoreRuntime(configs, globalSettings, connectionStrings, testHelper.GetUmbracoVersion(),
+ var coreRuntime = new CoreRuntime(globalSettings, connectionStrings, testHelper.GetUmbracoVersion(),
testHelper.IOHelper, testHelper.Logger, testHelper.Profiler, testHelper.UmbracoBootPermissionChecker,
testHelper.GetHostingEnvironment(), testHelper.GetBackOfficeInfo(), testHelper.DbProviderFactoryCreator,
testHelper.MainDom, testHelper.GetTypeFinder(), AppCaches.NoCache);
@@ -92,7 +91,7 @@ namespace Umbraco.Tests.Integration
umbracoContainer.Register(x => Options.Create(requestHandlerSettings));
umbracoContainer.Register(x => Options.Create(userPasswordConfigurationSettings));
umbracoContainer.Register(x => Options.Create(webRoutingSettings));
-
+
coreRuntime.Start();
Assert.IsTrue(MyComponent.IsInit);
diff --git a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs
index 3514a8557c..0fa81d7de5 100644
--- a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs
+++ b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs
@@ -31,11 +31,10 @@ namespace Umbraco.Tests.Integration.TestServerTest
AppCaches.NoCache, // Disable caches in integration tests
testHelper.GetLoggingConfiguration(),
// TODO: Yep that's extremely ugly
- (configs, globalSettings, connectionStrings, umbVersion, ioHelper, logger, profiler, hostingEnv,
+ (globalSettings, connectionStrings, umbVersion, ioHelper, logger, profiler, hostingEnv,
backOfficeInfo, typeFinder, appCaches, dbProviderFactoryCreator) =>
{
var runtime = UmbracoIntegrationTest.CreateTestRuntime(
- configs,
globalSettings,
connectionStrings,
umbVersion,
diff --git a/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs b/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs
index e9b38741e2..ebbfb0be25 100644
--- a/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs
+++ b/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs
@@ -3,10 +3,12 @@ using NUnit.Framework;
using System;
using System.IO;
using System.Linq;
+using Microsoft.Extensions.Options;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
@@ -57,7 +59,7 @@ namespace Umbraco.Tests.Integration.Testing
///
private ILocalizedTextService GetLocalizedTextService(IFactory factory)
{
- var configs = factory.GetInstance();
+ var globalSettings = factory.GetInstance>();
var logger = factory.GetInstance();
var appCaches = factory.GetInstance();
@@ -71,7 +73,7 @@ namespace Umbraco.Tests.Integration.Testing
currFolder = currFolder.Parent;
}
var netcoreUI = currFolder.GetDirectories("Umbraco.Web.UI.NetCore", SearchOption.TopDirectoryOnly).First();
- var mainLangFolder = new DirectoryInfo(Path.Combine(netcoreUI.FullName, configs.Global().UmbracoPath.TrimStart("~/"), "config", "lang"));
+ var mainLangFolder = new DirectoryInfo(Path.Combine(netcoreUI.FullName, globalSettings.Value.UmbracoPath.TrimStart("~/"), "config", "lang"));
return new LocalizedTextServiceFileSources(
logger,
diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
index 975710f460..a8f3b51e37 100644
--- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
+++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
@@ -123,7 +123,6 @@ namespace Umbraco.Tests.Integration.Testing
///
/// Creates a instance for testing and registers an event handler for database install
///
- ///
///
///
///
@@ -137,14 +136,13 @@ namespace Umbraco.Tests.Integration.Testing
///
///
public CoreRuntime CreateTestRuntime(
- Configs configs,
GlobalSettings globalSettings,
ConnectionStrings connectionStrings,
IUmbracoVersion umbracoVersion, IIOHelper ioHelper,
ILogger logger, IProfiler profiler, Core.Hosting.IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo,
ITypeFinder typeFinder, AppCaches appCaches, IDbProviderFactoryCreator dbProviderFactoryCreator)
{
- var runtime = CreateTestRuntime(configs,
+ var runtime = CreateTestRuntime(
globalSettings,
connectionStrings,
umbracoVersion,
@@ -166,7 +164,6 @@ namespace Umbraco.Tests.Integration.Testing
///
/// Creates a instance for testing and registers an event handler for database install
///
- ///
///
///
///
@@ -182,7 +179,6 @@ namespace Umbraco.Tests.Integration.Testing
///
///
public static CoreRuntime CreateTestRuntime(
- Configs configs,
GlobalSettings globalSettings,
ConnectionStrings connectionStrings,
IUmbracoVersion umbracoVersion, IIOHelper ioHelper,
@@ -191,7 +187,6 @@ namespace Umbraco.Tests.Integration.Testing
IMainDom mainDom, Action eventHandler)
{
var runtime = new CoreRuntime(
- configs,
globalSettings,
connectionStrings,
umbracoVersion,
diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
index 932a974b75..13f58f8021 100644
--- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
@@ -5,9 +5,11 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Services;
using Umbraco.Tests.Common;
+using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
@@ -58,7 +60,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
_httpContextFactory = new FakeHttpContextFactory("~/Home");
- var globalSettings = Factory.GetInstance();
+ var globalSettings = new GlobalSettingsBuilder().Build();
var umbracoContextAccessor = Factory.GetInstance();
_xml = new XmlDocument();
diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs
index 4b8ee755d2..de99ba445f 100644
--- a/src/Umbraco.Tests/Components/ComponentTests.cs
+++ b/src/Umbraco.Tests/Components/ComponentTests.cs
@@ -75,7 +75,7 @@ namespace Umbraco.Tests.Components
{
var register = MockRegister();
var typeLoader = MockTypeLoader();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = TypeArray();
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -114,7 +114,7 @@ namespace Umbraco.Tests.Components
public void Boot1B()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
var types = TypeArray();
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -130,7 +130,7 @@ namespace Umbraco.Tests.Components
public void Boot2()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = TypeArray();
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -145,7 +145,7 @@ namespace Umbraco.Tests.Components
public void Boot3()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = TypeArray();
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -162,7 +162,7 @@ namespace Umbraco.Tests.Components
public void BrokenRequire()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = TypeArray();
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -185,7 +185,7 @@ namespace Umbraco.Tests.Components
public void BrokenRequired()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = TypeArray();
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -221,7 +221,7 @@ namespace Umbraco.Tests.Components
throw new NotSupportedException(type.FullName);
});
});
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = new[] { typeof(Composer1), typeof(Composer5), typeof(Composer5a) };
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -247,7 +247,7 @@ namespace Umbraco.Tests.Components
public void Requires1()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = new[] { typeof(Composer6), typeof(Composer7), typeof(Composer8) };
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -262,7 +262,7 @@ namespace Umbraco.Tests.Components
public void Requires2A()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = new[] { typeof(Composer9), typeof(Composer2), typeof(Composer4) };
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -280,7 +280,7 @@ namespace Umbraco.Tests.Components
var register = MockRegister();
var typeLoader = MockTypeLoader();
var factory = MockFactory();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
var types = new[] { typeof(Composer9), typeof(Composer2), typeof(Composer4) };
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -299,7 +299,7 @@ namespace Umbraco.Tests.Components
public void WeakDependencies()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = new[] { typeof(Composer10) };
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -338,7 +338,7 @@ namespace Umbraco.Tests.Components
public void DisableMissing()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = new[] { typeof(Composer6), typeof(Composer8) }; // 8 disables 7 which is not in the list
var composers = new Composers(composition, types, Enumerable.Empty(), Mock.Of());
@@ -353,7 +353,7 @@ namespace Umbraco.Tests.Components
public void AttributesPriorities()
{
var register = MockRegister();
- var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), TestHelper.IOHelper, AppCaches.NoCache);
var types = new[] { typeof(Composer26) };
var enableDisableAttributes = new[] { new DisableComposerAttribute(typeof(Composer26)) };
@@ -380,7 +380,7 @@ namespace Umbraco.Tests.Components
var register = MockRegister();
var composition = new Composition(register, typeLoader, Mock.Of(),
- MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
var allComposers = typeLoader.GetTypes().ToList();
var types = allComposers.Where(x => x.FullName.StartsWith("Umbraco.Core.") || x.FullName.StartsWith("Umbraco.Web")).ToList();
diff --git a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs
index 2d977e89c7..4986c3ac53 100644
--- a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs
+++ b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs
@@ -24,7 +24,7 @@ namespace Umbraco.Tests.Composing
Current.Reset();
var register = TestHelper.GetRegister();
- _composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ _composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
}
[TearDown]
@@ -490,7 +490,7 @@ namespace Umbraco.Tests.Composing
for (var i = 0; i < col1A.Length; i++)
{
Assert.AreNotSame(col1A[i], col2A[i]);
- }
+ }
}
#endregion
diff --git a/src/Umbraco.Tests/Composing/CompositionTests.cs b/src/Umbraco.Tests/Composing/CompositionTests.cs
index 380511eaaa..229ba1102b 100644
--- a/src/Umbraco.Tests/Composing/CompositionTests.cs
+++ b/src/Umbraco.Tests/Composing/CompositionTests.cs
@@ -41,7 +41,7 @@ namespace Umbraco.Tests.Composing
var typeFinder = TestHelper.GetTypeFinder();
var ioHelper = TestHelper.IOHelper;
var typeLoader = new TypeLoader(typeFinder, Mock.Of(), new DirectoryInfo(ioHelper.MapPath("~/App_Data/TEMP")), logger);
- var composition = new Composition(mockedRegister, typeLoader, logger, Mock.Of(), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(mockedRegister, typeLoader, logger, Mock.Of(), TestHelper.IOHelper, AppCaches.NoCache);
// create the factory, ensure it is the mocked factory
var factory = composition.CreateFactory();
diff --git a/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs b/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs
index 4d0135d6c4..c17e80a34a 100644
--- a/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs
+++ b/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs
@@ -41,7 +41,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderHandlesTypes()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
composition.WithCollectionBuilder()
.Add()
@@ -67,7 +67,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderHandlesProducers()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
composition.WithCollectionBuilder()
.Add(() => new[] { typeof(TransientObject3), typeof(TransientObject2) })
@@ -92,7 +92,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderHandlesTypesAndProducers()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
composition.WithCollectionBuilder()
.Add()
@@ -118,7 +118,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderThrowsOnIllegalTypes()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
composition.WithCollectionBuilder()
.Add()
@@ -140,7 +140,7 @@ namespace Umbraco.Tests.Composing
public void LazyCollectionBuilderCanExcludeTypes()
{
var container = CreateRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
composition.WithCollectionBuilder()
.Add()
diff --git a/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs b/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs
index 390997173b..118eaab41a 100644
--- a/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs
+++ b/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs
@@ -22,7 +22,7 @@ namespace Umbraco.Tests.Composing
{
var container = TestHelper.GetRegister();
- var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(container, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
var expectedPackageActions = TypeLoader.GetPackageActions();
composition.WithCollectionBuilder()
diff --git a/src/Umbraco.Tests/IO/FileSystemsTests.cs b/src/Umbraco.Tests/IO/FileSystemsTests.cs
index eabd331a02..b474da872f 100644
--- a/src/Umbraco.Tests/IO/FileSystemsTests.cs
+++ b/src/Umbraco.Tests/IO/FileSystemsTests.cs
@@ -31,7 +31,7 @@ namespace Umbraco.Tests.IO
{
_register = TestHelper.GetRegister();
- var composition = new Composition(_register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(_register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
composition.Register(_ => Mock.Of());
composition.Register(_ => Mock.Of());
@@ -42,15 +42,11 @@ namespace Umbraco.Tests.IO
composition.RegisterUnique(TestHelper.IOHelper);
composition.RegisterUnique(TestHelper.GetHostingEnvironment());
- composition.Configs.Add(() => SettingsForTests.DefaultGlobalSettings);
-
var globalSettings = new GlobalSettingsBuilder().Build();
composition.Register(x => Microsoft.Extensions.Options.Options.Create(globalSettings));
composition.ComposeFileSystems();
- composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
-
_factory = composition.CreateFactory();
Current.Reset();
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs
index afdb71c28e..fe02e6fa48 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs
@@ -7,6 +7,7 @@ using System.Xml.XPath;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Xml;
using Umbraco.Tests.TestHelpers;
@@ -18,7 +19,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
internal class PublishedContentCache : PublishedCacheBase, IPublishedContentCache
{
private readonly IAppCache _appCache;
- private readonly IGlobalSettings _globalSettings;
+ private readonly GlobalSettings _globalSettings;
private readonly RoutesCache _routesCache;
private readonly IVariationContextAccessor _variationContextAccessor;
private readonly IDomainCache _domainCache;
@@ -33,7 +34,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
XmlStore xmlStore, // an XmlStore containing the master xml
IDomainCache domainCache, // an IDomainCache implementation
IAppCache appCache, // an IAppCache that should be at request-level
- IGlobalSettings globalSettings,
+ GlobalSettings globalSettings,
PublishedContentTypeCache contentTypeCache, // a PublishedContentType cache
RoutesCache routesCache, // a RoutesCache
IVariationContextAccessor variationContextAccessor,
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs
index bf7cbe40c4..a913ba06bd 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs
@@ -3,6 +3,7 @@ using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
@@ -35,7 +36,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private readonly IMediaService _mediaService;
private readonly IUserService _userService;
private readonly IAppCache _requestCache;
- private readonly IGlobalSettings _globalSettings;
+ private readonly GlobalSettings _globalSettings;
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
private readonly ISiteDomainHelper _siteDomainHelper;
private readonly IEntityXmlSerializer _entitySerializer;
@@ -56,7 +57,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
IDefaultCultureAccessor defaultCultureAccessor,
ILogger logger,
- IGlobalSettings globalSettings,
+ GlobalSettings globalSettings,
IHostingEnvironment hostingEnvironment,
IApplicationShutdownRegistry hostingLifetime,
IShortStringHelper shortStringHelper,
@@ -84,7 +85,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
IDefaultCultureAccessor defaultCultureAccessor,
ILogger logger,
- IGlobalSettings globalSettings,
+ GlobalSettings globalSettings,
IHostingEnvironment hostingEnvironment,
IApplicationShutdownRegistry hostingLifetime,
IShortStringHelper shortStringHelper,
diff --git a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs
index d2d8cb952b..439036fa16 100644
--- a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs
+++ b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs
@@ -26,7 +26,7 @@ namespace Umbraco.Tests.PropertyEditors
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
var register = TestHelper.GetRegister();
- var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
var requestHandlerSettings = new RequestHandlerSettingsBuilder().Build();
register.Register(_
diff --git a/src/Umbraco.Tests/Published/ConvertersTests.cs b/src/Umbraco.Tests/Published/ConvertersTests.cs
index 3ecae51ea8..2ae4c238cc 100644
--- a/src/Umbraco.Tests/Published/ConvertersTests.cs
+++ b/src/Umbraco.Tests/Published/ConvertersTests.cs
@@ -182,7 +182,7 @@ namespace Umbraco.Tests.Published
// Current.Reset();
var register = TestHelper.GetRegister();
- var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
composition.WithCollectionBuilder()
.Append()
diff --git a/src/Umbraco.Tests/Routing/BaseUrlProviderTest.cs b/src/Umbraco.Tests/Routing/BaseUrlProviderTest.cs
index 999748bc73..a4f472898e 100644
--- a/src/Umbraco.Tests/Routing/BaseUrlProviderTest.cs
+++ b/src/Umbraco.Tests/Routing/BaseUrlProviderTest.cs
@@ -29,10 +29,6 @@ namespace Umbraco.Tests.Routing
Composition.Register(x => Microsoft.Extensions.Options.Options.Create(contentSettings));
Composition.Register(x => Microsoft.Extensions.Options.Options.Create(userPasswordConfigurationSettings));
-
- // TODO: remove this once legacy config is fully extracted.
- Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockContentSettings);
- Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockGlobalSettings);
}
protected IPublishedUrlProvider GetPublishedUrlProvider(IUmbracoContext umbracoContext, DefaultUrlProvider urlProvider)
diff --git a/src/Umbraco.Tests/Routing/ContentFinderByUrlAndTemplateTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByUrlAndTemplateTests.cs
index 2c991ce455..14a7ec3ab1 100644
--- a/src/Umbraco.Tests/Routing/ContentFinderByUrlAndTemplateTests.cs
+++ b/src/Umbraco.Tests/Routing/ContentFinderByUrlAndTemplateTests.cs
@@ -31,12 +31,13 @@ namespace Umbraco.Tests.Routing
[TestCase("/home/Sub1.aspx/blah")]
public void Match_Document_By_Url_With_Template(string urlAsString)
{
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
+ var globalSettings = new GlobalSettingsBuilder()
+ .WithHideTopLevelNodeFromPath(false)
+ .Build();
var template1 = CreateTemplate("test");
var template2 = CreateTemplate("blah");
- var umbracoContext = GetUmbracoContext(urlAsString, template1.Id, globalSettings:globalSettings.Object);
+ var umbracoContext = GetUmbracoContext(urlAsString, template1.Id, globalSettings: globalSettings);
var publishedRouter = CreatePublishedRouter();
var frequest = publishedRouter.CreateRequest(umbracoContext);
var webRoutingSettings = new WebRoutingSettingsBuilder().Build();
diff --git a/src/Umbraco.Tests/Routing/ContentFinderByUrlTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByUrlTests.cs
index f7b6762774..0614d4a2bb 100644
--- a/src/Umbraco.Tests/Routing/ContentFinderByUrlTests.cs
+++ b/src/Umbraco.Tests/Routing/ContentFinderByUrlTests.cs
@@ -5,6 +5,7 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
using Umbraco.Web.Routing;
@@ -28,15 +29,15 @@ namespace Umbraco.Tests.Routing
[TestCase("/test-page", 1172)]
public void Match_Document_By_Url_Hide_Top_Level(string urlString, int expectedId)
{
- var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(true);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(true).Build();
- var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
+ var snapshotService = CreatePublishedSnapshotService(globalSettings);
+ var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettings, snapshotService: snapshotService);
var publishedRouter = CreatePublishedRouter();
var frequest = publishedRouter.CreateRequest(umbracoContext);
var lookup = new ContentFinderByUrl(Logger);
- Assert.IsTrue(Current.Configs.Global().HideTopLevelNodeFromPath);
+ Assert.IsTrue(globalSettings.HideTopLevelNodeFromPath);
// FIXME: debugging - going further down, the routes cache is NOT empty?!
if (urlString == "/home/sub1")
@@ -63,15 +64,14 @@ namespace Umbraco.Tests.Routing
[TestCase("/home/Sub1.aspx", 1173)]
public void Match_Document_By_Url(string urlString, int expectedId)
{
- var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
+ var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettings);
var publishedRouter = CreatePublishedRouter();
var frequest = publishedRouter.CreateRequest(umbracoContext);
var lookup = new ContentFinderByUrl(Logger);
- Assert.IsFalse(Current.Configs.Global().HideTopLevelNodeFromPath);
+ Assert.IsFalse(globalSettings.HideTopLevelNodeFromPath);
var result = lookup.TryFindContent(frequest);
@@ -88,10 +88,9 @@ namespace Umbraco.Tests.Routing
[TestCase("/home/sub1/custom-sub-4-with-æøå", 1180)]
public void Match_Document_By_Url_With_Special_Characters(string urlString, int expectedId)
{
- var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
+ var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettings);
var publishedRouter = CreatePublishedRouter();
var frequest = publishedRouter.CreateRequest(umbracoContext);
var lookup = new ContentFinderByUrl(Logger);
@@ -115,10 +114,9 @@ namespace Umbraco.Tests.Routing
[TestCase("/home/sub1/custom-sub-4-with-æøå", 1180)]
public void Match_Document_By_Url_With_Special_Characters_Using_Hostname(string urlString, int expectedId)
{
- var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
+ var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettings);
var publishedRouter = CreatePublishedRouter();
var frequest = publishedRouter.CreateRequest(umbracoContext);
frequest.Domain = new DomainAndUri(new Domain(1, "mysite", -1, CultureInfo.CurrentCulture, false), new Uri("http://mysite/"));
@@ -144,10 +142,9 @@ namespace Umbraco.Tests.Routing
[TestCase("/æøå/home/sub1/custom-sub-4-with-æøå", 1180)]
public void Match_Document_By_Url_With_Special_Characters_In_Hostname(string urlString, int expectedId)
{
- var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
+ var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettings);
var publishedRouter = CreatePublishedRouter();
var frequest = publishedRouter.CreateRequest(umbracoContext);
frequest.Domain = new DomainAndUri(new Domain(1, "mysite/æøå", -1, CultureInfo.CurrentCulture, false), new Uri("http://mysite/æøå"));
diff --git a/src/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs
index ac2e62b1ef..622df53d9e 100644
--- a/src/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs
+++ b/src/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs
@@ -4,6 +4,7 @@ using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
+using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web.Routing;
@@ -127,10 +128,9 @@ namespace Umbraco.Tests.Routing
{
SetDomains3();
- var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(true);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(true).Build();
- var umbracoContext = GetUmbracoContext(url, globalSettings:globalSettingsMock.Object);
+ var umbracoContext = GetUmbracoContext(url, globalSettings:globalSettings);
var publishedRouter = CreatePublishedRouter(Factory);
var frequest = publishedRouter.CreateRequest(umbracoContext);
@@ -169,10 +169,9 @@ namespace Umbraco.Tests.Routing
// defaults depend on test environment
expectedCulture = expectedCulture ?? System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
- var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(true);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(true).Build();
- var umbracoContext = GetUmbracoContext(url, globalSettings:globalSettingsMock.Object);
+ var umbracoContext = GetUmbracoContext(url, globalSettings:globalSettings);
var publishedRouter = CreatePublishedRouter(Factory);
var frequest = publishedRouter.CreateRequest(umbracoContext);
diff --git a/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs b/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs
index a81f345e38..0d39092b88 100644
--- a/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs
+++ b/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs
@@ -6,6 +6,7 @@ using Umbraco.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Tests.Common.Builders;
namespace Umbraco.Tests.Routing
{
@@ -266,10 +267,10 @@ namespace Umbraco.Tests.Routing
{
SetDomains1();
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
- var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings.Object);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
+
+ var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings);
var publishedRouter = CreatePublishedRouter(Factory);
var frequest = publishedRouter.CreateRequest(umbracoContext);
@@ -315,10 +316,9 @@ namespace Umbraco.Tests.Routing
// defaults depend on test environment
expectedCulture = expectedCulture ?? System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings.Object);
+ var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings);
var publishedRouter = CreatePublishedRouter(Factory);
var frequest = publishedRouter.CreateRequest(umbracoContext);
@@ -370,9 +370,8 @@ namespace Umbraco.Tests.Routing
{
SetDomains3();
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
- var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings.Object);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
+ var umbracoContext = GetUmbracoContext(inputUrl, globalSettings:globalSettings);
var publishedRouter = CreatePublishedRouter(Factory);
var frequest = publishedRouter.CreateRequest(umbracoContext);
diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
index 3f97f1a4a3..3328114576 100644
--- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
+++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
@@ -52,8 +52,8 @@ namespace Umbraco.Tests.Routing
public class TestRuntime : CoreRuntime
{
- public TestRuntime(Configs configs, GlobalSettings globalSettings, ConnectionStrings connectionStrings, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
- : base(configs, globalSettings, connectionStrings,umbracoVersion, ioHelper, Mock.Of(), Mock.Of(), new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator, TestHelper.MainDom, TestHelper.GetTypeFinder(), AppCaches.NoCache)
+ public TestRuntime(GlobalSettings globalSettings, ConnectionStrings connectionStrings, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
+ : base(globalSettings, connectionStrings,umbracoVersion, ioHelper, Mock.Of(), Mock.Of(), new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator, TestHelper.MainDom, TestHelper.GetTypeFinder(), AppCaches.NoCache)
{
}
diff --git a/src/Umbraco.Tests/Routing/RoutableDocumentFilterTests.cs b/src/Umbraco.Tests/Routing/RoutableDocumentFilterTests.cs
index a78459fa39..9bf85d61be 100644
--- a/src/Umbraco.Tests/Routing/RoutableDocumentFilterTests.cs
+++ b/src/Umbraco.Tests/Routing/RoutableDocumentFilterTests.cs
@@ -1,9 +1,12 @@
-using System.Web.Mvc;
+using System;
+using System.Web.Mvc;
using System.Web.Routing;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Configuration;
+using Umbraco.Infrastructure.Configuration;
+using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
@@ -51,12 +54,13 @@ namespace Umbraco.Tests.Routing
public void Is_Reserved_By_Route(string url, bool shouldMatch)
{
//reset the app config, we only want to test routes not the hard coded paths
- // TODO: Why are we using and modifying the global IGlobalSettings and not just a custom one?
- var globalSettingsMock = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettingsMock.Setup(x => x.ReservedPaths).Returns("");
- globalSettingsMock.Setup(x => x.ReservedUrls).Returns("");
- var routableDocFilter = new RoutableDocumentFilter(globalSettingsMock.Object, IOHelper);
+ var globalSettings = new GlobalSettingsBuilder()
+ .WithReservedPaths(string.Empty)
+ .WithReservedUrls(String.Empty)
+ .Build();
+
+ var routableDocFilter = new RoutableDocumentFilter(globalSettings, IOHelper);
var routes = new RouteCollection();
diff --git a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
index 993b0a112b..a2b3ce62e4 100644
--- a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
+++ b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
@@ -36,7 +36,7 @@ namespace Umbraco.Tests.Routing
logger,
null, // FIXME: PublishedRouter complexities...
Mock.Of(),
- new RoutableDocumentFilter(ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings), IOHelper),
+ new RoutableDocumentFilter(globalSettings, IOHelper),
UriUtility,
AppCaches.RequestCache,
ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings),
diff --git a/src/Umbraco.Tests/Routing/UrlProviderWithHideTopLevelNodeFromPathTests.cs b/src/Umbraco.Tests/Routing/UrlProviderWithHideTopLevelNodeFromPathTests.cs
index b38e7b5fc9..a5bbdd1f7c 100644
--- a/src/Umbraco.Tests/Routing/UrlProviderWithHideTopLevelNodeFromPathTests.cs
+++ b/src/Umbraco.Tests/Routing/UrlProviderWithHideTopLevelNodeFromPathTests.cs
@@ -29,7 +29,7 @@ namespace Umbraco.Tests.Routing
base.ComposeSettings();
Composition.RegisterUnique(x => Microsoft.Extensions.Options.Options.Create(_globalSettings));
}
-
+
[TestCase(1046, "/")]
[TestCase(1173, "/sub1/")]
[TestCase(1174, "/sub1/sub2/")]
@@ -40,11 +40,10 @@ namespace Umbraco.Tests.Routing
[TestCase(1172, "/test-page/")] // not hidden because not first root
public void Get_Url_Hiding_Top_Level(int nodeId, string niceUrlMatch)
{
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(true);
var requestHandlerSettings = new RequestHandlerSettingsBuilder().WithAddTrailingSlash(true).Build();
- var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(_globalSettings));
+ var snapshotService = CreatePublishedSnapshotService(_globalSettings);
+ var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: _globalSettings,snapshotService:snapshotService);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
diff --git a/src/Umbraco.Tests/Routing/UrlProviderWithoutHideTopLevelNodeFromPathTests.cs b/src/Umbraco.Tests/Routing/UrlProviderWithoutHideTopLevelNodeFromPathTests.cs
index e4275fe391..bb25635d6f 100644
--- a/src/Umbraco.Tests/Routing/UrlProviderWithoutHideTopLevelNodeFromPathTests.cs
+++ b/src/Umbraco.Tests/Routing/UrlProviderWithoutHideTopLevelNodeFromPathTests.cs
@@ -46,7 +46,7 @@ namespace Umbraco.Tests.Routing
{
var requestHandlerSettings = new RequestHandlerSettingsBuilder().WithAddTrailingSlash(false).Build();
- var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(_globalSettings));
+ var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: _globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
@@ -107,7 +107,7 @@ namespace Umbraco.Tests.Routing
{
var requestHandlerSettings = new RequestHandlerSettingsBuilder().WithAddTrailingSlash(true).Build();
- var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(_globalSettings));
+ var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: _globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
@@ -147,7 +147,7 @@ namespace Umbraco.Tests.Routing
.Returns(snapshot);
var umbracoContext = GetUmbracoContext(currentUri,
- globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(_globalSettings),
+ globalSettings: _globalSettings,
snapshotService: snapshotService.Object);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
@@ -202,7 +202,7 @@ namespace Umbraco.Tests.Routing
.Returns(snapshot);
var umbracoContext = GetUmbracoContext(currentUri,
- globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(_globalSettings),
+ globalSettings: _globalSettings,
snapshotService: snapshotService.Object);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
@@ -257,7 +257,7 @@ namespace Umbraco.Tests.Routing
.Returns(snapshot);
var umbracoContext = GetUmbracoContext(currentUri,
- globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(_globalSettings),
+ globalSettings: _globalSettings,
snapshotService: snapshotService.Object);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
@@ -279,7 +279,7 @@ namespace Umbraco.Tests.Routing
{
var requestHandlerSettings = new RequestHandlerSettingsBuilder().WithAddTrailingSlash(true).Build();
- var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(_globalSettings));
+ var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, globalSettings: _globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
@@ -303,7 +303,7 @@ namespace Umbraco.Tests.Routing
Logger,
Microsoft.Extensions.Options.Options.Create(_globalSettings),
new SiteDomainHelper(), UmbracoContextAccessor, UriUtility);
- var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(_globalSettings));
+ var umbracoContext = GetUmbracoContext("http://example.com/test", 1111, globalSettings: _globalSettings);
var publishedUrlProvider = GetPublishedUrlProvider(umbracoContext, urlProvider);
//mock the Umbraco settings that we need
diff --git a/src/Umbraco.Tests/Routing/UrlRoutesTests.cs b/src/Umbraco.Tests/Routing/UrlRoutesTests.cs
index 0c608d3e94..d0dd708561 100644
--- a/src/Umbraco.Tests/Routing/UrlRoutesTests.cs
+++ b/src/Umbraco.Tests/Routing/UrlRoutesTests.cs
@@ -5,6 +5,7 @@ using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
+using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
@@ -196,10 +197,9 @@ DetermineRouteById(id):
[TestCase(2006, false, "/x/b/e")]
public void GetRouteByIdNoHide(int id, bool hide, string expected)
{
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(hide).Build();
- var umbracoContext = GetUmbracoContext("/test", 0, globalSettings: globalSettings.Object);
+ var umbracoContext = GetUmbracoContext("/test", 0, globalSettings: globalSettings);
var cache = umbracoContext.Content as PublishedContentCache;
if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported.");
@@ -220,10 +220,10 @@ DetermineRouteById(id):
[TestCase(2006, true, "/b/e")] // risky!
public void GetRouteByIdHide(int id, bool hide, string expected)
{
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(hide).Build();
- var umbracoContext = GetUmbracoContext("/test", 0, globalSettings: globalSettings.Object);
+ var snapshotService = CreatePublishedSnapshotService(globalSettings);
+ var umbracoContext = GetUmbracoContext("/test", 0, globalSettings: globalSettings, snapshotService: snapshotService);
var cache = umbracoContext.Content as PublishedContentCache;
if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported.");
@@ -234,10 +234,10 @@ DetermineRouteById(id):
[Test]
public void GetRouteByIdCache()
{
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object);
+ var snapshotService = CreatePublishedSnapshotService(globalSettings);
+ var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings, snapshotService: snapshotService);
var cache = umbracoContext.Content as PublishedContentCache;
if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported.");
@@ -265,10 +265,10 @@ DetermineRouteById(id):
[TestCase("/x", false, 2000)]
public void GetByRouteNoHide(string route, bool hide, int expected)
{
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(hide).Build();
- var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object);
+ var snapshotService = CreatePublishedSnapshotService(globalSettings);
+ var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings, snapshotService: snapshotService);
var cache = umbracoContext.Content as PublishedContentCache;
if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported.");
@@ -296,10 +296,10 @@ DetermineRouteById(id):
[TestCase("/b/c", true, 1002)] // (hence the 2005 collision)
public void GetByRouteHide(string route, bool hide, int expected)
{
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(hide);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(hide).Build();
- var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object);
+ var snapshotService = CreatePublishedSnapshotService(globalSettings);
+ var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings, snapshotService: snapshotService);
var cache = umbracoContext.Content as PublishedContentCache;
if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported.");
@@ -319,10 +319,10 @@ DetermineRouteById(id):
[Test]
public void GetByRouteCache()
{
- var globalSettings = Mock.Get(Factory.GetInstance()); //this will modify the IGlobalSettings instance stored in the container
- globalSettings.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
+ var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings.Object);
+ var snapshotService = CreatePublishedSnapshotService(globalSettings);
+ var umbracoContext = GetUmbracoContext("/test", 0, globalSettings:globalSettings, snapshotService:snapshotService);
var cache = umbracoContext.Content as PublishedContentCache;
if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported.");
diff --git a/src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs b/src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs
index 3e7fb611df..c566e742cb 100644
--- a/src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs
+++ b/src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs
@@ -182,7 +182,7 @@ namespace Umbraco.Tests.Routing
var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings));
+ var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
Logger,
@@ -216,7 +216,7 @@ namespace Umbraco.Tests.Routing
var requestHandlerSettings = new RequestHandlerSettingsBuilder().WithAddTrailingSlash(true).Build();
var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings));
+ var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
Logger,
@@ -243,7 +243,7 @@ namespace Umbraco.Tests.Routing
var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings));
+ var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
Logger,
@@ -276,7 +276,7 @@ namespace Umbraco.Tests.Routing
var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings));
+ var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
@@ -300,7 +300,7 @@ namespace Umbraco.Tests.Routing
var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings));
+ var umbracoContext = GetUmbracoContext("/test", 1111, globalSettings: globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
@@ -366,7 +366,7 @@ namespace Umbraco.Tests.Routing
var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext("http://domain1.com/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings));
+ var umbracoContext = GetUmbracoContext("http://domain1.com/test", 1111, globalSettings: globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
@@ -393,7 +393,7 @@ namespace Umbraco.Tests.Routing
var globalSettings = new GlobalSettingsBuilder().WithHideTopLevelNodeFromPath(false).Build();
- var umbracoContext = GetUmbracoContext("http://domain1.com/en/test", 1111, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings));
+ var umbracoContext = GetUmbracoContext("http://domain1.com/en/test", 1111, globalSettings: globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
diff --git a/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs b/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs
index fdd891bda6..d5b98c402f 100644
--- a/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs
+++ b/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Tests.Routing
const string url = "http://domain1.com/1001-1/1001-1-1";
// get the nice url for 100111
- var umbracoContext = GetUmbracoContext(url, 9999, globalSettings: ConfigModelConversionsToLegacy.ConvertGlobalSettings(globalSettings));
+ var umbracoContext = GetUmbracoContext(url, 9999, globalSettings: globalSettings);
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
var urlProvider = new DefaultUrlProvider(
Microsoft.Extensions.Options.Options.Create(requestHandlerSettings),
diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
index 531102ae59..4de83eed4e 100644
--- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
+++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
@@ -7,6 +7,7 @@ using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Hosting;
@@ -21,6 +22,7 @@ using Umbraco.Tests.TestHelpers.Stubs;
using Umbraco.Web;
using Umbraco.Web.Hosting;
using Umbraco.Web.Runtime;
+using ConnectionStrings = Umbraco.Core.Configuration.Models.ConnectionStrings;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Runtimes
@@ -82,18 +84,21 @@ namespace Umbraco.Tests.Runtimes
// test application
public class TestUmbracoApplication : UmbracoApplicationBase
{
- public TestUmbracoApplication() : base(_logger, _configs, _ioHelper, _profiler, new AspNetHostingEnvironment(_hostingSettings), new AspNetBackOfficeInfo(_globalSettings, _ioHelper, _logger, _settings))
+ public TestUmbracoApplication() : base(_logger,
+ ConfigModelConversionsFromLegacy.ConvertSecuritySettings(SettingsForTests.GenerateMockSecuritySettings()),
+ ConfigModelConversionsFromLegacy.ConvertGlobalSettings(SettingsForTests.DefaultGlobalSettings),
+ new ConnectionStrings(),
+ _ioHelper, _profiler, new AspNetHostingEnvironment(_hostingSettings), new AspNetBackOfficeInfo(_globalSettings, _ioHelper, _logger, _settings))
{
}
private static readonly DebugDiagnosticsLogger _logger = new DebugDiagnosticsLogger(new MessageTemplates());
private static readonly IIOHelper _ioHelper = TestHelper.IOHelper;
private static readonly IProfiler _profiler = new TestProfiler();
- private static readonly Configs _configs = GetConfigs();
private static readonly IGlobalSettings _globalSettings = SettingsForTests.DefaultGlobalSettings;
private static readonly IHostingSettings _hostingSettings = SettingsForTests.DefaultHostingSettings;
private static readonly IContentSettings _contentSettings = SettingsForTests.GenerateMockContentSettings();
- private static readonly IWebRoutingSettings _settings = _configs.WebRouting();
+ private static readonly IWebRoutingSettings _settings = SettingsForTests.GenerateMockWebRoutingSettings();
private static Configs GetConfigs()
{
@@ -106,17 +111,17 @@ namespace Umbraco.Tests.Runtimes
public IRuntime Runtime { get; private set; }
- protected override IRuntime GetRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
+ protected override IRuntime GetRuntime(GlobalSettings globalSettings, ConnectionStrings connectionStrings, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
{
- return Runtime = new TestRuntime(configs, umbracoVersion, ioHelper, logger, profiler, hostingEnvironment, backOfficeInfo);
+ return Runtime = new TestRuntime(globalSettings, connectionStrings, umbracoVersion, ioHelper, logger, profiler, hostingEnvironment, backOfficeInfo);
}
}
// test runtime
public class TestRuntime : CoreRuntime
{
- public TestRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
- :base(configs, ConfigModelConversionsFromLegacy.ConvertGlobalSettings(configs.Global()), ConfigModelConversionsFromLegacy.ConvertConnectionStrings(configs.ConnectionStrings()),umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator, TestHelper.MainDom, TestHelper.GetTypeFinder(), AppCaches.NoCache)
+ public TestRuntime(GlobalSettings globalSettings, ConnectionStrings connectionStrings, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
+ :base(globalSettings, connectionStrings,umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator, TestHelper.MainDom, TestHelper.GetTypeFinder(), AppCaches.NoCache)
{
}
diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
index 2231633a10..5f0fc607c6 100644
--- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
+++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
@@ -81,11 +81,11 @@ namespace Umbraco.Tests.Runtimes
// create the register and the composition
var register = TestHelper.GetRegister();
- var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs, ioHelper, appCaches);
+ var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, ioHelper, appCaches);
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion, TestHelper.DbProviderFactoryCreator, hostingEnvironment, backOfficeInfo);
// create the core runtime and have it compose itself
- var coreRuntime = new CoreRuntime(configs, globalSettings, connectionStrings, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator, TestHelper.MainDom, typeFinder, AppCaches.NoCache);
+ var coreRuntime = new CoreRuntime(globalSettings, connectionStrings, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator, TestHelper.MainDom, typeFinder, AppCaches.NoCache);
// determine actual runtime level
runtimeState.DetermineRuntimeLevel();
@@ -289,7 +289,7 @@ namespace Umbraco.Tests.Runtimes
// create the register and the composition
var register = TestHelper.GetRegister();
- var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs, ioHelper, appCaches);
+ var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, ioHelper, appCaches);
var umbracoVersion = TestHelper.GetUmbracoVersion();
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion, TestHelper.DbProviderFactoryCreator, hostingEnvironment, backOfficeInfo);
@@ -297,7 +297,7 @@ namespace Umbraco.Tests.Runtimes
var globalSettings = new GlobalSettingsBuilder().Build();
var connectionStrings = new ConnectionStringsBuilder().Build();
- var coreRuntime = new CoreRuntime(configs, globalSettings, connectionStrings, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator, TestHelper.MainDom, typeFinder, AppCaches.NoCache);
+ var coreRuntime = new CoreRuntime(globalSettings, connectionStrings, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator, TestHelper.MainDom, typeFinder, AppCaches.NoCache);
// get the components
// all of them?
diff --git a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs
index a0c954e7bb..d775b0d8d3 100644
--- a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs
@@ -35,7 +35,7 @@ namespace Umbraco.Tests.Scoping
var register = TestHelper.GetRegister();
- var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(register, TestHelper.GetMockedTypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
_testObjects = new TestObjects(register);
@@ -43,9 +43,6 @@ namespace Umbraco.Tests.Scoping
composition.RegisterUnique(factory => new FileSystems(factory, factory.TryGetInstance(), TestHelper.IOHelper, Microsoft.Extensions.Options.Options.Create(globalSettings), TestHelper.GetHostingEnvironment()));
composition.WithCollectionBuilder();
- composition.Configs.Add(() => SettingsForTests.DefaultGlobalSettings);
- composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
-
Current.Reset();
Current.Factory = composition.CreateFactory();
diff --git a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
index 35f4f421bd..243ad50eef 100644
--- a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
@@ -8,6 +8,7 @@ using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Events;
using Umbraco.Core.Install;
@@ -74,7 +75,7 @@ namespace Umbraco.Tests.Scoping
private Action _onPublishedAssertAction;
- protected override IPublishedSnapshotService CreatePublishedSnapshotService()
+ protected override IPublishedSnapshotService CreatePublishedSnapshotService(GlobalSettings globalSettings = null)
{
var options = new PublishedSnapshotServiceOptions { IgnoreLocalDb = true };
var publishedSnapshotAccessor = new UmbracoContextPublishedSnapshotAccessor(Umbraco.Web.Composing.Current.UmbracoContextAccessor);
@@ -89,7 +90,6 @@ namespace Umbraco.Tests.Scoping
var typeFinder = TestHelper.GetTypeFinder();
- var globalSettings = new GlobalSettingsBuilder().Build();
var nuCacheSettings = new NuCacheSettingsBuilder().Build();
return new PublishedSnapshotService(
@@ -105,7 +105,7 @@ namespace Umbraco.Tests.Scoping
documentRepository, mediaRepository, memberRepository,
DefaultCultureAccessor,
new DatabaseDataSource(Mock.Of()),
- Microsoft.Extensions.Options.Options.Create(globalSettings),
+ Microsoft.Extensions.Options.Options.Create(globalSettings ?? new GlobalSettingsBuilder().Build()),
Factory.GetInstance(),
new NoopPublishedModelFactory(),
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider(ShortStringHelper) }),
diff --git a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs
index 72c6438324..59610e43bd 100644
--- a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs
@@ -51,10 +51,6 @@ namespace Umbraco.Tests.Scoping
Composition.Register(x => Microsoft.Extensions.Options.Options.Create(contentSettings));
Composition.Register(x => Microsoft.Extensions.Options.Options.Create(globalSettings));
Composition.Register(x => Microsoft.Extensions.Options.Options.Create(userPasswordConfigurationSettings));
-
- // TODO: remove this once legacy config is fully extracted.
- Composition.Configs.Add(SettingsForTests.GenerateMockContentSettings);
- Composition.Configs.Add(SettingsForTests.GenerateMockGlobalSettings);
}
[TearDown]
diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs
index 5830513fbd..bef6fde816 100644
--- a/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs
+++ b/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs
@@ -8,6 +8,7 @@ using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.Install;
using Umbraco.Core.Logging;
@@ -46,7 +47,7 @@ namespace Umbraco.Tests.Services
.Add(() => Composition.TypeLoader.GetCacheRefreshers());
}
- protected override IPublishedSnapshotService CreatePublishedSnapshotService()
+ protected override IPublishedSnapshotService CreatePublishedSnapshotService(GlobalSettings globalSettings = null)
{
var options = new PublishedSnapshotServiceOptions { IgnoreLocalDb = true };
var publishedSnapshotAccessor = new UmbracoContextPublishedSnapshotAccessor(Umbraco.Web.Composing.Current.UmbracoContextAccessor);
@@ -61,7 +62,6 @@ namespace Umbraco.Tests.Services
var typeFinder = TestHelper.GetTypeFinder();
- var globalSettings = new GlobalSettingsBuilder().Build();
var nuCacheSettings = new NuCacheSettingsBuilder().Build();
return new PublishedSnapshotService(
@@ -77,7 +77,7 @@ namespace Umbraco.Tests.Services
documentRepository, mediaRepository, memberRepository,
DefaultCultureAccessor,
new DatabaseDataSource(Mock.Of()),
- Microsoft.Extensions.Options.Options.Create(globalSettings),
+ Microsoft.Extensions.Options.Options.Create(globalSettings ?? new GlobalSettingsBuilder().Build()),
Factory.GetInstance(),
Mock.Of(),
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider(ShortStringHelper) }),
diff --git a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs
index 6bc228bf83..3faea42f01 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.TestHelpers
logger,
false);
- var composition = new Composition(container, typeLoader, Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ var composition = new Composition(container, typeLoader, Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
composition.RegisterUnique(_ => Mock.Of());
composition.RegisterUnique(_ => Mock.Of());
diff --git a/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs
index 641691e853..27aa9a832c 100644
--- a/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs
+++ b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs
@@ -23,6 +23,7 @@ using Umbraco.Web.Routing;
using Umbraco.Web.Security;
using Umbraco.Web.WebApi;
using Umbraco.Core.Logging;
+using Umbraco.Infrastructure.Configuration;
using Umbraco.Tests.Testing.Objects.Accessors;
using Umbraco.Web.Security.Providers;
using Umbraco.Tests.Strings;
@@ -67,7 +68,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
contentTypeService: mockedContentTypeService,
localizedTextService:Mock.Of());
- var globalSettings = SettingsForTests.GenerateMockGlobalSettings();
+ var globalSettings = ConfigModelConversionsFromLegacy.ConvertGlobalSettings(SettingsForTests.GenerateMockGlobalSettings());
// FIXME: v8?
////new app context
diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs
index 1b63bcc98d..1ed2bce83e 100644
--- a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs
@@ -8,12 +8,14 @@ using Moq;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Services;
+using Umbraco.Infrastructure.Configuration;
using Umbraco.Persistance.SqlCe;
using Umbraco.Tests.Common;
using Umbraco.Web;
@@ -136,9 +138,9 @@ namespace Umbraco.Tests.TestHelpers
return umbracoContextFactory.EnsureUmbracoContext().UmbracoContext;
}
- public IGlobalSettings GetGlobalSettings()
+ public GlobalSettings GetGlobalSettings()
{
- return SettingsForTests.DefaultGlobalSettings;
+ return ConfigModelConversionsFromLegacy.ConvertGlobalSettings(SettingsForTests.DefaultGlobalSettings);
}
public IFileSystems GetFileSystemsMock()
{
diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
index 3c88f710bc..6e133778bb 100644
--- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
@@ -11,6 +11,7 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
@@ -29,6 +30,7 @@ using Umbraco.Tests.Testing;
using Umbraco.Core.Migrations.Install;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence.Repositories;
+using Umbraco.Infrastructure.Configuration;
using Umbraco.Persistance.SqlCe;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Web.WebApi;
@@ -238,7 +240,7 @@ namespace Umbraco.Tests.TestHelpers
}
}
- protected virtual IPublishedSnapshotService CreatePublishedSnapshotService()
+ protected virtual IPublishedSnapshotService CreatePublishedSnapshotService(GlobalSettings globalSettings = null)
{
var cache = NoAppCache.Instance;
@@ -262,7 +264,7 @@ namespace Umbraco.Tests.TestHelpers
Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(),
DefaultCultureAccessor,
Logger,
- Factory.GetInstance(),
+ globalSettings ?? TestObjects.GetGlobalSettings(),
HostingEnvironment,
HostingLifetime,
ShortStringHelper,
@@ -352,7 +354,7 @@ namespace Umbraco.Tests.TestHelpers
}
}
- protected IUmbracoContext GetUmbracoContext(string url, int templateId = 1234, RouteData routeData = null, bool setSingleton = false, IGlobalSettings globalSettings = null, IPublishedSnapshotService snapshotService = null)
+ protected IUmbracoContext GetUmbracoContext(string url, int templateId = 1234, RouteData routeData = null, bool setSingleton = false, GlobalSettings globalSettings = null, IPublishedSnapshotService snapshotService = null)
{
// ensure we have a PublishedCachesService
var service = snapshotService ?? PublishedSnapshotService as XmlPublishedSnapshotService;
@@ -376,7 +378,7 @@ namespace Umbraco.Tests.TestHelpers
httpContextAccessor,
service,
Mock.Of(),
- globalSettings ?? Factory.GetInstance(),
+ globalSettings ?? new GlobalSettingsBuilder().Build(),
HostingEnvironment,
new TestVariationContextAccessor(),
UriUtility,
diff --git a/src/Umbraco.Tests/Testing/Objects/TestUmbracoContextFactory.cs b/src/Umbraco.Tests/Testing/Objects/TestUmbracoContextFactory.cs
index cb20c56d6d..595185c271 100644
--- a/src/Umbraco.Tests/Testing/Objects/TestUmbracoContextFactory.cs
+++ b/src/Umbraco.Tests/Testing/Objects/TestUmbracoContextFactory.cs
@@ -1,8 +1,10 @@
using Moq;
using NUnit.Framework.Internal;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Services;
+using Umbraco.Infrastructure.Configuration;
using Umbraco.Tests.Common;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
@@ -16,12 +18,12 @@ namespace Umbraco.Tests.Testing.Objects
///
public class TestUmbracoContextFactory
{
- public static IUmbracoContextFactory Create(IGlobalSettings globalSettings = null,
+ public static IUmbracoContextFactory Create(GlobalSettings globalSettings = null,
IUmbracoContextAccessor umbracoContextAccessor = null,
IHttpContextAccessor httpContextAccessor = null,
IPublishedUrlProvider publishedUrlProvider = null)
{
- if (globalSettings == null) globalSettings = TestHelpers.SettingsForTests.GenerateMockGlobalSettings();
+ if (globalSettings == null) globalSettings = ConfigModelConversionsFromLegacy.ConvertGlobalSettings(TestHelpers.SettingsForTests.GenerateMockGlobalSettings());
if (umbracoContextAccessor == null) umbracoContextAccessor = new TestUmbracoContextAccessor();
if (httpContextAccessor == null) httpContextAccessor = TestHelper.GetHttpContextAccessor();
if (publishedUrlProvider == null) publishedUrlProvider = TestHelper.GetPublishedUrlProvider();
diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
index affce75c20..3d2a4496a6 100644
--- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
+++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
@@ -188,9 +188,11 @@ namespace Umbraco.Tests.Testing
- Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
+ Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache);
+ TestHelper.GetConfigs().RegisterWith(register);
+
Composition.RegisterUnique(IOHelper);
Composition.RegisterUnique(UriUtility);
@@ -427,16 +429,6 @@ namespace Umbraco.Tests.Testing
Composition.Register(x => Microsoft.Extensions.Options.Options.Create(requestHandlerSettings));
Composition.Register(x => Microsoft.Extensions.Options.Options.Create(userPasswordConfigurationSettings));
Composition.Register(x => Microsoft.Extensions.Options.Options.Create(webRoutingSettings));
-
- // TODO: remove this once legacy config is fully extracted.
- Composition.Configs.Add(() => TestHelpers.SettingsForTests.DefaultGlobalSettings);
- Composition.Configs.Add(() => TestHelpers.SettingsForTests.DefaultHostingSettings);
- Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockRequestHandlerSettings);
- Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockWebRoutingSettings);
- Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockSecuritySettings);
- Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockUserPasswordConfiguration);
- Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockMemberPasswordConfiguration);
- Composition.Configs.Add(TestHelpers.SettingsForTests.GenerateMockContentSettings);
}
protected virtual void ComposeApplication(bool withApplication)
diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
index 06b2d7b421..1bec3d04f1 100644
--- a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
+++ b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
@@ -156,11 +156,6 @@ namespace Umbraco.Extensions
settings.EnableTours = false;
});
- // TODO: remove this once no longer requred in Umbraco.Web.
- var configsFactory = new AspNetCoreConfigsFactory(configuration);
- var configs = configsFactory.Create();
- services.AddSingleton(configs);
-
return services;
}
@@ -235,7 +230,7 @@ namespace Umbraco.Extensions
AppCaches appCaches,
ILoggingConfiguration loggingConfiguration,
//TODO: Yep that's extremely ugly
- Func getRuntime,
+ Func getRuntime,
out IFactory factory)
{
if (services is null) throw new ArgumentNullException(nameof(services));
@@ -280,9 +275,7 @@ namespace Umbraco.Extensions
var umbracoVersion = new UmbracoVersion();
var typeFinder = CreateTypeFinder(logger, profiler, webHostEnvironment, entryAssembly, typeFinderSettings);
- var configs = serviceProvider.GetService();
var coreRuntime = getRuntime(
- configs,
globalSettings.CurrentValue,
connectionStrings.Value,
umbracoVersion,
@@ -316,8 +309,8 @@ namespace Umbraco.Extensions
}
private static IRuntime GetCoreRuntime(
- Configs configs, GlobalSettings globalSettings, ConnectionStrings connectionStrings, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, Core.Logging.ILogger logger,
- IProfiler profiler, Core.Hosting.IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo,
+ GlobalSettings globalSettings, ConnectionStrings connectionStrings, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger,
+ IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo,
ITypeFinder typeFinder, AppCaches appCaches, IDbProviderFactoryCreator dbProviderFactoryCreator)
{
// Determine if we should use the sql main dom or the default
@@ -331,7 +324,6 @@ namespace Umbraco.Extensions
var mainDom = new MainDom(logger, mainDomLock);
var coreRuntime = new CoreRuntime(
- configs,
globalSettings,
connectionStrings,
umbracoVersion,
diff --git a/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs b/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs
index 679fb7987c..6d177651dc 100644
--- a/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs
+++ b/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs
@@ -6,6 +6,7 @@ using System.Web.Routing;
using System.Web.SessionState;
using Umbraco.Core;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Infrastructure.Configuration;
using Umbraco.Web.WebApi;
@@ -42,7 +43,7 @@ namespace Umbraco.Web.Mvc
///
///
internal static Route RouteControllerPlugin(this AreaRegistration area,
- IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment,
+ GlobalSettings globalSettings, IHostingEnvironment hostingEnvironment,
string controllerName, Type controllerType, RouteCollection routes,
string controllerSuffixName, string defaultAction, object defaultId,
string umbracoTokenValue = "backoffice",
@@ -58,7 +59,7 @@ namespace Umbraco.Web.Mvc
if (routes == null) throw new ArgumentNullException(nameof(routes));
if (defaultId == null) throw new ArgumentNullException(nameof(defaultId));
- var umbracoArea = ConfigModelConversionsFromLegacy.ConvertGlobalSettings(globalSettings).GetUmbracoMvcArea(hostingEnvironment);
+ var umbracoArea = globalSettings.GetUmbracoMvcArea(hostingEnvironment);
//routes are explicitly named with controller names and IDs
var url = umbracoArea + "/" +
diff --git a/src/Umbraco.Web/Mvc/BackOfficeArea.cs b/src/Umbraco.Web/Mvc/BackOfficeArea.cs
index 677ae18a1e..bbb2078b10 100644
--- a/src/Umbraco.Web/Mvc/BackOfficeArea.cs
+++ b/src/Umbraco.Web/Mvc/BackOfficeArea.cs
@@ -1,5 +1,6 @@
using System.Web.Mvc;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Infrastructure.Configuration;
using Umbraco.Web.Editors;
@@ -9,10 +10,10 @@ namespace Umbraco.Web.Mvc
// TODO: This has been ported to netcore, can be removed
internal class BackOfficeArea : AreaRegistration
{
- private readonly IGlobalSettings _globalSettings;
+ private readonly GlobalSettings _globalSettings;
private readonly IHostingEnvironment _hostingEnvironment;
- public BackOfficeArea(IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
+ public BackOfficeArea(GlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
{
_globalSettings = globalSettings;
_hostingEnvironment = hostingEnvironment;
@@ -49,6 +50,6 @@ namespace Umbraco.Web.Mvc
new[] {typeof (BackOfficeController).Namespace});
}
- public override string AreaName => ConfigModelConversionsFromLegacy.ConvertGlobalSettings(_globalSettings).GetUmbracoMvcArea(_hostingEnvironment);
+ public override string AreaName => _globalSettings.GetUmbracoMvcArea(_hostingEnvironment);
}
}
diff --git a/src/Umbraco.Web/Mvc/PluginControllerArea.cs b/src/Umbraco.Web/Mvc/PluginControllerArea.cs
index 838e304847..a4440ec4a6 100644
--- a/src/Umbraco.Web/Mvc/PluginControllerArea.cs
+++ b/src/Umbraco.Web/Mvc/PluginControllerArea.cs
@@ -6,6 +6,7 @@ using System.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Composing;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Web.WebApi;
@@ -17,7 +18,7 @@ namespace Umbraco.Web.Mvc
///
internal class PluginControllerArea : AreaRegistration
{
- private readonly IGlobalSettings _globalSettings;
+ private readonly GlobalSettings _globalSettings;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IEnumerable _surfaceControllers;
private readonly IEnumerable _apiControllers;
@@ -30,7 +31,7 @@ namespace Umbraco.Web.Mvc
///
///
///
- public PluginControllerArea(IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment, IEnumerable pluginControllers)
+ public PluginControllerArea(GlobalSettings globalSettings, IHostingEnvironment hostingEnvironment, IEnumerable pluginControllers)
{
_globalSettings = globalSettings;
_hostingEnvironment = hostingEnvironment;
diff --git a/src/Umbraco.Web/RoutableDocumentFilter.cs b/src/Umbraco.Web/RoutableDocumentFilter.cs
index 43e47a39b3..3580e25c78 100644
--- a/src/Umbraco.Web/RoutableDocumentFilter.cs
+++ b/src/Umbraco.Web/RoutableDocumentFilter.cs
@@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Collections.Concurrent;
using Umbraco.Core.Collections;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
@@ -22,14 +23,14 @@ namespace Umbraco.Web
///
public sealed class RoutableDocumentFilter
{
- public RoutableDocumentFilter(IGlobalSettings globalSettings, IIOHelper ioHelper)
+ public RoutableDocumentFilter(GlobalSettings globalSettings, IIOHelper ioHelper)
{
_globalSettings = globalSettings;
_ioHelper = ioHelper;
}
private static readonly ConcurrentDictionary RouteChecks = new ConcurrentDictionary();
- private readonly IGlobalSettings _globalSettings;
+ private readonly GlobalSettings _globalSettings;
private readonly IIOHelper _ioHelper;
private object _locker = new object();
private bool _isInit = false;
diff --git a/src/Umbraco.Web/Runtime/WebInitialComponent.cs b/src/Umbraco.Web/Runtime/WebInitialComponent.cs
index 4c66322cde..15261a2d6f 100644
--- a/src/Umbraco.Web/Runtime/WebInitialComponent.cs
+++ b/src/Umbraco.Web/Runtime/WebInitialComponent.cs
@@ -8,6 +8,7 @@ using System.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.Strings;
using Umbraco.Infrastructure.Configuration;
@@ -23,7 +24,7 @@ namespace Umbraco.Web.Runtime
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly SurfaceControllerTypeCollection _surfaceControllerTypes;
private readonly UmbracoApiControllerTypeCollection _apiControllerTypes;
- private readonly IGlobalSettings _globalSettings;
+ private readonly GlobalSettings _globalSettings;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IShortStringHelper _shortStringHelper;
@@ -31,7 +32,7 @@ namespace Umbraco.Web.Runtime
IUmbracoContextAccessor umbracoContextAccessor,
SurfaceControllerTypeCollection surfaceControllerTypes,
UmbracoApiControllerTypeCollection apiControllerTypes,
- IGlobalSettings globalSettings,
+ GlobalSettings globalSettings,
IHostingEnvironment hostingEnvironment,
IShortStringHelper shortStringHelper)
{
@@ -109,13 +110,13 @@ namespace Umbraco.Web.Runtime
// internal for tests
internal static void CreateRoutes(
IUmbracoContextAccessor umbracoContextAccessor,
- IGlobalSettings globalSettings,
+ GlobalSettings globalSettings,
IShortStringHelper shortStringHelper,
SurfaceControllerTypeCollection surfaceControllerTypes,
UmbracoApiControllerTypeCollection apiControllerTypes,
IHostingEnvironment hostingEnvironment)
{
- var umbracoPath = ConfigModelConversionsFromLegacy.ConvertGlobalSettings(globalSettings).GetUmbracoMvcArea(hostingEnvironment);
+ var umbracoPath = globalSettings.GetUmbracoMvcArea(hostingEnvironment);
// create the front-end route
var defaultRoute = RouteTable.Routes.MapRoute(
@@ -147,12 +148,12 @@ namespace Umbraco.Web.Runtime
}
private static void RoutePluginControllers(
- IGlobalSettings globalSettings,
+ GlobalSettings globalSettings,
SurfaceControllerTypeCollection surfaceControllerTypes,
UmbracoApiControllerTypeCollection apiControllerTypes,
IHostingEnvironment hostingEnvironment)
{
- var umbracoPath = ConfigModelConversionsFromLegacy.ConvertGlobalSettings(globalSettings).GetUmbracoMvcArea(hostingEnvironment);
+ var umbracoPath = globalSettings.GetUmbracoMvcArea(hostingEnvironment);
// need to find the plugin controllers and route them
var pluginControllers = surfaceControllerTypes.Concat(apiControllerTypes).ToArray();
diff --git a/src/Umbraco.Web/UmbracoApplication.cs b/src/Umbraco.Web/UmbracoApplication.cs
index 37e2522d43..989dcfaf83 100644
--- a/src/Umbraco.Web/UmbracoApplication.cs
+++ b/src/Umbraco.Web/UmbracoApplication.cs
@@ -3,12 +3,13 @@ using System.Web;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Runtime;
-using Umbraco.Infrastructure.Configuration;
using Umbraco.Web.Runtime;
+using ConnectionStrings = Umbraco.Core.Configuration.Models.ConnectionStrings;
namespace Umbraco.Web
{
@@ -17,14 +18,10 @@ namespace Umbraco.Web
///
public class UmbracoApplication : UmbracoApplicationBase
{
- protected override IRuntime GetRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
+ protected override IRuntime GetRuntime(GlobalSettings globalSettings, ConnectionStrings connectionStrings, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
{
- var connectionStringConfig = configs.ConnectionStrings()[Constants.System.UmbracoConnectionName];
-
var dbProviderFactoryCreator = new UmbracoDbProviderFactoryCreator();
- var globalSettings = ConfigModelConversionsFromLegacy.ConvertGlobalSettings(configs.Global());
- var connectionStrings = ConfigModelConversionsFromLegacy.ConvertConnectionStrings(configs.ConnectionStrings());
// Determine if we should use the sql main dom or the default
var appSettingMainDomLock = globalSettings.MainDomLock;
@@ -43,7 +40,7 @@ namespace Umbraco.Web
new IsolatedCaches(type => new DeepCloneAppCache(new ObjectCacheAppCache())));
var umbracoBootPermissionChecker = new AspNetUmbracoBootPermissionChecker();
- return new CoreRuntime(configs, globalSettings, connectionStrings,umbracoVersion, ioHelper, logger, profiler, umbracoBootPermissionChecker, hostingEnvironment, backOfficeInfo, dbProviderFactoryCreator, mainDom,
+ return new CoreRuntime(globalSettings, connectionStrings,umbracoVersion, ioHelper, logger, profiler, umbracoBootPermissionChecker, hostingEnvironment, backOfficeInfo, dbProviderFactoryCreator, mainDom,
GetTypeFinder(hostingEnvironment, logger, profiler), appCaches);
}
diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs
index 8599464bd1..330f64cced 100644
--- a/src/Umbraco.Web/UmbracoApplicationBase.cs
+++ b/src/Umbraco.Web/UmbracoApplicationBase.cs
@@ -4,11 +4,13 @@ using System.Reflection;
using System.Threading;
using System.Web;
using System.Web.Hosting;
+using Microsoft.Extensions.Options;
using Serilog.Context;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
@@ -18,6 +20,7 @@ using Umbraco.Infrastructure.Configuration;
using Umbraco.Net;
using Umbraco.Web.Hosting;
using Umbraco.Web.Logging;
+using ConnectionStrings = Umbraco.Core.Configuration.Models.ConnectionStrings;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Web
@@ -27,6 +30,9 @@ namespace Umbraco.Web
///
public abstract class UmbracoApplicationBase : HttpApplication
{
+ private readonly SecuritySettings _securitySettings;
+ private readonly GlobalSettings _globalSettings;
+ private readonly ConnectionStrings _connectionStrings;
private IRuntime _runtime;
private IFactory _factory;
@@ -38,6 +44,7 @@ namespace Umbraco.Web
var hostingSettings = configFactory.HostingSettings;
var globalSettings = configFactory.GlobalSettings;
+ var securitySettings = configFactory.SecuritySettings;
var hostingEnvironment = new AspNetHostingEnvironment(hostingSettings);
var loggingConfiguration = new LoggingConfiguration(
@@ -49,9 +56,13 @@ namespace Umbraco.Web
var configs = configFactory.Create();
+
var backOfficeInfo = new AspNetBackOfficeInfo(globalSettings, ioHelper, logger, configFactory.WebRoutingSettings);
var profiler = GetWebProfiler(hostingEnvironment);
- Umbraco.Composing.Current.Initialize(logger, configs, ioHelper, hostingEnvironment, backOfficeInfo, profiler);
+ Umbraco.Composing.Current.Initialize(logger,
+ ConfigModelConversionsFromLegacy.ConvertSecuritySettings(securitySettings),
+ ConfigModelConversionsFromLegacy.ConvertGlobalSettings(globalSettings),
+ ioHelper, hostingEnvironment, backOfficeInfo, profiler);
Logger = logger;
}
}
@@ -72,12 +83,16 @@ namespace Umbraco.Web
return webProfiler;
}
- protected UmbracoApplicationBase(ILogger logger, Configs configs, IIOHelper ioHelper, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
+ protected UmbracoApplicationBase(ILogger logger, SecuritySettings securitySettings, GlobalSettings globalSettings, ConnectionStrings connectionStrings, IIOHelper ioHelper, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
{
+ _securitySettings = securitySettings;
+ _globalSettings = globalSettings;
+ _connectionStrings = connectionStrings;
+
if (!Umbraco.Composing.Current.IsInitialized)
{
Logger = logger;
- Umbraco.Composing.Current.Initialize(logger, configs, ioHelper, hostingEnvironment, backOfficeInfo, profiler);
+ Umbraco.Composing.Current.Initialize(logger, securitySettings, globalSettings, ioHelper, hostingEnvironment, backOfficeInfo, profiler);
}
}
@@ -120,14 +135,14 @@ namespace Umbraco.Web
///
/// Gets a runtime.
///
- protected abstract IRuntime GetRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo);
+ protected abstract IRuntime GetRuntime(GlobalSettings globalSettings, ConnectionStrings connectionStrings, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo);
///
/// Gets the application register.
///
- protected virtual IRegister GetRegister(IGlobalSettings globalSettings)
+ protected virtual IRegister GetRegister(GlobalSettings globalSettings)
{
- return RegisterFactory.Create(ConfigModelConversionsFromLegacy.ConvertGlobalSettings(globalSettings));
+ return RegisterFactory.Create(globalSettings);
}
// events - in the order they trigger
@@ -159,14 +174,15 @@ namespace Umbraco.Web
// ******** THIS IS WHERE EVERYTHING BEGINS ********
- var globalSettings = Umbraco.Composing.Current.Configs.Global();
+ var globalSettings = _globalSettings;
var umbracoVersion = new UmbracoVersion();
// create the register for the application, and boot
// the boot manager is responsible for registrations
var register = GetRegister(globalSettings);
_runtime = GetRuntime(
- Umbraco.Composing.Current.Configs,
+ _globalSettings,
+ _connectionStrings,
umbracoVersion,
Umbraco.Composing.Current.IOHelper,
Umbraco.Composing.Current.Logger,
diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs
index 73ee4a377e..563435e9f9 100644
--- a/src/Umbraco.Web/UmbracoContext.cs
+++ b/src/Umbraco.Web/UmbracoContext.cs
@@ -2,6 +2,7 @@ using System;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Infrastructure.Configuration;
@@ -18,7 +19,7 @@ namespace Umbraco.Web
public class UmbracoContext : DisposableObjectSlim, IDisposeOnRequestEnd, IUmbracoContext
{
private readonly IHttpContextAccessor _httpContextAccessor;
- private readonly IGlobalSettings _globalSettings;
+ private readonly GlobalSettings _globalSettings;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly ICookieManager _cookieManager;
private readonly Lazy _publishedSnapshot;
@@ -32,7 +33,7 @@ namespace Umbraco.Web
internal UmbracoContext(IHttpContextAccessor httpContextAccessor,
IPublishedSnapshotService publishedSnapshotService,
IWebSecurity webSecurity,
- IGlobalSettings globalSettings,
+ GlobalSettings globalSettings,
IHostingEnvironment hostingEnvironment,
IVariationContextAccessor variationContextAccessor,
UriUtility uriUtility,
@@ -182,7 +183,7 @@ namespace Umbraco.Web
{
var request = GetRequestFromContext();
if (request?.Url != null
- && request.Url.IsBackOfficeRequest(ConfigModelConversionsFromLegacy.ConvertGlobalSettings(_globalSettings), _hostingEnvironment) == false
+ && request.Url.IsBackOfficeRequest(_globalSettings, _hostingEnvironment) == false
&& Security.CurrentUser != null)
{
var previewToken = _cookieManager.GetPreviewCookieValue(); // may be null or empty
diff --git a/src/Umbraco.Web/UmbracoContextFactory.cs b/src/Umbraco.Web/UmbracoContextFactory.cs
index bfb4dd627d..4eba56c36f 100644
--- a/src/Umbraco.Web/UmbracoContextFactory.cs
+++ b/src/Umbraco.Web/UmbracoContextFactory.cs
@@ -2,6 +2,7 @@
using System.IO;
using System.Text;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Services;
@@ -20,7 +21,7 @@ namespace Umbraco.Web
private readonly IVariationContextAccessor _variationContextAccessor;
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
- private readonly IGlobalSettings _globalSettings;
+ private readonly GlobalSettings _globalSettings;
private readonly IUserService _userService;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IHttpContextAccessor _httpContextAccessor;
@@ -35,7 +36,7 @@ namespace Umbraco.Web
IPublishedSnapshotService publishedSnapshotService,
IVariationContextAccessor variationContextAccessor,
IDefaultCultureAccessor defaultCultureAccessor,
- IGlobalSettings globalSettings,
+ GlobalSettings globalSettings,
IUserService userService,
IHostingEnvironment hostingEnvironment,
UriUtility uriUtility,